[FIX] account: include 'quantity' in '_compute_all_tax' dependencies
Summary ------- This commit addresses an issue where fixed taxes were not calculated correctly when applied to a line with a price of 0. Steps to reproduce ------------------ 1. Create a fixed tax with an amount of 5. 2. Create an invoice with a line having zero price and apply the fixed tax. 3. Save the invoice. You should have a total of 5. 4. Change the quantity of the invoice line, to something like 2. 5. Save the invoice. We expect the total to be 10, but we get 5. opw-3212536 closes odoo/odoo#134762 X-original-commit: 2aafff6a36bd40719de9447a7ab9bf05274ff5d2 Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: Séna Serge Nshimiyimana (sesn) <sesn@odoo.com>
This commit is contained in:
@@ -909,7 +909,7 @@ class AccountMoveLine(models.Model):
|
||||
else:
|
||||
line.tax_key = frozendict({'id': line.id})
|
||||
|
||||
@api.depends('tax_ids', 'currency_id', 'partner_id', 'analytic_distribution', 'balance', 'partner_id', 'move_id.partner_id', 'price_unit')
|
||||
@api.depends('tax_ids', 'currency_id', 'partner_id', 'analytic_distribution', 'balance', 'partner_id', 'move_id.partner_id', 'price_unit', 'quantity')
|
||||
def _compute_all_tax(self):
|
||||
for line in self:
|
||||
sign = line.move_id.direction_sign
|
||||
|
||||
@@ -715,3 +715,22 @@ class TestInvoiceTaxes(AccountTestInvoicingCommon):
|
||||
self.assertRecordValues(invoice.line_ids.filtered(lambda l: l.account_id.account_type == 'asset_receivable'), [{
|
||||
'balance': 686.54,
|
||||
}])
|
||||
|
||||
def test_fixed_tax_with_zero_price(self):
|
||||
fixed_tax = self.env['account.tax'].create({
|
||||
'name': 'Test 5 fixed',
|
||||
'amount_type': 'fixed',
|
||||
'amount': 5,
|
||||
})
|
||||
invoice = self._create_invoice([
|
||||
(0, fixed_tax),
|
||||
])
|
||||
self.assertRecordValues(invoice.line_ids.filtered('tax_line_id'), [{
|
||||
'credit': 5.0,
|
||||
'debit': 0,
|
||||
}])
|
||||
invoice.invoice_line_ids.quantity = 2
|
||||
self.assertRecordValues(invoice.line_ids.filtered('tax_line_id'), [{
|
||||
'credit': 10.0,
|
||||
'debit': 0,
|
||||
}])
|
||||
|
||||
Reference in New Issue
Block a user