-
-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
10 changed files
with
49 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,10 @@ Contributors | |
* Prabakaran <[email protected]> | ||
* Karthik <[email protected]> | ||
|
||
* `Moduon <https://www.moduon.team/>`__: | ||
|
||
* Jairo Llopis | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
from . import models | ||
from .hooks import post_init_hook | ||
from .hooks import uninstall_hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,10 @@ | ||
# Copyright 2015-2016 Pedro M. Baeza <[email protected]> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
import logging | ||
|
||
from odoo import SUPERUSER_ID, api | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
try: | ||
from odoo.addons.base_multi_company import hooks | ||
except ImportError: | ||
_logger.info("Cannot find `base_multi_company` module in addons path.") | ||
from odoo.addons.base_multi_company import hooks | ||
|
||
|
||
def post_init_hook(cr, registry): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
# Change access rule | ||
rule = env.ref("product.product_comp_rule") | ||
rule.write( | ||
{ | ||
"domain_force": ( | ||
"['|', ('company_ids', 'in', company_ids)," | ||
"('company_ids', '=', False)]" | ||
), | ||
} | ||
) | ||
|
||
|
||
def uninstall_hook(cr, registry): | ||
hooks.uninstall_hook( | ||
cr, | ||
"product.product_comp_rule", | ||
) | ||
api.Environment(cr, SUPERUSER_ID, {}) | ||
hooks.fill_company_ids(cr, "product.template") |
34 changes: 34 additions & 0 deletions
34
product_multi_company/migrations/16.0.1.0.3/pre-migrate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2025 Moduon Team S.L. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) | ||
from logging import getLogger | ||
|
||
from openupgradelib import openupgrade | ||
|
||
from odoo.tools import safe_eval | ||
|
||
_logger = getLogger(__name__) | ||
|
||
PREVIOUS_DOMAIN = [ | ||
"|", | ||
("company_ids", "in", "COMPANY_IDS"), | ||
("company_ids", "=", False), | ||
] | ||
UPSTREAM_DOMAIN = " [('company_id', 'in', company_ids + [False])]" | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
"""Restore upstream partner rule.""" | ||
rule = env.ref("product.product_comp_rule", False) | ||
if not rule: | ||
return | ||
try: | ||
domain = safe_eval( | ||
rule.domain_force, locals_dict={"company_ids": "COMPANY_IDS"} | ||
) | ||
except Exception: | ||
_logger.warning("Unable to evaluate domain_force") | ||
return | ||
if domain == PREVIOUS_DOMAIN: | ||
rule.domain_force = UPSTREAM_DOMAIN | ||
_logger.info("Restored upstream partner rule") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# Copyright 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import product_product | ||
from . import product_template |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,7 @@ | |
|
||
* Prabakaran <[email protected]> | ||
* Karthik <[email protected]> | ||
|
||
* `Moduon <https://www.moduon.team/>`__: | ||
|
||
* Jairo Llopis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters