summaryrefslogtreecommitdiff
path: root/odoo/fields.py
diff options
context:
space:
mode:
authorVictor Feyens <vfe@odoo.com>2020-03-31 14:22:13 +0000
committerRaphael Collet <rco@odoo.com>2020-05-13 12:21:13 +0000
commit0a4b989536be518cb1f4e8211f5a2b56791dfe5b (patch)
tree895c1cf61441fc38c151f7ee07389d4b2e5cb0b1 /odoo/fields.py
parent8ad7e7cb91fc7bccab845630a35e35b288b94fa0 (diff)
[FIX] base: default check_company domain.
The supported case of check_company on `res_company` model fields was not considered when specifying a default domain on `check_company=True` fields. closes odoo/odoo#48674 Nb: It is already correctly supported in the `_check_company()` method. Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/fields.py')
-rw-r--r--odoo/fields.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index a958695b618..89064379bcb 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -2395,11 +2395,14 @@ class _Relational(Field):
else:
return "[('company_id', 'in', [allowed_company_ids[0], False])]"
else:
+ # when using check_company=True on a field on 'res.company', the
+ # company_id comes from the id of the current record
+ cid = "id" if self.model_name == "res.company" else "company_id"
if self.comodel_name == "res.users":
# User allowed company ids = user.company_ids
- return "['|', (not company_id, '=', True), ('company_ids', 'in', [company_id])]"
+ return f"['|', (not {cid}, '=', True), ('company_ids', 'in', [{cid}])]"
else:
- return "[('company_id', 'in', [company_id, False])]"
+ return f"[('company_id', 'in', [{cid}, False])]"
return self.domain(env[self.model_name]) if callable(self.domain) else self.domain
def null(self, record):