コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
1574 ビュー

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


アバター
破棄
関連投稿 返信 ビュー 活動
2
8月 25
2403
1
7月 25
908
1
8月 25
1151
0
5月 25
1344
2
4月 25
3565