コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
11431 ビュー

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?

アバター
破棄
最善の回答
<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>
アバター
破棄

use >= for >=

著作者

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 >

最善の回答
    <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>
アバター
破棄
関連投稿 返信 ビュー 活動
0
11月 22
2200
2
2月 23
2406
0
3月 24
2064
3
12月 19
6671
1
8月 16
4579