跳至內容
選單
此問題已被標幟
2 回覆
11405 瀏覽次數

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
2179
2
2月 23
2378
0
3月 24
2064
3
12月 19
6660
1
8月 16
4554