Skip to Content
Menu
This question has been flagged
2 Replies
11507 Views

I have created a specific salary rule which the amount computation is based on a complex python expression
My python expression is similar to:

result = (-200 if contract.wage >= 12000 
else -150 if ((contract.wage >= 9000) and (contract.wage <= 11999))
else -80 if ((contract.wage >= 6000) and (contract.wage <= 8999)) 
else -20 if  ((contract.wage >= 3000) and (contract.wage <= 5999))
else -0)

How can I put this salary rule in a xml data file knowing that '&gt;' and '&lt;' didn't work?

Avatar
Discard
Best Answer
<record id="hr_rule_xyz" model="hr.salary.rule">
    <field name="name">xyz</field>
    <field name="sequence" eval="1"/>
    <field name="code">xyz</field>
    <field name="category_id" ref="hr_payroll.xyz"/>
    <field name="condition_select">none</field>
    <field name="amount_select">code</field>
    <field name="amount_python_compute">result = (-200 if contract.wage &gt;= 12000 else -150 if ((contract.wage &gt;= 9000) and (contract.wage &lt;= 11999)) else -80 if ((contract.wage &gt;= 6000) and (contract.wage &lt;= 8999)) else -20 if  ((contract.wage &gt;= 3000) and (contract.wage &lt;= 5999)) else -0)</field>
</record>
Avatar
Discard

use >= for >=

Author

Thank you friends. I used the '<' sign and it get a syntax error as it' interpreted as a tag start. I didn't think to reverse conditional expressions to use '>'.

oh yes lt and gt u can use it works..i have been used lt and gt in my answe but it shows < and >

Best Answer
    <record id="hr_rule_xyz" model="hr.salary.rule">
        <field name="name">xyz</field>
        <field name="sequence" eval="1"/>
        <field name="code">xyz</field>
        <field name="category_id" ref="hr_payroll.xyz"/>
        <field name="condition_select">none</field>
        <field name="amount_select">code</field>
        <field name="amount_python_compute">result = (-200 if contract.wage >= 12000 else -150 if ((contract.wage >= 9000) and (contract.wage <= 11999)) else -80 if ((contract.wage >= 6000) and (contract.wage <= 8999)) else -20 if  ((contract.wage >= 3000) and (contract.wage <= 5999)) else -0)</field>
    </record>
Avatar
Discard
Related Posts Replies Views Activity
0
Nov 22
2261
2
Feb 23
2507
0
Mar 24
2064
3
Dec 19
6717
1
Aug 16
4643