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

Hello all,

i am trying to override base record rule in my custom module because i want to display only current company partner to specific user. but when i use base feature frim settings 》 multi comoany and uncheck share partner then it apply on all company and user 


so i am trying to do this for only some user or only for some compnay so i am overriding base record rule but it's not working


 <record model="ir.rule" id="res_partner_rule">
            <field name="name">res.partner company</field>
            <field name="model_id" ref="base.model_res_partner"/>
            <!--
Show partners from ancestors and descendants companies
(or company-less), this is usually a better default for
multicompany setups.
-->
            <field name="domain_force">['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
            <field name="active" eval="False"/>
        </record>
i am trying to override above rule

please any one help me
アバター
破棄
最善の回答

Hi, your changes on res_partner_rule from your custom_module is not affected because that record rule is set in the base module xml file with noupdate="1"

And also if you notice, that rule is inactive by default.

<record model="ir.rule" id="res_partner_rule">
<field name="name">res.partner company</field>
<field name="model_id" ref="base.model_res_partner"/>
<!--
Show partners from ancestors and descendants companies
(or company-less), this is usually a better default for
multicompany setups.
-->
<field name="domain_force">['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
<field name="active" eval="False"/>
</record>

So before modifying the rule, just enable that default rule n try if it solves your issue. 

if not, you may check this link to understand how to override the record values set with noupdate="1", from your custom module. For eg:

<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value eval="[('module', '=', 'base'), ('name', '=', 'res_partner_rule')]"/>
</function>
<value eval="{'noupdate': False}"/>
</function>

<record model="ir.rule" id="base.res_partner_rule">
<field name="name">res.partner company</field>
<field name="model_id" ref="base.model_res_partner"/>
<!--
Show partners from ancestors and descendants companies
(or company-less), this is usually a better default for
multicompany setups.
-->
<field name="domain_force"> ['|',('company_id','=',user.company_id.id),('company_id','=',False)]</field>
<field name="active" eval="True"/>
</record>


<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value eval="[('module', '=', 'base'), ('name', '=', 'res_partner_rule')]"/>
</function>
<value eval="{'noupdate': True}"/>
</function>

Hope this helps!!

アバター
破棄
最善の回答

Hi,

You can rewrite/overide exiting rule in your custom module and do necessary changes. What you have to do is that, just copy and paste the original rule in your module and change its ID like with original_module_name.ID


Suppose if the rule  is coming from the module purchase and if it's ID is test_rule , in your custom module change the ID of record to purchase.test_rule


Thanks

アバター
破棄
関連投稿 返信 ビュー 活動
2
3月 24
1605
1
3月 24
1841
2
12月 18
7107
1
3月 15
4471
0
3月 15
3212