summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorstd-odoo <std@odoo.com>2020-07-16 09:48:57 +0000
committerstd-odoo <std@odoo.com>2020-07-17 08:34:12 +0000
commit89a2423c219beba85e682c30570a7c1a3b4d7014 (patch)
treea7a7cbd2a8d405ab67913341a09e4181718814f9 /addons
parentce8cb11054585ba27119656cb6a5e1760f27a84e (diff)
[FIX] website_event: fix ACL issue during registration
Bug === Register to an event with a public user. Sometimes an ACL error will be raised. Technical ========= Before flushing the environment (after the creation of the event registration in the endpoint `registration_confirm`), the ORM will recompute all needed stored fields. As we didn't write on some of them (`date_closed`, `utm_campaign_id`, `utm_source_id`, `utm_medium_id`) they are in the list `Environment::all.tocompute`. So, the ORM will recompute the fields even if the state didn't change (this behavior can be verify in `BaseModel::recompute`). This is done after the "create" call of the event registration and so without the SUDO flag. Task-2299227 closes odoo/odoo#54624 X-original-commit: 38f37cd483b7907b20171e2c44e14e69e3e00596 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/event/models/event_registration.py7
-rw-r--r--addons/event_sale/models/event_registration.py6
2 files changed, 11 insertions, 2 deletions
diff --git a/addons/event/models/event_registration.py b/addons/event/models/event_registration.py
index a611d300bdf..d8dc794b6e4 100644
--- a/addons/event/models/event_registration.py
+++ b/addons/event/models/event_registration.py
@@ -86,8 +86,11 @@ class EventRegistration(models.Model):
@api.depends('state')
def _compute_date_closed(self):
for registration in self:
- if registration.state == 'done' and not registration.date_closed:
- registration.date_closed = fields.Datetime.now()
+ if not registration.date_closed:
+ if registration.state == 'done':
+ registration.date_closed = fields.Datetime.now()
+ else:
+ registration.date_closed = False
@api.constrains('event_id', 'state')
def _check_seats_limit(self):
diff --git a/addons/event_sale/models/event_registration.py b/addons/event_sale/models/event_registration.py
index 6ff16fa1c31..cd35ff5d2e4 100644
--- a/addons/event_sale/models/event_registration.py
+++ b/addons/event_sale/models/event_registration.py
@@ -38,18 +38,24 @@ class EventRegistration(models.Model):
for registration in self:
if registration.sale_order_id.campaign_id:
registration.utm_campaign_id = registration.sale_order_id.campaign_id
+ elif not registration.utm_campaign_id:
+ registration.utm_campaign_id = False
@api.depends('sale_order_id')
def _compute_utm_source_id(self):
for registration in self:
if registration.sale_order_id.source_id:
registration.utm_source_id = registration.sale_order_id.source_id
+ elif not registration.utm_source_id:
+ registration.utm_source_id = False
@api.depends('sale_order_id')
def _compute_utm_medium_id(self):
for registration in self:
if registration.sale_order_id.medium_id:
registration.utm_medium_id = registration.sale_order_id.medium_id
+ elif not registration.utm_medium_id:
+ registration.utm_medium_id = False
def action_view_sale_order(self):
action = self.env.ref('sale.action_orders').read()[0]