[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>
This commit is contained in:
Victor Feyens
2020-05-13 12:21:13 +00:00
committed by Raphael Collet
parent 8ad7e7cb91
commit 0a4b989536
+5 -2
View File
@@ -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):