Skip to Content
Menu
This question has been flagged
3 Replies
6867 Views

I have below two salary rules and can see the computed value in pgAdmin, but it is not reflected in parent salary rule


<record id="hr_rule_other_deductions" model="hr.salary.rule">

            <field name="name">Other deductions</field>

            <field name="sequence" eval="122"/>

            <field name="code">OTHER_DEDUCT</field>

            <field name="category_id" ref="hr_payroll.DED"/>

            <field name="condition_select">none</field>

            <field name="amount_select">code</field>

            <field name="amount_python_compute">

result = rules.hr_rule_advance

            </field>

        </record>

        <record id="hr_rule_advance" model="hr.salary.rule">

            <field name="name">Advance on Salary</field>

            <field name="parent_rule_id" eval="hr_rule_other_deductions"/>

            <field name="sequence" eval="1"/>

            <field name="appears_on_payslip">false</field>

            <field name="code">ADVANCE_ON_SALARY</field>

            <field name="category_id" ref="hr_payroll.DED"/>

            <field name="condition_select">none</field>

            <field name="amount_select">code</field>

            <field name="amount_python_compute">

result = employee.get_advance_on_salary(payslip.date_from, payslip.date_to)

            </field>

        </record>

Avatar
Discard
Author Best Answer

Using new salary rule category solves the problem

<record id="OTHER_DED" model="hr.salary.rule.category">

            <field name="name">Other Deduction</field>

            <field name="code">OTHER_DED</field>

 </record>

<record id="hr_rule_other_deductions" model="hr.salary.rule">

            <field name="name">Other deductions</field>

            <field name="sequence" eval="122"/>

            <field name="code">OTHER_DEDUCT</field>

            <field name="category_id" ref="hr_payroll.DED"/>

            <field name="condition_select">none</field>

            <field name="amount_select">code</field>

            <field name="amount_python_compute">

result = categories.OTHER_DED

            </field>

        </record>

        <record id="hr_rule_advance" model="hr.salary.rule">

            <field name="name">Advance on Salary</field>

            <field name="parent_rule_id" eval="hr_rule_other_deductions"/>

            <field name="sequence" eval="1"/>

            <field name="appears_on_payslip">false</field>

            <field name="code">ADVANCE_ON_SALARY</field>

            <field name="category_id" ref="l10n_mu_hr_payroll.OTHER_DED"/>

            <field name="condition_select">none</field>

            <field name="amount_select">code</field>

            <field name="amount_python_compute">

result = employee.get_advance_on_salary(payslip.date_from, payslip.date_to)

            </field>

 </record>

Avatar
Discard
Best Answer

Please try
result = rules.ADVANCE_ON_SALARY

Avatar
Discard
Author

This is not working. The code will will work only for categories like below

result = categories.ALW

I cannot use categories variable as only specific deductions (i.e ,Advance on salary) goes under Other deductions. This Advance on salary won't appear on payslip, but the main rule 'Advance on salary' needs to appear with total of all child rules it has.

# Available variables:

#----------------------

# payslip: object containing the payslips

# employee: hr.employee object

# contract: hr.contract object

# rules: object containing the rules code (previously computed)

# categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category).

# worked_days: object containing the computed worked days.

# inputs: object containing the computed inputs.

# Note: returned value have to be set in the variable 'result'

Related Posts Replies Views Activity
1
Dec 24
397
0
Nov 24
107
1
Jul 24
4043
2
Jun 24
3471
1
Dec 23
450