Skip to content

Commit dbf4b41

Browse files
committed
[FIX] product_multi_company: don't change rules, but respect previous company assignments
Remove lots of code thanks to #760. Also, call the new `fill_company_ids` hook, to respect company assignments done before the module installation. @moduon MT-8863
1 parent 5c0a6cf commit dbf4b41

File tree

9 files changed

+15
-64
lines changed

9 files changed

+15
-64
lines changed

Diff for: product_multi_company/README.rst

+4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ Contributors
8484
* Prabakaran <[email protected]>
8585
* Karthik <[email protected]>
8686

87+
* `Moduon <https://www.moduon.team/>`__:
88+
89+
* Jairo Llopis
90+
8791
Maintainers
8892
~~~~~~~~~~~
8993

Diff for: product_multi_company/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
from . import models
22
from .hooks import post_init_hook
3-
from .hooks import uninstall_hook

Diff for: product_multi_company/__manifest__.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
"depends": ["base_multi_company", "product"],
1313
"data": ["views/product_template_view.xml"],
1414
"post_init_hook": "post_init_hook",
15-
"uninstall_hook": "uninstall_hook",
1615
}

Diff for: product_multi_company/hooks.py

+3-27
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,10 @@
11
# Copyright 2015-2016 Pedro M. Baeza <[email protected]>
22
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3-
4-
import logging
5-
63
from odoo import SUPERUSER_ID, api
74

8-
_logger = logging.getLogger(__name__)
9-
10-
try:
11-
from odoo.addons.base_multi_company import hooks
12-
except ImportError:
13-
_logger.info("Cannot find `base_multi_company` module in addons path.")
5+
from odoo.addons.base_multi_company import hooks
146

157

168
def post_init_hook(cr, registry):
17-
env = api.Environment(cr, SUPERUSER_ID, {})
18-
# Change access rule
19-
rule = env.ref("product.product_comp_rule")
20-
rule.write(
21-
{
22-
"domain_force": (
23-
"['|', ('company_ids', 'in', company_ids),"
24-
"('company_ids', '=', False)]"
25-
),
26-
}
27-
)
28-
29-
30-
def uninstall_hook(cr, registry):
31-
hooks.uninstall_hook(
32-
cr,
33-
"product.product_comp_rule",
34-
)
9+
api.Environment(cr, SUPERUSER_ID, {})
10+
hooks.fill_company_ids(cr, "product.template")

Diff for: product_multi_company/models/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Copyright 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
22
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
33

4-
from . import product_product
54
from . import product_template

Diff for: product_multi_company/models/product_product.py

-26
This file was deleted.

Diff for: product_multi_company/readme/CONTRIBUTORS.rst

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010

1111
* Prabakaran <[email protected]>
1212
* Karthik <[email protected]>
13+
14+
* `Moduon <https://www.moduon.team/>`__:
15+
16+
* Jairo Llopis

Diff for: product_multi_company/static/description/index.html

+4
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
430430
<li>Karthik &lt;<a class="reference external" href="mailto:karthik&#64;sodexis.com">karthik&#64;sodexis.com</a>&gt;</li>
431431
</ul>
432432
</li>
433+
<li><a class="reference external" href="https://www.moduon.team/">Moduon</a>:<ul>
434+
<li>Jairo Llopis</li>
435+
</ul>
436+
</li>
433437
</ul>
434438
</div>
435439
<div class="section" id="maintainers">

Diff for: product_multi_company/tests/test_product_multi_company.py

-8
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,3 @@ def test_search_product(self):
136136
]
137137
)
138138
self.assertEqual(searched_products, expected_products)
139-
140-
def test_uninstall(self):
141-
from ..hooks import uninstall_hook
142-
143-
uninstall_hook(self.env.cr, None)
144-
rule = self.env.ref("product.product_comp_rule")
145-
domain = " [('company_id', 'in', [False, user.company_id.id])]"
146-
self.assertEqual(rule.domain_force, domain)

0 commit comments

Comments
 (0)