From ac32c3ea6c0c61fc6c48f1671067fe851ec683eb Mon Sep 17 00:00:00 2001 From: Toufik Ben Jaa Date: Fri, 28 Feb 2020 15:23:34 +0000 Subject: [PATCH] [FIX] models: crash on one2many fields without inverse - In some cases One2many fields defined as computed without inverse field defined could cause crashes if it is used in a search. This should not be done, but shouldn't crash either. With this fix, trying to search on one of this fields would just print a warning. closes odoo/odoo#46742 X-original-commit: 4b4f1623590f2e872c565e8e56002bc3f5bf9efe Signed-off-by: Toufik Benjaa (tbe) --- odoo/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/models.py b/odoo/models.py index afe8b5345a2..bbec718b5a3 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -4346,7 +4346,7 @@ Record ids: %(records)s to_flush[model._name].add(f) if rfield.type in ('many2one', 'one2many', 'many2many'): model = self.env[rfield.comodel_name] - if rfield.type == 'one2many': + if rfield.type == 'one2many' and rfield.inverse_name: to_flush[rfield.comodel_name].add(rfield.inverse_name) if field.comodel_name: model_name = field.comodel_name