Hi,
To implement this salary structure in Odoo, where employees receive different rates for weekdays and weekends, you will need to create a salary rule that computes the hourly wage based on the day of the week.
Here is a step-by-step guide to help you create the rule:
1. Create a Salary Rule
First, you need to create a salary rule that defines how to compute the hourly wage and the bonus for weekends.
Go to Payroll > Configuration > Salary Rules.
Click Create to create a new salary rule.
Define the rule with the following key details:
Name: Weekend Bonus Rule (or something appropriate)
Category: Basic (you can choose the appropriate category)
Condition: Make sure the condition is based on the employee’s working hours.
Computation: Based on Python code.
2. Python Code for Salary Rule
In the Python Code section, you can add the logic to determine whether the working hours are on weekdays or weekends. Here's an example of how you might write this:
weekday_rate = 100
weekend_bonus = 10
worked_hours = worked_days.WORK100.number_of_hours
total_salary = 0
for day in worked_days:
if day.attendance_id.date.weekday() in [5, 6]:
total_salary += day.number_of_hours * (weekday_rate + weekend_bonus)
else:
total_salary += day.number_of_hours * weekday_rate
result = total_salary
Regards