Skip to Content
Menu
This question has been flagged
1 Reply
3574 Views

Hello Guys am customizing the Odoo 12 payroll module i need to get the id for a specific rule i have tried using the domain below as my python condition unfortunately its giving me an error "Wrong python condition defined for salary rule Insurance Relief (SAL96)".Any ideas on how i can work it out? 

[('rule_id', '=',  rule.id)]

Avatar
Discard
Best Answer

Hello Dishon Kadoh,

instead of id, you can use rule code. We have already a "rules" field in salary rule which is a object containing the rules code.

can you Please give brief information about your issue with Insurance Relief (SAL96) salary rule code.

Thanks,

Avatar
Discard
Author

I have added a one to many field in the employee section by the field name 'reliefs'.Inside the one to many field i have a field name 'rule_id' which has a many to one relation with the salary rule.

Now in my xml code i have created a domain in my python condition where i want to map rule id to its original record id however the domain is not working how can i go about it here is my xml file.

<record id="hr_salary_rule_employee_insurance_relief"

model="hr.salary.rule">

<field name="category_id"

ref="hr_payroll_insurance_relief_category"/>

<field name="name">Insurance Relief</field>

<field name="code">SAL96</field>

<field name="sequence">96</field>

<field name="condition_select">python</field>

<field name="condition_python">result = any(employee.reliefs.search([('employee_id', '=', employee.id),('rule_id', '=', rule.id)]))

</field>

<field name="amount_select">code</field>

<field name="amount_python_compute">PERCENTAGE = 0.15

PRESCRIBED_LIMIT = 3000

COMPUTED_RELIEF = PERCENTAGE * sum([x.amount for x in employee.reliefs.search([('employee_id', '=', employee.id),('rule_id', '=', rule.id)])])

if employee.resident:

result = min(PRESCRIBED_LIMIT, COMPUTED_RELIEF)

else:

result = 0.0

</field>

</record>

Hello ,

you can use rules in salary rules which is a object containing the rules code. Through this, you can get the salary rule id.

rule_id = rules.dict.['salary rule code'].id

For Ex.

rule_id = rules.dict['BASIC'].id

But instead of this, why don't you use the 'compute_sheet' or '_get_payslip_lines' methods of hr.payslip model and compute the Insurance Relief salary rule amount.

Hope it will help you.

thanks

Related Posts Replies Views Activity
0
May 23
2027
2
Apr 19
1887
1
Mar 18
3194
2
Dec 24
724
3
Dec 24
13070