[REV] account: 0% tax not in tax report due

This reverts commit 65b5ec4ad65f798b1d647978b5b42a49e760139a.

closes odoo/odoo#93717

X-original-commit: 09eb1b725e2f8b86dc671d0f77503e49d106d14c
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
Signed-off-by: Laurent Smet <las@odoo.com>
This commit is contained in:
Laurent Smet
2022-06-20 11:14:55 +02:00
parent fa753bd0f5
commit e2178ba796
6 changed files with 20 additions and 99 deletions
+13 -9
View File
@@ -715,6 +715,9 @@ class AccountMove(models.Model):
currency = self.env['res.currency'].browse(update_vals['currency_id'])
tax_amount = update_vals.pop('tax_amount')
if currency.is_zero(tax_amount):
return True
tax_rep = self.env['account.tax.repartition.line'].browse(update_vals['tax_repartition_line_id'])
tax_id = update_vals.pop('tax_id')
if tax_id == tax_rep.tax_id.id:
@@ -780,7 +783,7 @@ class AccountMove(models.Model):
# ===== TAX LINES =====
# Tax lines that are no longer neeeded.
# Tax lines that are no longer needed.
if not recompute_tax_base_amount:
for tax_line_vals in tax_results['tax_lines_to_delete']:
tax_line = tax_line_vals['record']
@@ -789,19 +792,20 @@ class AccountMove(models.Model):
# Newly created tax lines.
if not recompute_tax_base_amount:
for tax_line_vals in tax_results['tax_lines_to_add']:
fill_accounting_tax_vals(tax_line_vals)
line_ids_commands.append(Command.create(tax_line_vals))
if not fill_accounting_tax_vals(tax_line_vals):
line_ids_commands.append(Command.create(tax_line_vals))
# Update of existing tax lines.
for tax_line_vals, to_update in tax_results['tax_lines_to_update']:
tax_line = tax_line_vals['record']
fill_accounting_tax_vals(to_update)
if recompute_tax_base_amount:
fields_to_update = ('tax_base_amount',)
if fill_accounting_tax_vals(to_update):
line_ids_commands.append(Command.unlink(tax_line.id))
else:
fields_to_update = ('tax_base_amount', 'amount_currency', 'debit', 'credit')
line_ids_commands.append(Command.update(tax_line.id, {k: v for k, v in to_update.items() if k in fields_to_update}))
if recompute_tax_base_amount:
fields_to_update = ('tax_base_amount',)
else:
fields_to_update = ('tax_base_amount', 'amount_currency', 'debit', 'credit')
line_ids_commands.append(Command.update(tax_line.id, {k: v for k, v in to_update.items() if k in fields_to_update}))
(self.update if in_draft_mode else self.write)({'line_ids': line_ids_commands})
@@ -1168,91 +1168,6 @@ class TestAccountTaxDetailsReport(AccountTestInvoicingCommon):
)
self.assertTotalAmounts(invoice, tax_details)
def test_zero_amount_tax(self):
""" Ensure the tax details is generated for 0% tax. """
zero_tax = self.env['account.tax'].create({
'name': "zero_tax",
'amount_type': 'percent',
'amount': 0.0,
})
invoice = self.env['account.move'].create({
'move_type': 'out_invoice',
'partner_id': self.partner_a.id,
'invoice_date': '2019-01-01',
'invoice_line_ids': [
Command.create({
'name': 'line1',
'account_id': self.company_data['default_account_revenue'].id,
'price_unit': 1000.0,
'tax_ids': [Command.set(zero_tax.ids)],
}),
Command.create({
'name': 'line2',
'account_id': self.company_data['default_account_revenue'].id,
'price_unit': 1000.0,
'tax_ids': [Command.set(zero_tax.ids)],
}),
]
})
base_lines, tax_lines = self._dispatch_move_lines(invoice)
tax_details = self._get_tax_details()
self.assertTaxDetailsValues(
tax_details,
[
{
'base_line_id': base_lines[0].id,
'tax_line_id': tax_lines[0].id,
'base_amount': -1000.0,
'tax_amount': 0.0,
},
{
'base_line_id': base_lines[1].id,
'tax_line_id': tax_lines[0].id,
'base_amount': -1000.0,
'tax_amount': 0.0,
},
],
)
self.assertTotalAmounts(invoice, tax_details)
# Same with a group of taxes
tax_group = self.env['account.tax'].create({
'name': "tax_group",
'amount_type': 'group',
'children_tax_ids': [Command.set(zero_tax.ids)],
})
invoice.write({
'invoice_line_ids': [
Command.update(base_lines[0].id, {'tax_ids': [Command.set(tax_group.ids)]}),
Command.update(base_lines[1].id, {'tax_ids': [Command.set(tax_group.ids)]}),
],
})
base_lines, tax_lines = self._dispatch_move_lines(invoice)
tax_details = self._get_tax_details()
self.assertTaxDetailsValues(
tax_details,
[
{
'base_line_id': base_lines[0].id,
'tax_line_id': tax_lines[0].id,
'base_amount': -1000.0,
'tax_amount': 0.0,
},
{
'base_line_id': base_lines[1].id,
'tax_line_id': tax_lines[0].id,
'base_amount': -1000.0,
'tax_amount': 0.0,
},
],
)
self.assertTotalAmounts(invoice, tax_details)
def test_amounts_sign(self):
for tax_sign in (1, -1):
tax = self.env['account.tax'].create({
@@ -3063,7 +3063,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
})
self.assertEqual(len(invoice.invoice_line_ids), 1)
self.assertEqual(len(invoice.line_ids), 3)
self.assertEqual(len(invoice.line_ids), 2)
def test_out_invoice_recomputation_receivable_lines(self):
''' Test a tricky specific case caused by some framework limitations. Indeed, when
@@ -290,7 +290,9 @@ class AccountEdiFormat(models.Model):
This method is call for rounding.
If anything is wrong with rounding then we quick fix in method
"""
return round(amount, precision_digits)
value = round(amount, precision_digits)
# avoid -0.0
return value if value else 0.0
def _get_l10n_in_edi_line_details(self, index, line, line_tax_details, sign):
"""
+2 -2
View File
@@ -110,7 +110,7 @@ class TestEdiJson(AccountTestInvoicingCommon):
"ItemList": [{
"SlNo": "1", "PrdDesc": "product_a", "IsServc": "N", "HsnCd": "01111", "Qty": 1.0,
"Unit": "UNT", "UnitPrice": 1000.0, "TotAmt": 1000.0, "Discount": 1000.0, "AssAmt": 0.0,
"GstRt": 5.0, "IgstAmt": 0.0, "CgstAmt": 0.0, "SgstAmt": 0.0, "CesRt": 0.0, "CesAmt": 0.0,
"GstRt": 0.0, "IgstAmt": 0.0, "CgstAmt": 0.0, "SgstAmt": 0.0, "CesRt": 0.0, "CesAmt": 0.0,
"CesNonAdvlAmt": 0.0, "StateCesRt": 0.0, "StateCesAmt": 0.0, "StateCesNonAdvlAmt": 0.0,
"OthChrg": 0.0, "TotItemVal": 0.0}],
"ValDtls": {"AssVal": 0.0, "CgstVal": 0.0, "SgstVal": 0.0, "IgstVal": 0.0, "CesVal": 0.0,
@@ -125,7 +125,7 @@ class TestEdiJson(AccountTestInvoicingCommon):
"ItemList": [{
"SlNo": "1", "PrdDesc": "product_a", "IsServc": "N", "HsnCd": "01111", "Qty": 0.0,
"Unit": "UNT", "UnitPrice": 1000.0, "TotAmt": 0.0, "Discount": 0.0, "AssAmt": 0.0,
"GstRt": 5.0, "IgstAmt": 0.0, "CgstAmt": 0.0, "SgstAmt": 0.0, "CesRt": 0.0, "CesAmt": 0.0,
"GstRt": 0.0, "IgstAmt": 0.0, "CgstAmt": 0.0, "SgstAmt": 0.0, "CesRt": 0.0, "CesAmt": 0.0,
"CesNonAdvlAmt": 0.0, "StateCesRt": 0.0, "StateCesAmt": 0.0, "StateCesNonAdvlAmt": 0.0,
"OthChrg": 0.0, "TotItemVal": 0.0}],
})
@@ -80,7 +80,7 @@ class ValuationReconciliationTestCommon(AccountTestInvoicingCommon):
def check_reconciliation(self, invoice, picking, full_reconcile=True, operation='purchase'):
interim_account_id = self.company_data['default_account_stock_in'].id if operation == 'purchase' else self.company_data['default_account_stock_out'].id
invoice_line = invoice.line_ids.filtered(lambda line: line.account_id.id == interim_account_id and not line.tax_line_id)
invoice_line = invoice.line_ids.filtered(lambda line: line.account_id.id == interim_account_id)
stock_moves = picking.move_ids