From 3bac0f9d68d329ddeed8ddb95e6957cbf6a14403 Mon Sep 17 00:00:00 2001 From: "Nicolas (vin)" Date: Mon, 4 Jul 2022 09:21:20 +0000 Subject: [PATCH] [FIX] account: Do not add tax grids for CABA taxes upon reversal When using CABA and reversing a move, we expect the CABA move to be the one impacting the tax grids, and not the reversed move. Thus, we now avoid setting the tax grids for CABA taxes on move lines created when making a reverse move. Task id # 2895267 closes odoo/odoo#98789 X-original-commit: 5dd50ac1433be262ddd49d8b165e240afd16e675 Signed-off-by: Laurent Smet --- .../tests/test_account_move_reconcile.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/addons/account/tests/test_account_move_reconcile.py b/addons/account/tests/test_account_move_reconcile.py index 2b89316b9de..314970d65cf 100644 --- a/addons/account/tests/test_account_move_reconcile.py +++ b/addons/account/tests/test_account_move_reconcile.py @@ -3370,6 +3370,56 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon): {'debit': 0.0, 'credit': 33.33, 'tax_tag_ids': [], 'account_id': self.cash_basis_transfer_account.id}, ]) + def test_reconcile_cash_basis_tax_grid_reversal(self): + invoice = self.env['account.move'].create({ + 'move_type': 'out_invoice', + 'partner_id': self.partner_a.id, + 'date': '2016-01-01', + 'invoice_line_ids': [(0, 0, { + 'product_id': self.product_a.id, + 'price_unit': 1000.0, + 'tax_ids': [(6, 0, self.cash_basis_tax_a_third_amount.ids)], + })], + }) + invoice.action_post() + + self.assertRecordValues(invoice.line_ids.sorted('balance'), [ + {'debit': 0.0, 'credit': 1000.0, 'tax_tag_ids': [], 'account_id': self.company_data['default_account_revenue'].id}, + {'debit': 0.0, 'credit': 333.33, 'tax_tag_ids': [], 'account_id': self.cash_basis_transfer_account.id}, + {'debit': 1333.33, 'credit': 0.0, 'tax_tag_ids': [], 'account_id': self.company_data['default_account_receivable'].id}, + ]) + + reversal_wizard = self.env['account.move.reversal']\ + .with_context(active_model='account.move', active_ids=invoice.ids)\ + .create({ + 'reason': "test_reconcile_cash_basis_tax_grid_reversal", + 'refund_method': 'refund', + 'journal_id': invoice.journal_id.id, + }) + refund = self.env['account.move'].browse(reversal_wizard.reverse_moves()['res_id']) + refund.action_post() + + self.assertRecordValues(refund.line_ids.sorted('balance'), [ + {'debit': 0.0, 'credit': 1333.33, 'tax_tag_ids': [], 'account_id': self.company_data['default_account_receivable'].id}, + {'debit': 333.33, 'credit': 0.0, 'tax_tag_ids': [], 'account_id': self.cash_basis_transfer_account.id}, + {'debit': 1000.0, 'credit': 0.0, 'tax_tag_ids': [], 'account_id': self.company_data['default_account_revenue'].id}, + ]) + + reversal_wizard = self.env['account.move.reversal']\ + .with_context(active_model='account.move', active_ids=refund.ids)\ + .create({ + 'reason': "test_reconcile_cash_basis_tax_grid_reversal", + 'refund_method': 'refund', + 'journal_id': refund.journal_id.id, + }) + reversed_refund = self.env['account.move'].browse(reversal_wizard.reverse_moves()['res_id']) + + self.assertRecordValues(reversed_refund.line_ids.sorted('balance'), [ + {'debit': 0.0, 'credit': 1000.0, 'tax_tag_ids': [], 'account_id': self.company_data['default_account_revenue'].id}, + {'debit': 0.0, 'credit': 333.33, 'tax_tag_ids': [], 'account_id': self.cash_basis_transfer_account.id}, + {'debit': 1333.33, 'credit': 0.0, 'tax_tag_ids': [], 'account_id': self.company_data['default_account_receivable'].id}, + ]) + def test_reconcile_cash_basis_tax_grid_multi_taxes(self): ''' Test the tax grid when reconciling an invoice with multiple taxes/tax repartition. ''' base_taxes = self.cash_basis_tax_a_third_amount + self.cash_basis_tax_tiny_amount