Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1567 Vistas

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
Descartar
Mejor respuesta

Hi Asmaa, 

Please find code in comment. 

Hope it will be helpful to you.

Thanks & Regards,
Email: odoo@aktivsoftware.com 

Skype: kalpeshmaheshwari

Avatar
Descartar

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

Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
ago 25
2396
1
jul 25
903
1
ago 25
1151
0
may 25
1341
2
abr 25
3560