Skip to content

Commit d83102d

Browse files
author
Hadrien Huvelle
committed
[16.0] adds forbid_duplicates on event.type
1 parent 8e02d5e commit d83102d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

event_registration_partner_unique/__manifest__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
"application": False,
1616
"installable": True,
1717
"depends": ["event", "partner_event"],
18-
"data": ["views/event_event_view.xml"],
18+
"data": [
19+
"views/event_event_view.xml",
20+
"views/event_type_view.xml"
21+
],
1922
}

event_registration_partner_unique/models/event.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class EventEvent(models.Model):
1313
forbid_duplicates = fields.Boolean(
1414
help="Check this to disallow duplicate attendees in this event's "
1515
"registrations",
16+
compute="_compute_forbid_duplicates",
17+
store=True,
18+
readonly=False,
1619
)
1720

1821
@api.constrains("forbid_duplicates", "registration_ids")
@@ -22,6 +25,15 @@ def _check_forbid_duplicates(self):
2225
"forbid_duplicates"
2326
).registration_ids._check_forbid_duplicates()
2427

28+
@api.depends("event_type_id")
29+
def _compute_forbid_duplicates(self):
30+
"""Update event configuration from its event type. Depends are set only
31+
on event_type_id itself, not its sub fields. Purpose is to emulate an
32+
onchange: if event type is changed, update event configuration. Changing
33+
event type content itself should not trigger this method."""
34+
for event in self:
35+
event.forbid_duplicates = event.event_type_id.forbid_duplicates
36+
2537

2638
class EventRegistration(models.Model):
2739
_inherit = "event.registration"
@@ -51,3 +63,11 @@ def _duplicate_search_domain(self):
5163
("attendee_partner_id", "=", self.attendee_partner_id.id),
5264
("attendee_partner_id", "!=", False),
5365
]
66+
67+
68+
class EventType(models.Model):
69+
_inherit = "event.type"
70+
forbid_duplicates = fields.Boolean(
71+
help="Check this to disallow duplicate attendees in this event's "
72+
"registrations"
73+
)

0 commit comments

Comments
 (0)