From 8670584299b0fb4e7d5a8e915e5791fd797b9fa0 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 6 Jun 2019 13:39:36 +0200 Subject: [PATCH] [FIX] core: in onchanges, verfiy that x2many are the same records Comparing the length of the recordset is not enough for determining if there is changes on m2m. This also fix the merge of f14ae73a98ecb40c102c8a22729df4ceb44802e9 and d0bb596f1d51b72a6aa20d56eef3e65aefbd09b2 Oversight of previous forward-port. --- odoo/models.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/odoo/models.py b/odoo/models.py index ddbae89f9a4..cf3b12278ed 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -5481,14 +5481,20 @@ Fields: """ Return whether a field on record has changed. """ record = self[''] subnames = self[''][name] - if not subnames: + if record._fields[name].type not in ('one2many', 'many2many'): return self[name] != record[name] - else: - return len(self[name]) != len(record[name]) or any( + return ( + len(self[name]) != len(record[name]) + or ( + set(line_snapshot[""].id for line_snapshot in self[name]) + != set(record[name]._ids) + ) + or any( line_snapshot.has_changed(subname) for line_snapshot in self[name] for subname in subnames ) + ) def diff(self, other): """ Return the values in ``self`` that differ from ``other``.