Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to overwrite object in a module using data and xml (ir.rule)?

By
Anders Wallenquist
on 11/13/14, 9:06 AM 1,209 views

I want to override  a Security Record Rule (model ir.rule) with a new domain. I have looked up the record id and model in External Identifiers and produced this data.xml-file:

<data>

<record id="base.res_partner_rule" model="ir.rule">
            <field name="name">Multi-company res.partner</field>
            <field name="model_id" ref="base.model_res_partner"/>
            <field eval="True" name="global"/>
            <field name="domain_force">['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id','in',[company.id for company in user.company_ids])]</field>
        </record>

</data>

I dont get any erros when I install the module but the ir.rule-record does not get updated.

<data noupdate="false">

<data noupdate="0">

<data noupdate="1">

I have tried some attributes on data but with no luck.

 

I'm facing the same issue. Do you find a proper way to handle this ?

David Bertha
on 7/16/15, 6:41 AM
0
Shawn Varghese
On 10/3/15, 6:49 AM

This is probably because the default rule has been defined with <data noupdate="1">

Once this is done, you cannot update it or overwrite it or even set the noupdate property to 0.

You can instead navigate to Settings > Sequences & Identifiers > External Identifiers and search for res_partner_rule.

Open this record and uncheck the "Non Updatable" boolean. Try updating your custom module again.

It is still useless because of the manual work involved, you might as well create a record rule on the UI directly. But it can save you some time. Please let us know if you find a better way to do this.



Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/13/14, 9:06 AM
Seen: 1209 times
Last updated: 10/3/15, 6:49 AM