Skip to Content
Menu
This question has been flagged
2 Replies
2969 Views

I am trying to calculate payslips using a work entry (extra hour work entry with the code HED100) 


First, I want odoo to detect how many extra hours (HED100) an employee worked for this particular payslip, then multiply that number of extra hours times whatever rate I want to apply. 


First I used the conditions as “always true” but when the employee has zero extra hours it wouldn’t let me calculate the payslip b/c HED100 = 0.


Then, I tried to used this formula but its telling me I have an error in my formula




Condition: Python expression: result = inputs.HED100.amount > 0 


then,


Calculation: Python expression: result = (contract.hourly_wage) * (worked_days.HED100.number_of_hours) * (1.25)




I will attach the URL  of a picture of the salary rule 


Any idea? I need some help 

 

Avatar
Discard
Best Answer

I'm not sure what the name of the custom model is that you're calling, but you have to make sure the fields you are calling in your function are all derived from your model. I.e. the variable calls should be something like model.field.field.

Avatar
Discard
Author

Just like regular attendance has a code (WORK100) I created another work entry for extra hours (HED100)

I am trying to create a salary rule that checks if the number of credit hours is greater than 0 (HED100 > 0)

If that condition is met, then compute the calculation I defined in the the calculation part

This is how I defined that salary rule:

Condition: python expression

Result = inputs.HED100.amount > 0

IF this condition is true then compute the following calculation

Result = Python formula:

result = (contract.hourly_wage) * (worked_days.HED100.number_of_hours) * (1.25)

When I set the condition to be “always true” this salary rule works fine until I have zero extra hours in the payslip. Therefore, the problem must be in my condition

Unfortunately, I don’t know how to work with these python variables.

Maybe the right variable is field rather than inputs, how you you define the condition for this example?

again, by clicking the URL below you can see a screenshot of the Salary rule for a better appreciation

Thank you for your time!

Author Best Answer

 Here is the URL https://imgur.com/ceGyQGd

Avatar
Discard