[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) <tbe@odoo.com>
This commit is contained in:
Toufik Ben Jaa
2020-03-03 12:19:10 +00:00
parent ed3f448e68
commit ac32c3ea6c
+1 -1
View File
@@ -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