DEV Community

Jeevachaithanyan Sivanandan
Jeevachaithanyan Sivanandan

Posted on

1

Odoo : Add conditions to list view, custom record rules

The below code explains how to add conditions on list views in a model with custom record rules.

for our test case, the model mrp.bom has a field - is_bulk_bom, so we need to display the list of records based this field set and if the user has the group permission group_mrp_bulk_bom


        <!-- this record rule will show only records with is_bulk_bom is false to user without bulk bom permission -->
        <record id="bulk_bom_records_own" model="ir.rule">
            <field name="name">BOM : is bulk bom False</field>
            <field name="model_id" ref="mrp.model_mrp_bom"/>
            <field name="domain_force">[('is_bulk_bom', '=', False)]</field>
            <field name="groups" eval="[(4, ref('base.group_user'))]"/>
            <field name="perm_read" eval="1"/>
            <field name="perm_write" eval="1"/>
            <field name="perm_create" eval="1"/>
            <field name="perm_unlink" eval="1"/>

        </record>
Enter fullscreen mode Exit fullscreen mode

        <!-- this record rule will show only records with is_bulk_bom is true to user with bulk bom permission -->
        <record id="bulk_bom_records_is_bulk" model="ir.rule">
            <field name="name">BOM : is bulk bom True</field>
            <field name="model_id" ref="mrp.model_mrp_bom"/>
            <field name="domain_force">[('is_bulk_bom', '=', True)]</field>
            <field name="groups" eval="[(4, ref('module_name.group_mrp_bulk_bom'))]"/>
            <field name="perm_read" eval="1"/>
            <field name="perm_write" eval="1"/>
            <field name="perm_create" eval="1"/>
            <field name="perm_unlink" eval="1"/>
        </record>
Enter fullscreen mode Exit fullscreen mode

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more