Odoo Help


Nested conditions in Salary Rule

Emad Jaddo
on 7/29/15, 4:33 PM 1,130 views


We have 4 type of Leaves (Annual, Sick, Lieu & Unpaid) and all of those are paid except the Unpaid leave. the issue is that Odoo normal behaviour is to deduct all leave from the number of working days which should not be the case so I am trying to create a salary rule to solve this;

result = ((contract.wage/26)*0.6)*(worked_days.WORK100.number_of_days+worked_days.Annual2015.number_of_days+worked_days.Lieu.number_of_days)

This works only if the employee has both the Annual2015 and the Lieu but wrong python code will come if none or either of the leave does not exist for that employee. So I am trying to build a salary rule deal with this as following however everything I try return Python error:

if (worked_days.Annual2015.number_of_days and inputs.worked_days.Lieu.number_of_days): 
result = (((contract.wage/26)*0.6)*worked_days.WORK100.number_of_days) elif (worked_days.Annual2015.number_of_days is None and worked_days.Lieu.number_of_days > 0): result = ((contract.wage/26)*0.6)*(worked_days.WORK100.number_of_days+worked_days.Lieu.number_of_days) elif (worked_days.Annual2015.number_of_days > 0 and worked_days.Lieu.number_of_days is None): result = ((contract.wage/26)*0.6)*(worked_days.WORK100.number_of_days+worked_days.Annual2015.number_of_days)

I appreciate your help on this.

can you post the error msg ?

Ahmed M.Elmubarak
on 7/30/15, 7:48 AM
Emad Jaddo
On 7/30/15, 8:00 AM

The error is: 

Wrong Python code defined on salary Rule Basic

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/29/15, 4:33 PM
Seen: 1130 times
Last updated: 7/30/15, 8:00 AM