From aed0bab7ff97599ce33b2b98fdb088c0ad9eb4c5 Mon Sep 17 00:00:00 2001 From: "Mattis Megevand (mmeg)" Date: Tue, 2 Jan 2024 13:01:59 +0000 Subject: [PATCH] [FIX] purchase: always display inactive taxes on purchase order Steps to reproduce: - Create a PO with a tax - Confirm PO and bill it - Deactivate tax Issue: Tax is shown on bill but not on PO Solution: Make sure that we display tax even if inactive. opw-3631087 closes odoo/odoo#148778 X-original-commit: 4e424750eccff168c3cbb1a3f8411b35905717f3 Signed-off-by: Adrien Widart (awt) Signed-off-by: Mattis Megevand (mmeg) --- addons/purchase/models/purchase_order_line.py | 2 +- .../tests/test_purchase_tax_totals.py | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/addons/purchase/models/purchase_order_line.py b/addons/purchase/models/purchase_order_line.py index 19fccdfbd6f..0bbaffe63d5 100644 --- a/addons/purchase/models/purchase_order_line.py +++ b/addons/purchase/models/purchase_order_line.py @@ -30,7 +30,7 @@ class PurchaseOrderLine(models.Model): compute='_compute_price_unit_and_date_planned_and_name', digits='Discount', store=True, readonly=False) - taxes_id = fields.Many2many('account.tax', string='Taxes', domain=['|', ('active', '=', False), ('active', '=', True)]) + taxes_id = fields.Many2many('account.tax', string='Taxes', domain=['|', ('active', '=', False), ('active', '=', True)], context={'active_test': False}) product_uom = fields.Many2one('uom.uom', string='Unit of Measure', domain="[('category_id', '=', product_uom_category_id)]") product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id') product_id = fields.Many2one('product.product', string='Product', domain=[('purchase_ok', '=', True)], change_default=True, index='btree_not_null') diff --git a/addons/purchase/tests/test_purchase_tax_totals.py b/addons/purchase/tests/test_purchase_tax_totals.py index 2b0529cc5a6..95afd6a5182 100644 --- a/addons/purchase/tests/test_purchase_tax_totals.py +++ b/addons/purchase/tests/test_purchase_tax_totals.py @@ -60,3 +60,26 @@ class PurchaseTestTaxTotals(TestTaxTotals): }) tax_purchase.invalidate_model(fnames=['is_used']) self.assertTrue(tax_purchase.is_used) + + def test_archived_tax_totals(self): + tax_10 = self.env['account.tax'].create({ + 'name': "tax_10", + 'amount_type': 'percent', + 'amount': 10.0, + 'tax_group_id': self.tax_group1.id, + }) + + po = self._create_document_for_tax_totals_test([ + (100.0, tax_10), + ]) + po.button_confirm() + po.order_line.qty_received = 1 + po.action_create_invoice() + + invoice = po.invoice_ids + invoice.invoice_date = '2020-01-01' + invoice.action_post() + + old_ammount = po.amount_total + tax_10.active = False + self.assertEqual(po.amount_total, old_ammount)