Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
11463 Zobrazení

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
Zrušit
Nejlepší odpověď
<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
Zrušit

use >= for >=

Autor

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 >

Nejlepší odpověď
    <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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
lis 22
2214
2
úno 23
2451
0
bře 24
2064
3
pro 19
6681
1
srp 16
4621