콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
5347 화면
I have a field that is readonly if the status field of that model is finished, but if the logged user has a specific group, this field would no longer be readonly, how can I validate the user group in the xml, or some other way to achieve this


아바타
취소
베스트 답변

Hi,

This can be achieved using two views, one main view and the other one is inherited view(for which we will set user group).

In the main view, you can set the required field attributes for all users and then create an inherited view and set user group for it, then inside this inherited view, you can change the field properties as per need for this user group.


See an use case here:  Apply Changes In A View For Particular User Groups In Odoo


Thanks

아바타
취소

Please notice that this solution cannot be replicated on Odoo 16 or higher

베스트 답변

Hi Pavel,

Try

<field name="comment" attrs="{'readonly': [('state', '!=', 'submit')]}" force_save="1" groups="!base.group_system"/>

<
field name="comment" groups="base.group_system"/>


The "!base.group_system"  in Odoo restricts access to an element, such as a button or field, to all groups except the "Administration/Settings" group.
This means the element will not be accessible by the users who have Administration/Settings access


Hope it Helps,
Kiran K

아바타
취소
작성자 베스트 답변
I thought it was working fine for me, but it puts the editable field with any user, even though it doesn't have the group I put in the inherited view
 id="group_maintenance_petitioner" model="res.groups">
name="name">Maintenance Petitioner
name="category_id" ref="module_category_maintenance"/>


id="df_maintenance_work_order_form_inherit" model="ir.ui.view">
name="name">df.maintenance.work.order.form.inherit
name="model">df.maintenance.work.order
name="groups_id" eval="[(4, ref('group_maintenance_petitioner'))]"/>
name="inherit_id" ref="df_maintenance_work_order_form_view"/>
name="arch" type="xml">
name="employee_ids" position="attributes">
name="attrs">{'readonly': ['|',('state', 'in', ('history','cancelled','posted')),('active', '=', False)]}




아바타
취소