[FIX] account: auto reconcile model with tax
Set an automatic reconciliation model with a tax Create a bank statement on which one line will be caught by that model Click on reconcile to get to the reconciliation widget Observe the account move lines creates Before this commit, the move line representing the tax amount (and in the account for taxes) did not have a tax_line_id, which is a reference to the tax that made the line exist This messed up tax reports After this commit, the move line of the tax has a reference to the tax it originated from The tax reports are correct OPW 2006826 closes odoo/odoo#34627 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
@@ -154,6 +154,7 @@ class AccountReconcileModel(models.Model):
|
||||
'analytic_account_id': tax.analytic and base_line_dict['analytic_account_id'],
|
||||
'analytic_tag_ids': tax.analytic and base_line_dict['analytic_tag_ids'],
|
||||
'tax_exigible': tax.tax_exigibility == 'on_payment',
|
||||
'tax_line_id': tax.id,
|
||||
})
|
||||
|
||||
# Handle price included taxes.
|
||||
|
||||
@@ -98,6 +98,12 @@ class TestReconciliationMatchingRules(AccountingTestCase):
|
||||
'sequence': 1,
|
||||
})
|
||||
|
||||
self.tax21 = self.env['account.tax'].create({
|
||||
'name': '21%',
|
||||
'type_tax_use': 'purchase',
|
||||
'amount': 21,
|
||||
})
|
||||
|
||||
def test_matching_fields(self):
|
||||
''' Test all fields used to restrict the rules's applicability.'''
|
||||
|
||||
@@ -304,6 +310,34 @@ class TestReconciliationMatchingRules(AccountingTestCase):
|
||||
{'partner_id': self.partner_2.id, 'debit': 1000.0, 'credit': 0.0},
|
||||
])
|
||||
|
||||
def test_auto_reconcile_with_tax(self):
|
||||
''' Test auto reconciliation with a tax amount included in the bank statement line'''
|
||||
|
||||
self.rule_1.write({
|
||||
'auto_reconcile': True,
|
||||
'force_tax_included': True,
|
||||
'tax_id': self.tax21.id,
|
||||
'rule_type': 'writeoff_suggestion',
|
||||
})
|
||||
|
||||
self.bank_line_2.unlink()
|
||||
self.bank_line_1.amount = -121
|
||||
|
||||
self._check_statement_matching(
|
||||
self.rule_1,
|
||||
{
|
||||
self.bank_line_1.id: {'aml_ids': [], 'model': self.rule_1, 'status': 'reconciled'},
|
||||
},
|
||||
self.bank_st
|
||||
)
|
||||
|
||||
# Check first line has been well reconciled.
|
||||
self.assertRecordValues(self.bank_line_1.journal_entry_ids, [
|
||||
{'partner_id': self.partner_1.id, 'debit': 0.0, 'credit': 121.0},
|
||||
{'partner_id': self.partner_1.id, 'debit': 21.0, 'credit': 0.0, 'tax_line_id': self.tax21.id},
|
||||
{'partner_id': self.partner_1.id, 'debit': 100.0, 'credit': 0.0, 'tax_ids': [self.tax21.id]}
|
||||
])
|
||||
|
||||
def test_reverted_move_matching(self):
|
||||
AccountMove = self.env['account.move']
|
||||
move = AccountMove.create({
|
||||
|
||||
Reference in New Issue
Block a user