[FIX] event: ensure event_registrations_open can always be computed
Using a compute_sudo ensure this field is correctly computed (aka without crash) if someone is allowed to read the event but not all its sub models. For example event_registrations_open reads the active flag of a product linked to a ticker which may not be readable by public users. This field is used in frontend templates and therefore usable by external people. Also remove unnecessary registrable rendering parameter in website_event as it has been replaced by computed fields. Task ID 2228189 Community PR odoo/odoo#48652 X-original-commit: b2b334a65f3a1379f25717ec39f0a52f3305b19c
This commit is contained in:
@@ -168,7 +168,7 @@ class EventEvent(models.Model):
|
||||
'event.event.ticket', 'event_id', string='Event Ticket', copy=True,
|
||||
compute='_compute_from_event_type', readonly=False, store=True)
|
||||
event_registrations_open = fields.Boolean(
|
||||
'Registration open', compute='_compute_event_registrations_open',
|
||||
'Registration open', compute='_compute_event_registrations_open', compute_sudo=True,
|
||||
help='Registrations are open if event is not ended, seats are available on event and if tickets are sellable if ticketing is used.')
|
||||
start_sale_date = fields.Date(
|
||||
'Start sale date', compute='_compute_start_sale_date',
|
||||
|
||||
@@ -211,7 +211,6 @@ class WebsiteEventController(http.Controller):
|
||||
'sold_out': all(not ticket.sale_available and not ticket.is_expired for ticket in event.event_ticket_ids),
|
||||
'main_object': event,
|
||||
'range': range,
|
||||
'registrable': event.sudo().event_registrations_open,
|
||||
'google_url': urls.get('google_url'),
|
||||
'iCal_url': urls.get('iCal_url'),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user