[IMP] website_event_booth_*: propagate fields and redirect the page to the cart

{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) <awa@odoo.com>
This commit is contained in:
Mahamadasif Ansari
2023-02-17 09:50:50 +01:00
parent d6589641cf
commit 81bb575598
6 changed files with 17 additions and 14 deletions
@@ -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'):
@@ -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):
@@ -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()
@@ -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)',
@@ -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",
@@ -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",