From 7b082b2e27940c515764c619589db028796bb33f Mon Sep 17 00:00:00 2001 From: gawa-odoo Date: Tue, 14 Mar 2023 09:49:44 +0000 Subject: [PATCH] [FIX] account: prevent wrong type tax on move - Create an account of type current asset - Add him a Sales Tax and a Purchase Tax - Create invoice - Add a line - Remove the taxes from this line - Change the account to the one you created => A purchase tax is applied to the line. It should not happen, so we prevent it. closes odoo/odoo#117539 X-original-commit: 85d89a986b6adcf9d0ac0ce57599d4b2678b59a3 Signed-off-by: Quentin De Paoli Signed-off-by: Wala Gauthier (gawa) --- addons/account/models/account_move_line.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index 8321d0e21f5..b108b0536d3 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -849,20 +849,16 @@ class AccountMoveLine(models.Model): # Out invoice. if self.product_id.taxes_id: tax_ids = self.product_id.taxes_id.filtered(lambda tax: tax.company_id == self.move_id.company_id) - elif self.account_id.tax_ids: - tax_ids = self.account_id.tax_ids else: - tax_ids = self.env['account.tax'] + tax_ids = self.account_id.tax_ids.filtered(lambda tax: tax.type_tax_use == 'sale') if not tax_ids and self.display_type == 'product': tax_ids = self.move_id.company_id.account_sale_tax_id elif self.move_id.is_purchase_document(include_receipts=True): # In invoice. if self.product_id.supplier_taxes_id: tax_ids = self.product_id.supplier_taxes_id.filtered(lambda tax: tax.company_id == self.move_id.company_id) - elif self.account_id.tax_ids: - tax_ids = self.account_id.tax_ids else: - tax_ids = self.env['account.tax'] + tax_ids = self.account_id.tax_ids.filtered(lambda tax: tax.type_tax_use == 'purchase') if not tax_ids and self.display_type == 'product': tax_ids = self.move_id.company_id.account_purchase_tax_id else: