From b29b4bcbfc61aab1035de1f8b0cb9c796cd4bc58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 1 Apr 2020 12:36:17 +0000 Subject: [PATCH] [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 --- addons/event/models/event_event.py | 2 +- addons/website_event/controllers/main.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/event/models/event_event.py b/addons/event/models/event_event.py index b4f740a89bf..d8e60bb373c 100644 --- a/addons/event/models/event_event.py +++ b/addons/event/models/event_event.py @@ -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', diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py index 11e17a4f7a4..ea484cab7a8 100644 --- a/addons/website_event/controllers/main.py +++ b/addons/website_event/controllers/main.py @@ -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'), }