Odoo - How to inherit BASE Salary structure as data and add new salary rules to it

半腔热情 提交于 2019-12-24 01:17:54

问题


I need to add a new Salary rule in Base of a data.xml file, so I can compute the total allowances and deductions. The final output should look like this:

Here's my code:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data noupdate="1">
        <record id="ALLOWANCES" model="hr.salary.rule.category">
            <field name="name">Allowances</field>
            <field name="code">ALLOWANCES</field>
        </record>
        <record id="DEDUCTIONS" model="hr.salary.rule.category">
            <field name="name">Deductions</field>
            <field name="code">DEDUCTIONS</field>
        </record>
        <record id="hr_rule_allowances" model="hr.salary.rule">
            <field name="name">Allowances</field>
            <field name="sequence" eval="99"/>
            <field name="code">ALLOWANCES</field>
            <field name="category_id" ref="hr_wps.ALLOWANCES"/>
            <field name="condition_select">none</field>
            <field name="amount_select">code</field>
            <field name="amount_python_compute">result = categories.ALW</field>
        </record>
        <record id="hr_rule_deductions" model="hr.salary.rule">
            <field name="name">Deductions</field>
            <field name="sequence" eval="199"/>
            <field name="code">DEDUCTIONS</field>
            <field name="category_id" ref="hr_wps.DEDUCTIONS"/>
            <field name="condition_select">none</field>
            <field name="amount_select">code</field>
            <field name="amount_python_compute">result = categories.DED</field>
        </record>

        <!-- Salary Structure -->

         <record id="structure_base_extend" model="hr.payroll.structure">
            <field name="code">BASE</field>
            <field name="name">Base for new structures</field>
            <field name="inherit_id" ref="hr_payroll.structure_base"/>
            <field eval="[(6, 0, [ref('hr_rule_allowances'), ref('hr_rule_deductions')])]" name="rule_ids"/>
        </record>

but I get this error:

ParseError: "External ID not found in the system: hr_payroll.ALLOWANCES" while parsing /home/youta/odoo-8/my_addons/hr_wps/wps_data.xml:15, near ''

and when I tried to erase this line

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

I got another error that category_id cannot be NULL

Any help will be appreciated. Thanks.

After fixing the mentioned problem.. Now what I get it created duplicated BASE salary rule with the new two rows only instead of being added to the original BASE. how can I inherit the BASE structure instead of creating new one.

来源:https://stackoverflow.com/questions/36956438/odoo-how-to-inherit-base-salary-structure-as-data-and-add-new-salary-rules-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!