Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2326 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
cze 24
2129
0
cze 24
1735
2
sie 25
2394
1
lip 25
896
1
sie 25
1151