DEV Community

Jeevachaithanyan Sivanandan
Jeevachaithanyan Sivanandan

Posted on

Odoo 16 : how to add attributes with conditions

If you want to add a custom condition to show/hide a field, you would need to use XPath. For instance, to show a field 'cost' in the product template only if the user is a member of a custom group called 'Allow Cost and Price' you need to know the XML ID of this group, which is 'group_edit_costprice_purchaseorders.'

Now, you can inherit the product template and add the XPath as shown below

            <xpath expr="//field[@name='standard_price']" position="attributes">
                <attribute name="groups">
                    custom_extension.group_edit_costprice_purchaseorders
                </attribute>                
            </xpath>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)