From b0138fb6df8bce004c2b56e9bdc923991a15ee92 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 23 Mar 2021 12:45:17 +0000 Subject: [PATCH] [FIX] wabsite_sale: Recursive Partner hierarchies on website_sale Steps to reproduce the bug: - Let's create two partners P1 and P2 where P1 is a company and P2 a child of P1 - P2 is a portal user - Log with P2 and go to the shop - Add a product in the cart and process to checkout - The billing address the details of P2 are auto completed, click on next - For the shipping address, the details of P1 are auto completed, click on next Bug: A 403 page was displayed with: You cannot create recursive Partner hierarchies. opw:2487590 closes odoo/odoo#68814 X-original-commit: a6077a8cf8cd03b93dcd865c9fe2939bb3b7132b Signed-off-by: Simon Goffin (sig) Co-authored-by: rdeodoo --- addons/website_sale/controllers/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 3af89c9edab..319fb76e35b 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -699,11 +699,14 @@ class WebsiteSale(http.Controller): can_edit_vat = order.partner_id.can_edit_vat() else: shippings = Partner.search([('id', 'child_of', order.partner_id.commercial_partner_id.ids)]) - if partner_id in shippings.mapped('id'): + if order.partner_id.commercial_partner_id.id == partner_id: + mode = ('new', 'shipping') + partner_id = -1 + elif partner_id in shippings.mapped('id'): mode = ('edit', 'shipping') else: return Forbidden() - if mode: + if mode and partner_id != -1: values = Partner.browse(partner_id) elif partner_id == -1: mode = ('new', 'shipping')