[FIX] website_sale: add missing method check

This commit is contained in:
Romain Derie
2021-12-21 17:14:00 +01:00
parent cfb9967d37
commit c88f76cab7
2 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -823,7 +823,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)
@@ -141,7 +141,8 @@ class TestWebsiteSaleCheckoutAddress(TransactionCaseWithUserDemo):
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).")
@@ -185,7 +186,9 @@ class TestWebsiteSaleCheckoutAddress(TransactionCaseWithUserDemo):
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)
@@ -204,7 +207,9 @@ class TestWebsiteSaleCheckoutAddress(TransactionCaseWithUserDemo):
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)