从 Odoo 中的其他模块的 security.xml 继承组类别

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

祝你今天一切顺利。

我在两个自定义的不同模块中有两个 security.xml 文件。一个模块称为 picking_rename,另一个模块称为 so_rename.

picking_rename模块中,我制作了一个群组类别和群组本身。显示如下:

<?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>

在我的其他security.xml里面so_rename,我也做了一个群。我想把这个组放在 rename_privileges 下,如上所述,它在不同的模块中声明。

<?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>

我已经在我的 so_rename 中将 picking_rename 模块放入 depends 中,但我仍然收到错误消息。

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

错误信息如下所示

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>

我怎样才能实现继承? 感谢您的帮助

哦,我现在解决了,

我只需要在字段中添加 ref=moduleName.groupName。这是因为 category_id 已经和第一个模块一起安装了,所以我只需要“正常调用”它即可。

我在 security.xmlso_rename 模块中的代码变成这样:

    <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>

这两个组现在如预期的那样“统一”在一个类别组中。