Odoo Help

Welcome!

This community 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.

0

Nested conditions in Salary Rule

By
Emad Jaddou
on 7/29/15, 4:33 PM 567 views

Hi,

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
0
Emad Jaddou
On 7/30/15, 8:00 AM

The error is: 

Wrong Python code defined on salary Rule Basic

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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