From 1918b61bc01246de5f982bc5e04515da80dcf29e Mon Sep 17 00:00:00 2001 From: MerlinGuillaume Date: Tue, 12 Jul 2022 10:35:16 +0000 Subject: [PATCH] [FIX] repair: apply fiscal position account mapping When creating an invoice from a repair order, the account mapping of the fiscal position doesn't apply even though the tax one does Steps to reproduce: 1. Install Repair and Accounting 2. Go to Accounting > Configuration > Invoicing > Fiscal Positions and create a new fiscal position with: - Name: 'FP test' - Tax Mapping from 'Tax 15.00%' to a new tax 'Tax 10.00%' - Account Mapping from '400000 Product Sales' to '450000 Other Income' 3. Go to Sales > Products and create a new product 'Product A' with: - Product Type: 'Consumable' - Customer Taxes: 'Tax 15.00%' - Income Account: '400000 Product Sales' 4. Create another product 'Product B' with same values except type which is 'Service' 5. Go to Repairs and create a new repair order with: - Any Product to Repair - Any Customer (once set, edit the customer's fiscal position to 'FP test') - Invoice Method: 'Before Repair' - Parts: add a line of type 'Add' with product 'Product A' - Operations: add a line with product 'Product A' 6. Confirm the order, create an invoice and open it: the account mapping of the fiscal position didn't apply (it should be '450000 Other Income') Solution: Apply the fiscal position mapping on the income account of the product opw-2902056 closes odoo/odoo#96038 X-original-commit: 02975a8a7b1803167a5ba8365cfbf29f80f84b2e Signed-off-by: Guillaume Merlin (megu) --- addons/repair/models/repair.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py index 17e188352e1..1251045db9e 100644 --- a/addons/repair/models/repair.py +++ b/addons/repair/models/repair.py @@ -418,7 +418,7 @@ class Repair(models.Model): else: name = operation.name - account = operation.product_id.product_tmpl_id._get_product_accounts()['income'] + account = operation.product_id.product_tmpl_id.get_product_accounts(fiscal_pos=fpos)['income'] if not account: raise UserError(_('No account defined for product "%s".', operation.product_id.name)) @@ -460,7 +460,7 @@ class Repair(models.Model): if not fee.product_id: raise UserError(_('No product defined on fees.')) - account = fee.product_id.product_tmpl_id._get_product_accounts()['income'] + account = fee.product_id.product_tmpl_id.get_product_accounts(fiscal_pos=fpos)['income'] if not account: raise UserError(_('No account defined for product "%s".', fee.product_id.name))