i have use this code in the salary structure to solve my problem but there are still few things not working according to me.
Code piece 1:
by using this code the odoo calculate all the number of days in the column even if they are from unpaid leave which i dont want
result = 0 for line in payslip.worked_days_line_ids: result += line.number_of_days result = result*(contract.wage/30)
Code piece 2: in this code it calculate the salary on the number of days attendance but again in this it ignore all the paid leaves/sick leave days.
result = worked_days.WORK100.number_of_days * (contract.wage / 30)
i want to calculate the salary on the bases of attendance,sick leave,other paid leaves and unpaid leaves.
To calculate the salary based on attendance, sick leave, other paid leaves, and unpaid leaves, you can use:
Code piece 1:
result = 0
for line in payslip.worked_days_line_ids:
if line.code == 'WORK100':
result += line.number_of_days
elif line.code == 'LEAVE_UNPAID':
result -= line.number_of_days
result = result * (contract.wage / 30)
Code piece 2:
result = 0
for line in payslip.worked_days_line_ids:
if line.code == 'WORK100' or line.code == 'LEAVE_PAID' or line.code == 'LEAVE_SICK':
result += line.number_of_days
result = result * (contract.wage / 30)