Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
5065 Представления

Hello there,

Recently I'm trying to figuring out how Odoo Payroll works. Later then, I'm having an issue where I can't compute my payslip, it says that I submitting a wrong code in my Salary Rules

so here's my code

if contract.wage <= 50000000:
result = -(contract.wage * 0.05)
else:
result = -(contract.wage * 0.15)

I don't really know if it's the right code for If-Else statement haha. I really appreciate any kind of help from you guys, thank you

Аватар
Отменить
Лучший ответ

Am just answering for If-Else statement,

result = 0.00
if contract.wage <= 50000000:
    result = -(contract.wage * 0.05)
else:
    result = -(contract.wage * 0.15)
You should declare the variable result before accessing it and the computation should come inside with an indent spacing in If-Else statement(Python)
Let me know if it doesn't work, then your having an issue in your salary rule logic.
Аватар
Отменить
Автор

Hello Karthikeyan :D

First of all, I want to thank you for your time and answer but unfortunately, the code still gave me the same error.

However, I already find a way by splitting that rule into two (Rules AB → Rules A, Rules B) and adding the python code in the Condition section.

So the code for each rule be like:

Rules A (https://prnt.sc/zlo697)

*Condition: result = contract.wage > 50000000

*Computation: result = - (contract.wage * 0.15)

Rules B (https://prnt.sc/zlodok)

*Condition: result = contract.wage <= 50000000

*Computation: result = - (contract.wage * 0.05)

Once again, thank you for your answer Karthikeyan and I hope our answer could help other community members or anyone else :D

Related Posts Ответы Просмотры Активность
1
авг. 19
7438
1
мая 25
769
1
мар. 25
1008
0
февр. 25
1173
1
дек. 24
1701