diff --git a/event_registration_partner_unique/__manifest__.py b/event_registration_partner_unique/__manifest__.py index 15c51c5bc..6270372f2 100644 --- a/event_registration_partner_unique/__manifest__.py +++ b/event_registration_partner_unique/__manifest__.py @@ -15,5 +15,8 @@ "application": False, "installable": True, "depends": ["event", "partner_event"], - "data": ["views/event_event_view.xml"], + "data": [ + "views/event_event_view.xml", + "views/event_type_view.xml" + ], } diff --git a/event_registration_partner_unique/models/event.py b/event_registration_partner_unique/models/event.py index 7769cab59..c41ce410c 100644 --- a/event_registration_partner_unique/models/event.py +++ b/event_registration_partner_unique/models/event.py @@ -13,6 +13,9 @@ class EventEvent(models.Model): forbid_duplicates = fields.Boolean( help="Check this to disallow duplicate attendees in this event's " "registrations", + compute="_compute_forbid_duplicates", + store=True, + readonly=False, ) @api.constrains("forbid_duplicates", "registration_ids") @@ -22,6 +25,15 @@ def _check_forbid_duplicates(self): "forbid_duplicates" ).registration_ids._check_forbid_duplicates() + @api.depends("event_type_id") + def _compute_forbid_duplicates(self): + """Update event configuration from its event type. Depends are set only + on event_type_id itself, not its sub fields. Purpose is to emulate an + onchange: if event type is changed, update event configuration. Changing + event type content itself should not trigger this method.""" + for event in self: + event.forbid_duplicates = event.event_type_id.forbid_duplicates + class EventRegistration(models.Model): _inherit = "event.registration" @@ -51,3 +63,11 @@ def _duplicate_search_domain(self): ("attendee_partner_id", "=", self.attendee_partner_id.id), ("attendee_partner_id", "!=", False), ] + + +class EventType(models.Model): + _inherit = "event.type" + forbid_duplicates = fields.Boolean( + help="Check this to disallow duplicate attendees in this event's " + "registrations" + )