From 6a2320ab8920e441851c677e5240d749ab8397e7 Mon Sep 17 00:00:00 2001 From: Romain Derie <rde@odoo.com> Date: Fri, 18 Jun 2021 10:30:20 +0200 Subject: [PATCH] [FIX] website_sale: add missing method check --- addons/website_sale/controllers/main.py | 2 +- addons/website_sale/tests/test_sale_process.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 3a49dc8a7523..913fddd6027f 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -678,7 +678,7 @@ class WebsiteSale(http.Controller): return request.redirect('/shop/checkout') # IF POSTED - if 'submitted' in kw: + if 'submitted' in kw and request.httprequest.method == "POST": pre_values = self.values_preprocess(order, mode, kw) errors, error_msg = self.checkout_form_validate(mode, kw, pre_values) post, errors, error_msg = self.values_postprocess(order, mode, pre_values, errors, error_msg) diff --git a/addons/website_sale/tests/test_sale_process.py b/addons/website_sale/tests/test_sale_process.py index d0a3630bc0f5..d1e8dc5c3f21 100644 --- a/addons/website_sale/tests/test_sale_process.py +++ b/addons/website_sale/tests/test_sale_process.py @@ -74,7 +74,8 @@ class TestWebsiteSaleCheckoutAddress(odoo.tests.TransactionCase): p = self.env.user.partner_id so = self._create_so(p.id) - with MockRequest(self.env, website=self.website, sale_order_id=so.id): + with MockRequest(self.env, website=self.website, sale_order_id=so.id) as req: + req.httprequest.method = "POST" self.WebsiteSaleController.address(**self.default_address_values) self.assertFalse(self._get_last_address(p).website_id, "New shipping address should not have a website set on it (no specific_user_account).") @@ -118,7 +119,9 @@ class TestWebsiteSaleCheckoutAddress(odoo.tests.TransactionCase): env = api.Environment(self.env.cr, self.demo_user.id, {}) # change also website env for `sale_get_order` to not change order partner_id - with MockRequest(env, website=self.website.with_env(env), sale_order_id=so.id): + with MockRequest(env, website=self.website.with_env(env), sale_order_id=so.id) as req: + req.httprequest.method = "POST" + # 1. Logged in user, new shipping self.WebsiteSaleController.address(**self.default_address_values) new_shipping = self._get_last_address(self.demo_partner) @@ -137,7 +140,9 @@ class TestWebsiteSaleCheckoutAddress(odoo.tests.TransactionCase): env = api.Environment(self.env.cr, self.website.user_id.id, {}) # change also website env for `sale_get_order` to not change order partner_id - with MockRequest(env, website=self.website.with_env(env), sale_order_id=so.id): + with MockRequest(env, website=self.website.with_env(env), sale_order_id=so.id) as req: + req.httprequest.method = "POST" + # 1. Public user, new billing self.default_address_values['partner_id'] = -1 self.WebsiteSaleController.address(**self.default_address_values) -- GitLab