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
This commit is contained in:
Cédric Krier committed 2023-02-17 12:56:18 +01:00
1 parent f471e81c11
commit 30d2bcb2a8
1 file changed
+5
+5
View File
@@ -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