Skip to content

Commit f6efa37

Browse files
committed
fix write, added loop for multiple records
1 parent 89b3eb5 commit f6efa37

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

g2p_registry_membership/models/group.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ class G2PMembershipGroup(models.Model):
3030
def write(self, values):
3131
res = super().write(values)
3232
if self:
33-
unique_kinds = self.env["g2p.group.membership.kind"].search([("is_unique", "=", True)])
34-
for unique_kind in unique_kinds:
35-
count = sum(1 for rec in self.group_membership_ids if unique_kind.id in rec.kind.ids)
36-
if count > 1:
37-
raise ValidationError(_("Only one %s is allowed per group") % unique_kind.name)
33+
for rec in self:
34+
unique_kinds = self.env["g2p.group.membership.kind"].search([("is_unique", "=", True)])
35+
for unique_kind in unique_kinds:
36+
count = sum(1 for member in rec.group_membership_ids if unique_kind.id in member.kind.ids)
37+
if count > 1:
38+
raise ValidationError(_("Only one %s is allowed per group") % unique_kind.name)
3839
return res
3940

4041
@api.model

0 commit comments

Comments
 (0)