[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 <jco@odoo.com>
Signed-off-by: Anh Thao Pham (pta) <pta@odoo.com>
This commit is contained in:
Anh Thao Pham (pta)
2024-03-21 23:03:05 +00:00
parent d8024733a7
commit bbcc049344
+2 -2
View File
@@ -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",