How to do it...

Record rules are added using a data XML file. To do this, perform the following steps:

  1. Ensure that the security/library_security.xml file is referenced by the manifest data key:
    'data': [ 
        'security/library_security.xml', 
        # ... 
    ], 
  1. We should have a security/library_security.xml data file, with a <odoo> section that creates the security group:
<odoo noupdate="1">
<record model="ir.rule" id="library_book_user_rule">
<field name="name">Library: see only own books</field>
<field name="model_id" ref="model_library_book"/>
<field name="groups" eval="[(4, ref('my_library.group_library_user'))]"/>
<field name="domain_force">
[('is_public', '=', True)]
</field>
</record>
<record model="ir.rule" id="library_book_all_rule">
<field name="name">Library: see all books</field>
<field name="model_id" ref="model_library_book"/>
<field name="groups"
eval="[(4, ref('my_library.group_library_librarian'))]"/>
<field name="domain_force">[(1, '=', 1)]</field>
</record>
</odoo>

Upgrading the add-on module will load the record rules in the Odoo instance. If you are using demo data, you can test it through the default demo user to give library user rights to the demo user. If you are not using demo data, you can create a new user with library user rights.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset