Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
1573 Visualizações

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
Cancelar
Melhor resposta

Hi Asmaa, 

Please find code in comment. 

Hope it will be helpful to you.

Thanks & Regards,
Email: odoo@aktivsoftware.com 

Skype: kalpeshmaheshwari

Avatar
Cancelar

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

Melhor resposta

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
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
2
ago. 25
2401
1
jul. 25
905
1
ago. 25
1151
0
mai. 25
1344
2
abr. 25
3564