Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
1569 Weergaven

i added this field in res.partner:
class ResPartner(models.Model):
_inherit = 'res.partner'
 is_foreign=fields.Boolean()


and i added this group :

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

i need to show the partners which have is_foreign equal True only for users which have this group in odoo16









i need to show the partners which have is_foreign equal True only for users which have this group in odoo16

Avatar
Annuleer
Beste antwoord

Hi Asmaa, 

Please find code in comment. 

Hope it will be helpful to you.

Thanks & Regards,
Email: odoo@aktivsoftware.com 

Skype: kalpeshmaheshwari

Avatar
Annuleer

Please find code here :-

class ResPartner(models.Model):
_inherit = "res.partner"

is_foreign=fields.Boolean()

<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="res_partner_rule_show_foreign_contacts" model="ir.rule">
<field name="name">res.partner.rule.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('module_name.group_show_foreign_contacts'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_unlink" eval="True"/>
</record>

Remember, This will not work for Admin as that user have extra permissions and other record rules will affect that,

You can remove other record rule for 'Contact' and can use demo user to check this

Feel free to contact us for further assistance

Beste antwoord

Hi,

You can add record rules for the contacts. Try the code below,

<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('your_module.group_show_foreign_contacts'))]"/>
</record>


Hope it helps


Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
aug. 25
2401
1
jul. 25
905
1
aug. 25
1151
0
mei 25
1344
2
apr. 25
3564