[FIX] account: clear epd discount tax
Set "Cash Discount Tax Reduction" to "Always" Have Tax A and Tax B Create an invoice with a payment term having a discount (example: 2/7 Net 30) Add the following lines 1) Any prod, Tax A 2) Any prod, Tax B In journal items tab we will see 2 line for the product, 2 for tax, 3 for epd, 2 for epd tax discount, 1 for payment Delete line 2) Check journal items Issue: epd discount for tax B is still there This occurs because: - When calculating the epd vals we don't actually issue a clear command - Due to a `_sync_dynamic_line` optimization we may write on a line scheduled for delete instead of creating a new one As result an old tax may be left in the overwritten line opw-3285534 closes odoo/odoo#123697 X-original-commit: bc83baf7d6be3a9ab25da90ddf1882c1cb95217e Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com> Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -1005,7 +1005,7 @@ class AccountMoveLine(models.Model):
|
||||
'amount_currency': 0.0,
|
||||
'balance': 0.0,
|
||||
'price_subtotal': 0.0,
|
||||
'tax_ids': [],
|
||||
'tax_ids': [Command.clear()],
|
||||
},
|
||||
)
|
||||
epd_needed_vals['amount_currency'] += line.amount_currency * percentage
|
||||
|
||||
@@ -581,3 +581,30 @@ class TestAccountEarlyPaymentDiscount(AccountTestInvoicingCommon):
|
||||
self.assertEqual(len(inv.line_ids), 3) # 1 prod, 1 tax, 1 payment terms
|
||||
inv.write({'invoice_payment_term_id': self.early_pay_10_percents_10_days.id})
|
||||
self.assertEqual(len(inv.line_ids), 6)
|
||||
|
||||
def test_mixed_epd_with_tax_deleted_line(self):
|
||||
self.early_pay_10_percents_10_days.write({'early_pay_discount_computation': 'mixed'})
|
||||
tax_a = self.env['account.tax'].create({
|
||||
'name': 'Test A',
|
||||
'amount': 10,
|
||||
})
|
||||
tax_b = self.env['account.tax'].create({
|
||||
'name': 'Test B',
|
||||
'amount': 15,
|
||||
})
|
||||
|
||||
inv = self.env['account.move'].create({
|
||||
'move_type': 'out_invoice',
|
||||
'partner_id': self.partner_a.id,
|
||||
'invoice_date': '2019-01-01',
|
||||
'date': '2019-01-01',
|
||||
'invoice_line_ids': [
|
||||
Command.create({'name': 'line', 'price_unit': 100.0, 'tax_ids': [Command.set(tax_a.ids)]}),
|
||||
Command.create({'name': 'line2', 'price_unit': 100.0, 'tax_ids': [Command.set(tax_b.ids)]}),
|
||||
],
|
||||
'invoice_payment_term_id': self.early_pay_10_percents_10_days.id,
|
||||
})
|
||||
self.assertEqual(len(inv.line_ids), 10) # 2 prod, 2 tax, 3 epd, 2 epd tax discount, 1 payment terms
|
||||
inv.invoice_line_ids[1].unlink()
|
||||
self.assertEqual(len(inv.line_ids), 6) # 1 prod, 1 tax, 2 epd, 1 epd tax discount, 1 payment terms
|
||||
self.assertEqual(inv.amount_tax, 9.00) # $100.0 @ 10% tax (-10% epd)
|
||||
|
||||
Reference in New Issue
Block a user