콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
6889 화면

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

관련 게시물 답글 화면 활동
0
11월 22
2467
2
3월 15
11703
2
2월 23
2752
0
3월 24
2064
3
2월 21
16863