[FIX] account: remove no longer applicable tax lines
Porting the tests from commit b501105d9d0b08395b993bcae1957ee5a1a1fb23 (the behavior was already correct on version 14.0) Note: - also added unit test for the use case of 226a1155124e890d00e33968feb43b9fd6b99fa5 opw-2371745 closes odoo/odoo#62688 X-original-commit: 902d2d9a91f9a1167fd1f51ad71c021cc1e6bfc1 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> Signed-off-by: Nicolas Galler <ngaller@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import fields
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
from odoo.tests import tagged, Form
|
||||
|
||||
@@ -540,3 +541,54 @@ class TestInvoiceTaxes(AccountTestInvoicingCommon):
|
||||
(50, self.percent_tax_3_incl),
|
||||
], currency_id=self.currency_data['currency'], invoice_payment_term_id=self.pay_terms_a)
|
||||
invoice.action_post()
|
||||
|
||||
def test_changing_tax_to_caba_after_create_invoice(self):
|
||||
tax_waiting_account = self.env['account.account'].create({
|
||||
'name': 'TAX_WAIT',
|
||||
'code': 'TWAIT',
|
||||
'user_type_id': self.env.ref('account.data_account_type_current_liabilities').id,
|
||||
'reconcile': True,
|
||||
'company_id': self.company_data['company'].id,
|
||||
})
|
||||
sale_tax = self.company_data['default_tax_sale']
|
||||
invoice = self._create_invoice([
|
||||
(100, sale_tax),
|
||||
])
|
||||
# turn on cash basis on the same tax that was used
|
||||
self.company_data['company'].tax_exigibility = True
|
||||
sale_tax.write({
|
||||
'tax_exigibility': 'on_payment',
|
||||
'cash_basis_transition_account_id': tax_waiting_account.id,
|
||||
})
|
||||
invoice.action_post()
|
||||
|
||||
tax_lines = invoice.line_ids.filtered('tax_line_id')
|
||||
self.assertEqual(len(tax_lines), 1, 'Should have only 1 tax line')
|
||||
self.assertNotEqual(tax_lines.price_unit, 0.0)
|
||||
self.assertEqual(tax_lines.tax_base_amount, 100.0)
|
||||
self.assertEqual(tax_lines.account_id.name, 'TAX_WAIT')
|
||||
|
||||
def test_recompute_tax_when_change_currency(self):
|
||||
"""
|
||||
- In a multi currency company, create an invoice with the domestic
|
||||
currency ($);
|
||||
- Add a product (100$) with taxes;
|
||||
- Change the currency to a foreign one (€);
|
||||
- The product don't change of amount but only of currency (500€);
|
||||
- Save the invoice, and print it.
|
||||
"""
|
||||
invoice = self._create_invoice([
|
||||
(100, self.percent_tax_1),
|
||||
])
|
||||
tax_line = invoice.line_ids.filtered('tax_line_id')
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': fields.Date.to_string(fields.Date.today()),
|
||||
'rate': 4.0,
|
||||
'currency_id': self.currency_data['currency'].id,
|
||||
'company_id': self.env.company.id,
|
||||
})
|
||||
with Form(invoice) as invoice_form:
|
||||
invoice_form.currency_id = self.currency_data['currency']
|
||||
|
||||
self.assertEqual(tax_line.tax_base_amount, 25, 'Should convert tax base amount to company currency')
|
||||
self.assertEqual(tax_line.balance, -5.25, 'Should convert balance to company currency')
|
||||
|
||||
Reference in New Issue
Block a user