[FIX] website_sale: show phone required error on same address

Issue:
======
The phone field is required in a billing and shipping address at the
same time but no warning appears.

Steps to reproduce the issue:
=============================
- Install ecommerce
- Log in with mitchel admin and add anything to cart then go to checkout
- Update the saved address which is for shipping and billing and remove
  the phone
- Save the adress , the page will reload and no error appears.
- Add the phone and save it will works.

Origin of the issue:
====================
`use_same` wasn't passed in `kw` when updating the address.

Solution:
=========
Force `use_same` when validating the values when we have the address is
the same for shipping and billing.

opw-3617720

closes odoo/odoo#146266

Signed-off-by: Mahdi Cheikh Rouhou (macr) <macr@odoo.com>
This commit is contained in:
Mahdi Cheikh Rouhou (macr)
2023-12-19 12:20:06 +00:00
parent 13b338acd8
commit a058996ecc
3 changed files with 53 additions and 2 deletions
@@ -0,0 +1,39 @@
/** @odoo-module **/
import { registry } from "@web/core/registry";
import tourUtils from "@website_sale/js/tours/tour_utils";
registry.category("web_tour.tours").add('update_billing_shipping_address', {
test: true,
url: '/shop',
steps: () => [
...tourUtils.addToCart({productName: "Office Chair Black TEST"}),
tourUtils.goToCart({quantity: 1}),
tourUtils.goToCheckout(),
{
content: "Edit Address",
trigger: '#shipping_and_billing a:contains("Edit")'
},
{
content: "Edit billing address which is shipping address too",
trigger: 'a.js_edit_address'
},
{
content: "Empty the phone field",
trigger: 'input[name="phone"]',
run: () => {
document.querySelector('input[name="phone"]').value = "";
},
},
{
content: "Save address",
trigger: 'a.a-submit',
run: "click",
},
{
content: "Check there is a warning for required field.",
trigger: 'h5.text-danger:contains("Some required fields are empty.")',
run: () => {},
},
],
});
+11 -2
View File
@@ -147,6 +147,15 @@ class TestUi(HttpCaseWithUserDemo):
self.start_tour("/shop", 'google_analytics_view_item')
self.start_tour("/shop", 'google_analytics_add_to_cart')
def test_update_same_address_billing_shipping_edit(self):
''' Phone field should be required when updating an adress for billing and shipping '''
self.env['product.product'].create({
'name': 'Office Chair Black TEST',
'list_price': 12.50,
'is_published': True,
})
self.start_tour("/shop", 'update_billing_shipping_address', login="admin")
@odoo.tests.tagged('post_install', '-at_install')
class TestWebsiteSaleCheckoutAddress(TransactionCaseWithUserDemo, HttpCaseWithUserPortal):
@@ -399,13 +408,13 @@ class TestWebsiteSaleCheckoutAddress(TransactionCaseWithUserDemo, HttpCaseWithUs
partner = self.env['res.partner'].create({'name': 'test'})
be_address_POST, nl_address_POST = [
{
'name': 'Test name', 'email': 'test@email.com', 'street': 'test',
'name': 'Test name', 'email': 'test@email.com', 'street': 'test', 'phone': '+333333333333333',
'city': 'test', 'zip': '3000', 'country_id': self.env.ref('base.be').id, 'submitted': 1,
'partner_id': partner.id,
'callback': '/shop/checkout',
},
{
'name': 'Test name', 'email': 'test@email.com', 'street': 'test',
'name': 'Test name', 'email': 'test@email.com', 'street': 'test', 'phone': '+333333333333333',
'city': 'test', 'zip': '3000', 'country_id': self.env.ref('base.nl').id, 'submitted': 1,
'partner_id': partner.id,
'callback': '/shop/checkout',
+3
View File
@@ -2034,6 +2034,9 @@
</div>
</div>
</t>
<t t-else="">
<input type="hidden" name="use_same" t-att-value="partner_id == website_sale_order.partner_shipping_id.id == website_sale_order.partner_invoice_id.id"/>
</t>
</div>
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()" t-nocache="The csrf token must always be up to date."/>