diff --git a/account_payment_term_discount/models/account_move.py b/account_payment_term_discount/models/account_move.py index 28a12722c2d8..65b510cd1e90 100644 --- a/account_payment_term_discount/models/account_move.py +++ b/account_payment_term_discount/models/account_move.py @@ -3,6 +3,7 @@ from dateutil.relativedelta import relativedelta from odoo import api, fields, models +from odoo.tools import float_round class AccountMove(models.Model): @@ -43,7 +44,9 @@ def _compute_discount_amt(self): ) ) if discount_information[0] > 0.0: - invoice.discount_amt = abs(round(discount_information[0], 2)) + rounding = invoice.currency_id.rounding + invoice.discount_amt = abs(float_round( + discount_information[0], rounding)) # If discount taken make disc amt to 0 as disc is no more valid if invoice.discount_taken != 0: invoice.discount_amt = 0 diff --git a/account_payment_term_discount/wizard/account_payment_register.py b/account_payment_term_discount/wizard/account_payment_register.py index f46fac68785a..259be03a1df3 100644 --- a/account_payment_term_discount/wizard/account_payment_register.py +++ b/account_payment_term_discount/wizard/account_payment_register.py @@ -4,6 +4,7 @@ from odoo import _, api, fields, models from odoo.exceptions import UserError +from odoo.tools import float_round class AccountPaymentRegister(models.TransientModel): @@ -45,7 +46,9 @@ def onchange_payment_amount(self): payment_date = fields.Date.from_string(self.payment_date) discount_amt = self.invoice_id.discount_amt - payment_difference = self.payment_difference + rounding = self.invoice_id.currency_id.rounding + payment_difference = float_round( + self.payment_difference, rounding) self.payment_difference = 0.0 if payment_date <= till_discount_date: @@ -103,9 +106,11 @@ def action_create_payments(self): res = super().action_create_payments() for payment in self: if payment.payment_difference_handling == "reconcile": + rounding = payment.invoice_id.currency_id.rounding payment.invoice_id.write( { - "discount_taken": abs(payment.payment_difference), + "discount_taken": abs(float_round( + payment.payment_difference, rounding)), "discount_amt": 0, } )