Skip to Content
Menu
This question has been flagged
1 Reply
962 Views

i added this code to hide contacts who have is_foreign = True to users who does not have the user group  but it does not work

<record id="group_show_foreign_contacts" model="res.groups">
<field name="name">Show Foreign Contacts</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>

<record id="record_rule_show_foreign_contacts" model="ir.rule">
<field name="name">Show Foreign Contacts</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="domain_force">[('is_foreign', '=', True)]</field>
<field name="groups" eval="[(4, ref('hat_contact.group_show_foreign_contacts'))]"/>
</record>

and this is code in model py:

class ResPartner(models.Model):
_inherit = 'res.partner'
is_foreign=fields.Boolean()

and this is the data in manifest where group and rule exist in group.xml:

'data': [
'security/ir.model.access.csv',
'security/groups.xml',
'views/res_partner_inherit_view.xml',


all records appears when user doesn't have the group despite some records have is_foreign =True

Avatar
Discard
Best Answer

Hello

Please refer to this blog for creating record rules in Odoo 16.

https://www.cybrosys.com/blog/how-to-create-record-rule-in-odoo-16


Hope it helps

Avatar
Discard