From bbcc04934447f0a436735a3277656d8f9e12893e Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Wed, 13 Mar 2024 10:57:27 +0000 Subject: [PATCH] [FIX] account: fix default taxes on product from branch Steps to reproduce: - Install Invoicing (and Sales for product creation rights) - From a company, create a Branch company - Switch to parent company - In Invoicing settings of parent company, set default taxes - Switch to branch company - In Invoicing settings of branch company, set no default taxes - Create a user with only the branch company as allowed companies - Give the user the right to create a product (e.g. Sales: Administrator) - Connect with the created user - Try to create a product Issue: An Access Error is raised due to "company rule employee" rule because the system tries to fetch the default taxes from the parent company, which is not activated in the company selector. opw-3790360 closes odoo/odoo#158567 X-original-commit: 7a9088e2c76ac0309245bee8cf10863cd3ede19d Signed-off-by: Josse Colpaert Signed-off-by: Anh Thao Pham (pta) --- addons/account/models/product.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/product.py b/addons/account/models/product.py index 92a735bc18f..296ab735348 100644 --- a/addons/account/models/product.py +++ b/addons/account/models/product.py @@ -27,12 +27,12 @@ class ProductTemplate(models.Model): taxes_id = fields.Many2many('account.tax', 'product_taxes_rel', 'prod_id', 'tax_id', help="Default taxes used when selling the product.", string='Customer Taxes', domain=[('type_tax_use', '=', 'sale')], - default=lambda self: self.env.companies.account_sale_tax_id or self.env.companies.root_id.account_sale_tax_id, + default=lambda self: self.env.companies.account_sale_tax_id or self.env.companies.root_id.sudo().account_sale_tax_id, ) tax_string = fields.Char(compute='_compute_tax_string') supplier_taxes_id = fields.Many2many('account.tax', 'product_supplier_taxes_rel', 'prod_id', 'tax_id', string='Vendor Taxes', help='Default taxes used when buying the product.', domain=[('type_tax_use', '=', 'purchase')], - default=lambda self: self.env.companies.account_purchase_tax_id or self.env.companies.root_id.account_purchase_tax_id, + default=lambda self: self.env.companies.account_purchase_tax_id or self.env.companies.root_id.sudo().account_purchase_tax_id, ) property_account_income_id = fields.Many2one('account.account', company_dependent=True, string="Income Account",