Boubaker
Boubaker

Reputation: 429

inherit and replace ir.rule odoo 11

I want to change in domaine force " res_partner_rule_private_employee" how to inherit and replace with my new code

this the origin in base/security/base_security.xml

  <!-- Security restriction for private addresses -->
        <record id="res_partner_rule_private_employee" model="ir.rule">
            <field name="name">res.partner.rule.private.employee</field>
            <field name="model_id" ref="base.model_res_partner"/>
            <field name="domain_force">
                 ['|', ('type', '!=', 'private'), ('type', '=', False)]

            </field>
            <field name="groups" eval="[
                (4, ref('base.group_user')),
            ]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="False"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_unlink" eval="False"/>
        </record>

I want to replace with this in my /security new module

<record id="rule_private_employee" model="ir.rule">
        <field name="name">res.partner.manager</field>
        <field name="model_id" ref="base.model_res_partner"/>
        <field name="domain_force"> 


          ['|','&', ('type', '!=', 'private'), ('type', '=', False),('is_student', '!=', True)]
        </field>
        <field name="groups" eval="[
            (4, ref('base.group_user')),
        ]"/>
        <field name="perm_read" eval="True"/>
        <field name="perm_write" eval="False"/>
        <field name="perm_create" eval="False"/>
        <field name="perm_unlink" eval="False"/>
</record> 

but the '&' character does not work in version 11 and if it correct it does not load my modification!

Upvotes: 0

Views: 3961

Answers (2)

aekis.dev
aekis.dev

Reputation: 2754

If you wanna change an existing record values you will need to define a record with the same id, in your case base.res_partner_rule_private_employee.

No need to define all the values already defined, just the ones that you wanna add/change. Like:

<record id="base.res_partner_rule_private_employee" model="ir.rule">
    <field name="domain_force">
        ['|','&amp;', ('type', '!=', 'private'), ('type', '=', False),('is_student', '!=', True)]
    </field>
</record>

Also I think that the & or &amp; it's not needed in this case since it's the default operator between tuples when you don't specify it but it's a matter of try it

Upvotes: 2

Veikko
Veikko

Reputation: 3610

& is a special character in XML. You need to encode it as &amp;. The field in xml would be:

    <field name="domain_force"> 
      ['|','&amp;', ('type', '!=', 'private'), ('type', '=', False),('is_student', '!=', True)]
    </field>

More info on XML encoding can be found in answer What characters do I need to escape in XML documents?.

Upvotes: 0

Related Questions