Skip to Content
Menu
This question has been flagged
1 Reply
2289 Views

In my company the employee receives 100 rs per hour on weekdays, but on weekend he receives a bonus per hour.

For example 10 rs extra per hour. So by computing the salary, how i add this, how i need to create the rule, how do i add the python code?




Regards

Avatar
Discard
Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
3
Jun 24
2103
0
Jun 24
1715
2
Aug 25
2322
1
Jul 25
841
1
Aug 25
1150