From 81bb5755987769e097da40b8b5abfd782d1932d7 Mon Sep 17 00:00:00 2001 From: Mahamadasif Ansari Date: Tue, 13 Dec 2022 10:17:39 +0000 Subject: [PATCH] [IMP] website_event_booth_*: propagate fields and redirect the page to the cart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit {sale, exhibitor, sale_exhibitor} Specification: - Currently, when a user books an event, it redirects to the checkout page; however, if the user already has some items in their cart, they will appear at the checkout; if they need to remove them, they must go to the cart page. It's better to redirect users to the cart page rather than the checkout page. - When a user enters the booth registration value, it fills the fields name, email, phone, and mobile, but when the user enters the address of the order, the same fields are filled by the user, so it is preferred that the fields value entered in booth registration appears in the address of the order as well. This commit done following changes: - Redirect the review order instead of the checkout order when booking the event booth. - By adding the partner to the order, it can propagate the values of the fields name, phone, and email. - When a partner is created in the website event booth, the email address is stored in the name. This commit passes the name and email instead of the email address so that the partner can be stored with the name. - If the contact does not have a name or phone number, it will set the sponsor's name or phone number as the contact. - Adaptations to the tour to accommodate the above changes task-3098295 closes odoo/odoo#112525 X-original-commit: ca2bac512000674d1ee55ed3151bbdace2311234 Signed-off-by: Warnon Aurélien (awa) --- addons/website_event_booth/controllers/event_booth.py | 6 +++--- .../controllers/event_booth.py | 4 ++++ .../website_event_booth_sale/controllers/event_booth.py | 4 +++- .../static/tests/tours/website_event_booth.js | 4 ++-- .../tests/tours/website_event_booth_sale_pricelists.js | 9 +++------ .../tests/tours/website_event_booth_sale_exhibitor.js | 4 ++-- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/addons/website_event_booth/controllers/event_booth.py b/addons/website_event_booth/controllers/event_booth.py index 5873b6183bf..67b990cc747 100644 --- a/addons/website_event_booth/controllers/event_booth.py +++ b/addons/website_event_booth/controllers/event_booth.py @@ -5,7 +5,7 @@ import json import werkzeug from werkzeug.exceptions import Forbidden, NotFound -from odoo import exceptions, http, _ +from odoo import exceptions, http, tools from odoo.http import request from odoo.addons.website_event.controllers.main import WebsiteEventController @@ -102,8 +102,8 @@ class WebsiteEventBoothController(WebsiteEventController): def _prepare_booth_registration_partner_values(self, event, kwargs): if request.env.user._is_public(): - contact_email = kwargs['contact_email'] - partner = request.env['res.partner'].sudo().find_or_create(contact_email) + contact_name_email = tools.formataddr((kwargs['contact_name'], kwargs['contact_email'])) + partner = request.env['res.partner'].sudo().find_or_create(contact_name_email) if not partner.name and kwargs.get('contact_name'): partner.name = kwargs['contact_name'] if not partner.phone and kwargs.get('contact_phone'): diff --git a/addons/website_event_booth_exhibitor/controllers/event_booth.py b/addons/website_event_booth_exhibitor/controllers/event_booth.py index e43b53aa8b2..23ed74cce01 100644 --- a/addons/website_event_booth_exhibitor/controllers/event_booth.py +++ b/addons/website_event_booth_exhibitor/controllers/event_booth.py @@ -26,6 +26,10 @@ class WebsiteEventBoothController(WebsiteEventController): def _prepare_booth_registration_partner_values(self, event, kwargs): if not kwargs.get('contact_email') and kwargs.get('sponsor_email'): kwargs['contact_email'] = kwargs['sponsor_email'] + if not kwargs.get('contact_name') and kwargs.get('sponsor_name'): + kwargs['contact_name'] = kwargs['sponsor_name'] + if not kwargs.get('contact_phone') and kwargs.get('sponsor_phone'): + kwargs['contact_phone'] = kwargs['sponsor_phone'] return super(WebsiteEventBoothController, self)._prepare_booth_registration_partner_values(event, kwargs) def _prepare_booth_registration_sponsor_values(self, event, booth_values, kwargs): diff --git a/addons/website_event_booth_sale/controllers/event_booth.py b/addons/website_event_booth_sale/controllers/event_booth.py index 3978aacb454..c2de0ce13bc 100644 --- a/addons/website_event_booth_sale/controllers/event_booth.py +++ b/addons/website_event_booth_sale/controllers/event_booth.py @@ -37,7 +37,9 @@ class WebsiteEventBoothController(WebsiteEventController): registration_values=booth_values, ) if order_sudo.amount_total: - return json.dumps({'redirect': '/shop/checkout'}) + if request.env.user._is_public(): + order_sudo.partner_id = booth_values['partner_id'] + return json.dumps({'redirect': '/shop/cart'}) elif order_sudo: order_sudo.action_confirm() request.website.sale_reset() diff --git a/addons/website_event_booth_sale/static/tests/tours/website_event_booth.js b/addons/website_event_booth_sale/static/tests/tours/website_event_booth.js index 2e62e26c064..abd4baac667 100644 --- a/addons/website_event_booth_sale/static/tests/tours/website_event_booth.js +++ b/addons/website_event_booth_sale/static/tests/tours/website_event_booth.js @@ -40,8 +40,8 @@ registry.category("web_tour.tours").add('website_event_booth_tour', { trigger: 'tr#order_total_taxes .oe_currency_value:containsExact(20.00)', run: function () {}, }, { - content: 'Click confirm to continue', - trigger: 'a[role="button"] span:contains("Confirm")', + content: 'Click Process Checkout to continue', + trigger: 'a[role="button"] span:contains("Process Checkout")', }, { content: 'Check if the price is correct', trigger: 'tr#order_total_untaxed .oe_currency_value:containsExact(200.00)', diff --git a/addons/website_event_booth_sale/static/tests/tours/website_event_booth_sale_pricelists.js b/addons/website_event_booth_sale/static/tests/tours/website_event_booth_sale_pricelists.js index d7eaaaba699..8cedad3f04e 100644 --- a/addons/website_event_booth_sale/static/tests/tours/website_event_booth_sale_pricelists.js +++ b/addons/website_event_booth_sale/static/tests/tours/website_event_booth_sale_pricelists.js @@ -38,12 +38,9 @@ registry.category("web_tour.tours").add('event_booth_sale_pricelists_different_c { content: 'Submit your informations', trigger: 'button[type="submit"]', - }, - { - content: 'Confirm Order', - extra_trigger: 'h3:contains("Billing Address")', - trigger: '.btn:contains("Confirm")', - run: function () {}, + }, { + content: 'Checkout your order', + trigger: 'a[role="button"] span:contains("Process Checkout")', }, ...getPriceListChecksSteps({ pricelistName: "EUR With Discount Included", diff --git a/addons/website_event_booth_sale_exhibitor/static/tests/tours/website_event_booth_sale_exhibitor.js b/addons/website_event_booth_sale_exhibitor/static/tests/tours/website_event_booth_sale_exhibitor.js index 0820ee420c4..82219adde23 100644 --- a/addons/website_event_booth_sale_exhibitor/static/tests/tours/website_event_booth_sale_exhibitor.js +++ b/addons/website_event_booth_sale_exhibitor/static/tests/tours/website_event_booth_sale_exhibitor.js @@ -7,8 +7,8 @@ odoo.define("website_event_booth_sale_exhibitor.tour", function (require) { _getSteps: function () { return [{ - content: 'Confirm your order', - trigger: '.btn-primary[href="/shop/confirm_order"]', + content: 'Checkout your order', + trigger: 'a[role="button"] span:contains("Process Checkout")', run: 'click', }, { content: "Select `Wire Transfer` payment method",