콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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
1659
1
3월 24
1923
2
12월 18
7171
1
3월 15
4521
0
3월 15
3260