From ea8477391a411e41eadaab10c5464f8f0331a5fc 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 (grafted from 9dabdd3422a69e132269c4e9cc02076286aba3ed) --HG-- branch : 6.0 --- 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 11510288a1..ac1bffa98f 100644 --- a/trytond/trytond/model/modelstorage.py +++ b/trytond/trytond/model/modelstorage.py @@ -1182,6 +1182,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