[FIX] website_sale: address updates

Improved header (billing/shipping address instead of 'my details')
Keep the use_same input value on invalid form refresh

closes odoo/odoo#139474

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Victor Feyens
2023-10-24 13:55:25 +00:00
parent 7a1f505e31
commit 24c8ff9b28
3 changed files with 28 additions and 15 deletions
+5 -2
View File
@@ -23,7 +23,7 @@ from odoo.addons.website.controllers import main
from odoo.addons.website.controllers.form import WebsiteForm
from odoo.addons.sale.controllers import portal as sale_portal
from odoo.osv import expression
from odoo.tools import lazy
from odoo.tools import lazy, str2bool
from odoo.tools.json import scriptsafe as json_scriptsafe
_logger = logging.getLogger(__name__)
@@ -1333,6 +1333,7 @@ class WebsiteSale(payment_portal.PaymentPortal):
if not errors:
return request.redirect(kw.get('callback') or '/shop/confirm_order')
is_public_user = request.website.is_public_user()
render_values = {
'website_sale_order': order,
'partner_id': partner_id,
@@ -1343,7 +1344,9 @@ class WebsiteSale(payment_portal.PaymentPortal):
'callback': kw.get('callback'),
'only_services': order and order.only_services,
'account_on_checkout': request.website.account_on_checkout,
'is_public_user': request.website.is_public_user()
'is_public_user': is_public_user,
'is_public_order': order._is_public_order(),
'use_same': is_public_user or ('use_same' in kw and str2bool(kw.get('use_same'))),
}
render_values.update(self._get_country_related_render_values(kw, render_values))
return request.render("website_sale.address", render_values)
@@ -62,7 +62,7 @@
{
content: "Fulfill shipping address form",
trigger: 'select[name="country_id"]',
extra_trigger: 'h3:contains("My details")',
extra_trigger: 'h3:contains("Shipping address")',
run: function () {
$('input[name="name"]').val('def');
$('input[name="phone"]').val('8888888888');
@@ -97,7 +97,7 @@
{
content: "Change billing address form",
trigger: 'select[name="country_id"]',
extra_trigger: 'h3:contains("Your address")',
extra_trigger: 'h3:contains("Billing address")',
run: function () {
$('input[name="name"]').val('abcd');
$('input[name="phone"]').val('11111111');
+21 -11
View File
@@ -1844,18 +1844,19 @@
<div class="row">
<div class="oe_cart col-12 col-lg-8">
<div>
<t t-if="mode == ('new', 'billing') and is_public_user">
<t t-set="address_mode" t-value="mode[1]"/>
<t t-if="is_public_order">
<h3 class="mb-3">
<span t-if="account_on_checkout != 'mandatory'">Fill in your address</span>
<small class="text-muted" t-if="account_on_checkout == 'optional'"> or </small>
<a t-if="account_on_checkout != 'disabled'" role="button" href='/web/login?redirect=/shop/checkout' style="margin-top: -11px"> Sign in</a>
</h3>
</t>
<t t-elif="mode == ('edit', 'billing') or mode[1] == 'billing' and not is_public_user">
<h3 class="mb-3">Your address</h3>
<t t-elif="address_mode == 'billing'">
<h3 class="mb-3">Billing address</h3>
</t>
<t t-if="mode[1] == 'shipping'">
<h3 class="mb-3">My details</h3>
<t t-else="">
<h3 class="mb-3">Shipping address</h3>
</t>
<t t-if="partner_id == website_sale_order.partner_shipping_id.id == website_sale_order.partner_invoice_id.id">
<div class="alert alert-warning" role="alert" t-if="not only_services">
@@ -1887,7 +1888,7 @@
<t t-if="website._display_partner_b2b_fields()">
<div class="w-100"/>
<t t-set='vat_warning' t-value="'vat' in checkout and checkout['vat'] and not can_edit_vat" />
<t t-if="(mode == ('new', 'billing') and website_sale_order._is_public_order()
<t t-if="(mode == ('new', 'billing') and is_public_order
or mode == ('edit', 'billing') and partner_id == website_sale_order.partner_id.id)
and (can_edit_vat or 'vat' in checkout and checkout['vat'])"
>
@@ -1959,11 +1960,20 @@
<t t-if="mode == ('new', 'billing') and not only_services">
<div class="col-lg-12">
<div class="form-check form-switch mt-2 mb-3">
<label>
<input type="checkbox" id='shipping_use_same' class="form-check-input mr8" name='use_same' value="1" t-att-checked='website.is_public_user()'/>Ship to the same address
<t t-if='website.is_public_user()'>
<span class='form-check-label ship_to_other text-muted' style="display: none">&amp;nbsp;(<i>Your shipping address will be requested later) </i></span>
</t>
<label>
<input
type="checkbox"
id="shipping_use_same"
class="form-check-input mr8"
name="use_same"
value="1"
t-att-checked="use_same"/>Ship to the same address
<span
t-if="is_public_user"
class="form-check-label ship_to_other text-muted"
style="display: none">
&amp;nbsp;(<i>Your shipping address will be requested later)</i>
</span>
</label>
</div>
</div>