İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
2346 Görünümler

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
Vazgeç
En İyi Yanıt

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Haz 24
2134
0
Haz 24
1747
2
Ağu 25
2403
1
Tem 25
908
1
Ağu 25
1151