From 3977a50bcbf86cf15e034c9cf6e3a3e85eaf3607 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 24 Aug 2023 10:38:54 +0200 Subject: [PATCH] [FIX] event_sale: registration data on portal confirmation When a customer with a sale portal link confirms the order, the registrations in the order won't have the data for the partner of the order which would be the expected default. In 6cfdf64a86ef5c10422910734d7356a86c0c1dd6 the intention is to avoid that registrations made on the website by anonymous users are registered with the public user. There's a side effect to this in the portal workflow though. We can reproduce it like this: - We need a payment aqcquire wich confirms our sale order (we can use payment demo) - In backend, create a sale order with the desired partner and a registration to an event. - Send the quotation to the partner. - With the link portal (and without being logged in) sign and pay the order with the demo payment aquirer. Result: - The order gets confirmed. - The registrations are created with no partner (booked by). So this fix avoids the original issue (having a public user as the registration partner) but saving the case where we are confident about the booked by value. TT44782 closes odoo/odoo#148758 X-original-commit: 28020f2046b0183293a06ab03d4724173e3a0fa0 Signed-off-by: Thibault Delavallee (tde) --- addons/event_sale/models/event_registration.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/event_sale/models/event_registration.py b/addons/event_sale/models/event_registration.py index 26a6a64802b..e765e016035 100644 --- a/addons/event_sale/models/event_registration.py +++ b/addons/event_sale/models/event_registration.py @@ -105,7 +105,8 @@ class EventRegistration(models.Model): def _synchronize_so_line_values(self, so_line): if so_line: return { - 'partner_id': False if self.env.user._is_public() else so_line.order_id.partner_id.id, + # Avoid registering public users but respect the portal workflows + 'partner_id': False if self.env.user._is_public() and self.env.user.partner_id == so_line.order_id.partner_id else so_line.order_id.partner_id.id, 'event_id': so_line.event_id.id, 'event_ticket_id': so_line.event_ticket_id.id, 'sale_order_id': so_line.order_id.id,