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

Hi Odooers !
I'd like to know how I can either modify an existing security group or add a new one to an existing module ? In my case I need to have a security group to only allow read access to purchase orders and purchase orders lines (Purchase module). I'd like to do that through a new module that will extend the existing purchase module. I tried to add the following xml to my module's security xml:

<record id="group_purchase_user" model="res.groups">
<field name="name">Consulter</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
<field name="category_id" ref="base.module_category_purchase_management"/>
</record>

With the following rules:

access_purchase_order_readonly,access_purchase_order_readonly,purchase.model_purchase_order,group_purchase_user,1,0,0,0
access_purchase_order_line_readonly,access_purchase_order_line_readonly,purchase.model_purchase_order_line,group_purchase_user,1,0,0,0

Thinking I could override the existing "User" security group of Purchase.

I also tried to add a new security group with new security rules in the same fashion:

<record id="group_consult_internal_purchase" model="res.groups">
<field name="name">Consulter</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
<field name="category_id" ref="base.module_category_purchase_management"/>
</record>
access_purchase_order_readonly,access_purchase_order_readonly,purchase.model_purchase_order, group_consult_internal_purchase,1,0,0,0
access_purchase_order_line_readonly,access_purchase_order_line_readonly,purchase.model_purchase_order_line, group_consult_internal_purchase,1,0,0,0

I tried to find examples in the documentation or the internet but I couldn't find any so I'm even sure that's possible.

Help please ?



아바타
취소
베스트 답변

Hi,

There are some existing record rules and access rights for this models in the odoo source code, you might need to inherit and change those rules for achieving what you are trying to do.


For Changing an existing record rule, you can do it like this,

<record model="ir.rule" id="purchase_order_line_comp_rule">
<field name="name">Purchase Order Line multi-company</field>
<field name="model_id" ref="model_purchase_order_line"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>


The above rule is defined in the purchase module, suppose if i need to change the domain to empty for this rule from my custom module what i have to do is ,

<record model="ir.rule" id="purchase.purchase_order_line_comp_rule">
<field name="domain_force"></field>
</record>


Copy existing rule to your module, remove those lines you don't want to make changes and change the id to original_module_name.orginal_id . In the above code, you can see i have changed the id purchase_order_line_comp_rule to purchase.purchase_order_line_comp_rule . This is how you can change existing record rules.


For Changing existing access rights,you have to follow same procedures, replace the id with original_module_name.id .


Thanks

아바타
취소
작성자

Thanks for the answer ! do you think it is also possible to add a new security group to an existing module from my custom module ?

how can i add a new group to the list of module groups

관련 게시물 답글 화면 활동
3
9월 15
4112
2
5월 15
5121
3
8월 25
719
1
7월 25
617
1
7월 25
1008