Skip to content

Commit

Permalink
[16.0] adds forbid_duplicates on event.type
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadrien Huvelle committed Oct 4, 2024
1 parent 8e02d5e commit d83102d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion event_registration_partner_unique/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
}
20 changes: 20 additions & 0 deletions event_registration_partner_unique/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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"
Expand Down Expand Up @@ -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"
)

0 comments on commit d83102d

Please sign in to comment.