Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
1572 Представления

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

Аватар
Отменить
Лучший ответ

Hi Asmaa, 

Please find code in comment. 

Hope it will be helpful to you.

Thanks & Regards,
Email: odoo@aktivsoftware.com 

Skype: kalpeshmaheshwari

Аватар
Отменить

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

Лучший ответ

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


Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
авг. 25
2401
1
июл. 25
905
1
авг. 25
1151
0
мая 25
1344
2
апр. 25
3564