summaryrefslogtreecommitdiff
path: root/odoo/models.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2020-06-19 12:00:09 +0000
committerRaphael Collet <rco@odoo.com>2020-06-23 14:00:42 +0000
commitea83473eab2ba3f23673dd2561f3c80550a4671d (patch)
tree0fbca11adeb3cb3d363fc20bb595ac137ed53e22 /odoo/models.py
parent536759644e13448f1c2b14d95cc8ecb44e5f0b24 (diff)
[FIX] core: flush() with one2many fields
This ensures that flushing a one2many field automatically flushes its inverse many2one/integer field. Without that, a search like: model.search([('o2m_ids', 'in', ids)]) can return incorrect results. closes odoo/odoo#53514 X-original-commit: b91b485a5d9a62acfe44b12c64a46dcca23981ce Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/models.py')
-rw-r--r--odoo/models.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/odoo/models.py b/odoo/models.py
index 42b1344e2e4..f4b0012dfff 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -5349,6 +5349,12 @@ Record ids: %(records)s
id_vals = self.env.all.towrite.pop(model_name)
process(self.env[model_name], id_vals)
+ # missing for one2many fields, flush their inverse
+ for fname in fnames:
+ field = self._fields[fname]
+ if field.type == 'one2many' and field.inverse_name:
+ self.env[field.comodel_name].flush([field.inverse_name])
+
#
# New records - represent records that do not exist in the database yet;
# they are used to perform onchanges.