fix solve Python uses "round half to even" by default in payroll field total

This commit is contained in:
Bakry 2025-04-20 16:54:59 +03:00
parent 04baa81cb8
commit fd712bcbfd
1 changed files with 5 additions and 1 deletions

View File

@ -11,6 +11,8 @@ from dateutil.relativedelta import relativedelta
from odoo import api, fields, models, tools, _, exceptions
from odoo.exceptions import UserError, except_orm
# solve Python uses "round half to even" by default
from decimal import Decimal, ROUND_HALF_UP
# New object for loans lines in payslip
class PayslipLoans(models.Model):
@ -2235,7 +2237,9 @@ class HrPayslipLine(models.Model):
line.total = round(((line.amount / 30) * work_days) * line.percentage / 100,2)
################################################### End IF Then else #################################################
else:
line.total = round((line.amount) * line.percentage / 100,2)
total = Decimal(line.amount * line.percentage / 100)
rounded = total.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)
line.total = round(rounded,2)
#print("compute_shee_computee_total payslips_Run %s" % (time.time() - start_time))