-
-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] base_multi_company: support
in False
search operators
Before this commit, when doing a read with a domain such as [the one used by upstream `base.res_partner_rule`][1], the read failed to find records without company. This is now fixed in the base module, adding tested support for such operators. The only relevant part of the hooks that were provided to workaround the issue is extracted to a new `post_init_hook`. All other hooks are marked as deprecated. [1]: https://github.com/odoo/odoo/blob/db072461cddced2a8f65a64fb6d2ddf0dd79b38e/odoo/addons/base/security/base_security.xml#L23 @moduon MT-8863
- Loading branch information
Showing
7 changed files
with
66 additions
and
58 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,7 @@ Contributors | |
* Rodrigo Ferreira <[email protected]> | ||
* Florian da Costa <[email protected]> | ||
* Denis Roussel <[email protected]> | ||
* Jairo Llopis (`Moduon <https://www.moduon.team/>`__) | ||
|
||
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,6 +1,8 @@ | ||
# Copyright 2015-2016 Pedro M. Baeza <[email protected]> | ||
# Copyright 2017 LasLabs Inc. | ||
# License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html | ||
import warnings | ||
|
||
from odoo import SUPERUSER_ID, api | ||
|
||
__all__ = [ | ||
|
@@ -15,6 +17,10 @@ def set_security_rule(env, rule_ref): | |
:param: env: Environment | ||
:param: rule_ref: XML-ID of the security rule to change. | ||
""" | ||
warnings.warn( | ||
"This hook is deprecated. Use `fill_company_ids` instead.", | ||
DeprecationWarning, | ||
) | ||
rule = env.ref(rule_ref) | ||
if not rule: # safeguard if it's deleted | ||
return | ||
|
@@ -38,6 +44,12 @@ def post_init_hook(cr, rule_ref, model_name): | |
""" | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
set_security_rule(env, rule_ref) | ||
fill_company_ids(cr, model_name) | ||
|
||
|
||
def fill_company_ids(cr, model_name): | ||
"""Fill company_ids with company_id values.""" | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
# Copy company values | ||
model = env[model_name] | ||
table_name = model._fields["company_ids"].relation | ||
|
@@ -65,6 +77,7 @@ def uninstall_hook(cr, rule_ref): | |
rule_ref (string): XML ID of security rule to remove the | ||
`domain_force` from. | ||
""" | ||
warnings.warn("This hook is deprecated.", DeprecationWarning) | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
# Change access rule | ||
rule = env.ref(rule_ref) | ||
|
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
* Rodrigo Ferreira <[email protected]> | ||
* Florian da Costa <[email protected]> | ||
* Denis Roussel <[email protected]> | ||
* Jairo Llopis (`Moduon <https://www.moduon.team/>`__) |
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
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