From fa2082de8bfcb4d7486c5b34f7a121fe9f10a38f Mon Sep 17 00:00:00 2001 From: "Abdelouahab (abla)" Date: Mon, 13 Jun 2022 12:57:06 +0000 Subject: [PATCH] [FIX] website_sale : create contact without sales access rights To reproduce ============ - on a database where *sale*, *contacts* and *website_sale* are installed - create a user without sales access rights but has the right to create a contact (extra rights/create contact) - connect to this user and try to create a contact An Access Error is raised. Purpose ======= Because the model *website_sale* is installed, the method `_onchange_property_product_pricelist` in `res_partner` is triggred. In this method we run `search` on `sale.order`, but the user doesn't have the right to read `sale.order` so the error is raised. Specification ============= The role of the method `_onchange_property_product_pricelist` is needed when we edit an exisitng contact, but in our case, we are creating a new one. To solve issue, the method `_onchange_property_product_pricelist` has been modified to do nothing in case of new contact. opw-2864945 closes odoo/odoo#93813 X-original-commit: 0c49d86f4fac18d151bbda95cbe29bcb1dc9481d Signed-off-by: William Braeckman (wbr) Signed-off-by: abla001 --- addons/website_sale/models/res_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_sale/models/res_partner.py b/addons/website_sale/models/res_partner.py index 9fd913f478e..96cf0efe0c1 100644 --- a/addons/website_sale/models/res_partner.py +++ b/addons/website_sale/models/res_partner.py @@ -27,7 +27,7 @@ class ResPartner(models.Model): @api.onchange('property_product_pricelist') def _onchange_property_product_pricelist(self): - open_order = self.env['sale.order'].search([ + open_order = self.env['sale.order'].sudo().search([ ('partner_id', '=', self._origin.id), ('pricelist_id', '=', self._origin.property_product_pricelist.id), ('pricelist_id', '!=', self.property_product_pricelist.id),