diff options
| author | Florent de Labarre <florent.mirieu@gmail.com> | 2021-04-21 13:36:55 +0000 |
|---|---|---|
| committer | Florent de Labarre <florent.mirieu@gmail.com> | 2021-04-23 17:19:18 +0000 |
| commit | f8c8418bdd5b9d27b33fea3c63511297a231aa93 (patch) | |
| tree | 873a10d01efe0986a666d864e609c956e3f23fe5 /addons | |
| parent | 020958f55d384e546eb61c98763d45b5db1ed206 (diff) | |
[FIX] website_sale : check mandatory fields
If a partner have two delivery address, one full filled, an other with missing fields. During the shopping (the first delivery address is auto selected), if the partner go back in shop/address to select the second address. Then go to /shop/confirm_order, there no checks.
closes odoo/odoo#69615
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/website_sale/controllers/main.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 8495170c790..e1160a2df43 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -491,6 +491,15 @@ class WebsiteSale(http.Controller): # Checkout # ------------------------------------------------------ + def checkout_check_address(self, order): + billing_fields_required = self._get_mandatory_fields_billing(order.partner_id.country_id.id) + if not all(order.partner_id.read(billing_fields_required)[0].values()): + return request.redirect('/shop/address?partner_id=%d' % order.partner_id.id) + + shipping_fields_required = self._get_mandatory_fields_shipping(order.partner_shipping_id.country_id.id) + if not all(order.partner_shipping_id.read(shipping_fields_required)[0].values()): + return request.redirect('/shop/address?partner_id=%d' % order.partner_shipping_id.id) + def checkout_redirection(self, order): # must have a draft sales order with lines at this point, otherwise reset if not order or order.state != 'draft': @@ -782,13 +791,9 @@ class WebsiteSale(http.Controller): if order.partner_id.id == request.website.user_id.sudo().partner_id.id: return request.redirect('/shop/address') - billing_fields_required = self._get_mandatory_fields_billing(order.partner_id.country_id.id) - if not all(order.partner_id.read(billing_fields_required)[0].values()): - return request.redirect('/shop/address?partner_id=%d' % order.partner_id.id) - - shipping_fields_required = self._get_mandatory_fields_shipping(order.partner_shipping_id.country_id.id) - if not all(order.partner_shipping_id.read(shipping_fields_required)[0].values()): - return request.redirect('/shop/address?partner_id=%d' % order.partner_shipping_id.id) + redirection = self.checkout_check_address(order) + if redirection: + return redirection values = self.checkout_values(**post) @@ -806,7 +811,7 @@ class WebsiteSale(http.Controller): def confirm_order(self, **post): order = request.website.sale_get_order() - redirection = self.checkout_redirection(order) + redirection = self.checkout_redirection(order) or self.checkout_check_address(order) if redirection: return redirection @@ -901,7 +906,7 @@ class WebsiteSale(http.Controller): paying / canceling """ order = request.website.sale_get_order() - redirection = self.checkout_redirection(order) + redirection = self.checkout_redirection(order) or self.checkout_check_address(order) if redirection: return redirection |
