Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
6719 มุมมอง

Hii, I am trying to write a python expression in xml file for salary rule. My expression is multi line, so when I import and compute salary, it gives error on python expression...

Python code

unpaid = payslip.total_unpaid_leave_days 
basic = contract.wage
result = basic - (unpaid * basic/30)

xml code

<record id="hr_payroll.hr_rule_basic" model="hr.salary.rule">
<field name="name">Basic Salary</field>
<field name="sequence" eval="1"/>
<field name="code">BASIC</field>
<field name="category_id" ref="hr_payroll.BASIC"/>
<field name="condition_select">none</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">unpaid = payslip.total_unpaid_leave_days basic = contract.wage result = basic - (unpaid * basic/30)</field>
</record>

I put it in one line, it did not work...How to do it here

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

You can write muti line python code in salary rule in xml with proper indentation. Search for .<field name="amount_select">code</field> in your Odoo source code. you will find some example.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

You can use directly like this:

result = contract.wage - (payslip.total_unpaid_leave_days * contract.wage/30)


อวตาร
ละทิ้ง
ผู้เขียน

This is also correct

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ย. 22
2269
2
มี.ค. 15
11509
2
ก.พ. 23
2512
0
มี.ค. 24
2064
3
ก.พ. 21
16582