@@ -13,6 +13,9 @@ class EventEvent(models.Model):
13
13
forbid_duplicates = fields .Boolean (
14
14
help = "Check this to disallow duplicate attendees in this event's "
15
15
"registrations" ,
16
+ compute = "_compute_forbid_duplicates" ,
17
+ store = True ,
18
+ readonly = False ,
16
19
)
17
20
18
21
@api .constrains ("forbid_duplicates" , "registration_ids" )
@@ -22,6 +25,15 @@ def _check_forbid_duplicates(self):
22
25
"forbid_duplicates"
23
26
).registration_ids ._check_forbid_duplicates ()
24
27
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
+
25
37
26
38
class EventRegistration (models .Model ):
27
39
_inherit = "event.registration"
@@ -51,3 +63,11 @@ def _duplicate_search_domain(self):
51
63
("attendee_partner_id" , "=" , self .attendee_partner_id .id ),
52
64
("attendee_partner_id" , "!=" , False ),
53
65
]
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