Odoo 15 Change existing record rules
Change odoo base record rules with your own new record rules
11 December, 2022 by
Odoo 15 Change existing record rules
Pranshu Tiwari

    Odoo base record rules changing


    Odoo 15 Change existing record rules

    Here is the code for changing the base record rules. And updating with the new record rules.

    Suppose For example in purchase vendor Price list and the object name is product.supplierinfo in that it is company specific field. Mens

    One company can see own vendor price and other company can not see the other company vendor price list.

    So in that if we change the base multi company record rules. And update the records for all the companies then it will work.

    Now we are going to explain how to change the base record rules with the backend. Form front end that is easy you can easily do at your end otherwise drop your request at business@erpcall.com. Our expert team will help you in that setup. Now lets continue with backend process. 

    1- First go to Custom module and under security folder create your own security.xml file(you can give any name with .xml extension). If in your custom module security folder not created then you can create as well.

    2-Once your file and foder created then give the path in your manifest file.  'security/security.xml', like this.

    3- In that file now its time to change the odoo15 base record rules.

    So before modifying the rule, just run function command to change noupdate=''1'', Becuause until this noupdate="1", we can not modify our odoo base record rules.

    if not, you may check this link to understand how to override the record values set with noupdate="1", And to check this with the name filed you can search base code from odoo addons.

    With this highlighted name you can search in your odoo base rules. And then start changing with the id. Let me explain with full code. For same case-

    <function name="write" model="ir.model.data">
    <function name="search" model="ir.model.data">
    <value eval="[('module', '=', 'product'), ('name', '=', 'product_supplierinfo_comp_rule')]"/>
    <value eval="{'noupdate': False}"/>

    <record model="ir.rule" id="product.product_supplierinfo_comp_rule">
    <field name="name">product supplierinfo company rule</field>
    <field name="model_id" ref="product.model_product_supplierinfo"/>
    <field name="domain_force">[(1,'=',1)]</field>
    <field name="active" eval="True"/>

    <function name="write" model="ir.model.data">
    <function name="search" model="ir.model.data">
    <value eval="[('module', '=', 'product'), ('name', '=', 'product_supplierinfo_comp_rule')]"/>
    <value eval="{'noupdate': True}"/>

    4- With the same code you can change your odoo base record rules. 

    5- We chnage noupdate' : False with the the help of function.

    6- Then change base record rules with the new domain multi company allow.

    7- And then last again we make noupdate: True for the record rules.

    So this way we can change/modify/delete odoo14 base record rules and same it also work for odoo15 base record rules.

    I hope this blog will help you get idea about the record rules.

    If further query or question if you have related to your record rules or any odoo related work like odoo customization, odoo modification, odoo migration then you can connect with us at business@erpcall.com


    ERPcaLL Team

    in Odoo