From 30d2bcb2a8f6f2172ac6abd4b637bf4d0597d082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 17 Feb 2023 12:56:18 +0100 Subject: [PATCH] Find invalid records of xxx2Many field using intersection For xxx2Many field, the contain test is not working correctly because the field value is a tuple of records which is never in the list of invalid relations. Closes #12099 --- trytond/trytond/model/modelstorage.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/trytond/trytond/model/modelstorage.py b/trytond/trytond/model/modelstorage.py index 12a7447395..2e219889d3 100644 --- a/trytond/trytond/model/modelstorage.py +++ b/trytond/trytond/model/modelstorage.py @@ -1271,6 +1271,11 @@ class ModelStorage(Model): 'many2one', 'one2many', 'many2many', 'one2one', 'reference'}: invalid_records = invalid_relations + elif field._type.endswith('2many'): + invalid_records = [ + r for r in records + if invalid_relations.intersection( + getattr(r, field.name))] else: invalid_records = [ r for r in records