Search code examples
xmlodoo

Inherit Group Category From Other Module's security.xml in Odoo


hope you are well today.

I have two security.xml files inside two custom different modules. One module is called picking_rename and another one is so_rename.

In the picking_rename module, i made a group category and the group itself. It shown like this one :

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- The group Category -->
    <record model ="ir.module.category" id="rename_privileges">
        <field name="name">Rename Privilege</field>
        <field name="description">Renaming privilege for certain documents</field>
    </record>

    <!-- The group -->
    <record id ="rename_picking_true" model="res.groups">
        <field name="name">Rename Partner Picking Order</field>
        <field name="category_id" ref="rename_privileges" />
    </record>
</odoo>

In my other security.xml inside so_rename, I also made a group. I want to make this group under the rename_privileges, which is declared in the different module as i said above.

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- The group -->
    <record id ="rename_so_true" model="res.groups">
        <field name="name">Rename Customer in Sales Order</field>
        <field name="inherit_id" ref="picking_rename.rename_privileges"/>
    </record>

</odoo>

I already put the picking_rename module inside depends in my so_rename, but i still got the error message.

    'depends': [
        'stock',
        'sale_management',
        'picking_rename'
    ],

The error message is shown below

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/pramardhika/Desktop/odoo15/odoo/http.py", line 644, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/Users/pramardhika/Desktop/odoo15/odoo/http.py", line 302, in _handle_exception
    raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing /Users/pramardhika/Desktop/odoo15/custom/odooapps/so_rename/security/security.xml:8, somewhere inside
<record id="rename_so_true" model="res.groups">
        <field name="name">Rename Sales Order</field>
        <field name="category_id" ref="rename_privileges"/>
    </record>

How can i make inheritance happen? Appreciate for the help


Solution

  • Ohh i solved it now,

    I just need to add ref=moduleName.groupName in the field. It's because the category_id is already installed along with the first module, so i just need to "normally call" it.

    My code in security.xml inside so_rename module become like this :

        <record model="res.groups" id ="rename_so_true">
            <field name="name">Rename Sales Order</field>
            <field name="category_id" ref="picking_rename.rename_privileges" />
        </record>
    

    Both group is now "united" under one category group as expected. enter image description here