summaryrefslogtreecommitdiff
path: root/odoo/fields.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2021-02-25 16:56:52 +0000
committerRaphael Collet <rco@odoo.com>2021-02-26 15:07:09 +0000
commitb2235e2749504e6eee9e6f8090d1df54cf5971b7 (patch)
tree86c8f4a989f05e3f7914d56335fafe0ab09aabb8 /odoo/fields.py
parent71cc7212b1c1abad5d37e29f3a1f33f6e6cd2a81 (diff)
[FIX] core: convert_to_write() of x2many field with new records
When comparing the values of a new record with its origin, x2many fields are always different because we compare new records with real records. For instance, converting the value of a one2many field where lines have a many2many field always returns update commands for the many2many field. closes odoo/odoo#66937 X-original-commit: 03a4137cc3fa398dbd0cb214dc5472a083ae33b8 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/fields.py')
-rw-r--r--odoo/fields.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index fc159a3dc89..0396437a446 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -2978,6 +2978,9 @@ class _RelationalMulti(_Relational):
value = record.env[self.comodel_name].browse(value)
if isinstance(value, BaseModel) and value._name == self.comodel_name:
+ def get_origin(val):
+ return val._origin if isinstance(val, BaseModel) else val
+
# make result with new and existing records
inv_names = {field.name for field in record._field_inverses[self]}
result = [(6, 0, [])]
@@ -2996,7 +2999,7 @@ class _RelationalMulti(_Relational):
values = record._convert_to_write({
name: record[name]
for name in record._cache
- if name not in inv_names and record[name] != origin[name]
+ if name not in inv_names and get_origin(record[name]) != origin[name]
})
if values:
result.append((1, origin.id, values))