Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
11520 มุมมอง

I want to set a python code in 'Condition based on' field so that this particular rule will not be shown or printed with payslip when result is false. The condition I want to check is the existence of an inputs line with code as LOAN. something like

result = exist(inputs.LOAN)

That's a half pseudo code above. What's the exact python syntax in OpenERP to achieve this?

Thanks :)

อวตาร
ละทิ้ง

what is LOAN is it a boolean field ?

ผู้เขียน

No. I created a Salary Rule called LOAN and a Salary Structure containing this specific rule. An employee contract is with this Salary Structure and when generating payslip, I do not want to show this specific rule in PaySlip if an Input item with code LOAN doesn't exist.

คำตอบที่ดีที่สุด

Hello,

I tried the following in v17:

Here's something which you could use as well:

Since Loans may be added optionally to the payslip under the 'Other inputs', I added the python code under the rule as follows:

I had to first configure an "other input type" (Configuration > Salary > Other Input Types) called Loan payment with the code LOAN,

Then create a rule under the structure you'd like to use (can be the same name as the other input type name and the same code),

For the Python condition: result = 'LOAN' in inputs

Under the computation, add the following Python Code:

result = inputs['LOAN'].amount

result_name = inputs['LOAN'].name

Hope this helps!

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

iN THE PYTHON CONDITION EXPRESSION ADD THE FOLLOWING;

result = (inputs.LOAN.amount  and inputs.LOAN)  or False

อวตาร
ละทิ้ง

result = (inputs and inputs.LOAN and inputs.LOAN.amount) or False

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 15
3625
0
มี.ค. 15
3672
1
ก.พ. 20
3874
how to manage variable-based salaries? แก้ไขแล้ว
2
ม.ค. 25
1347
Date in salary rules? แก้ไขแล้ว
2
ธ.ค. 24
2402