如何根据组和状态将字段设置为只读? [英] How to make field readonly based on group and status?
问题描述
我想根据组和状态使字段准备就绪.
I want to make field readony based on group, and status.
就像我有两个问题一样:1.经理组2.用户组
Like i have two grops 1. Manager Group 2. User Group
如果我将 User Group (用户组)授予任何用户,然后状态完成,则该用户的字段将为只读.
If I give User Group to any user then and Status Done then field will be readonly for this user.
希望我能清楚地理解
谢谢
推荐答案
创建boolean类型的功能字段.如果登录的用户在用户组下并且状态为完成,则返回true.然后在视图中,指定attrs="{'readonly':[('boolean_field_name','=',True)]}"
Create a functional field of type boolean. If the logged in user is under user group and state is done, then return true. Then in the view, specify attrs="{'readonly':[('boolean_field_name','=',True)]}"
OR
首先创建您的表单视图.然后继承视图,同时指定组.例如在销售订单表单视图中,当状态不在草稿中或未发送时,我想使组用户的客户参考字段为只读.
First create your form view. Then inherit the view also specify the groups. for example in sale order form view, i want to make the customer reference field readonly for group user when state is not in draft or sent.
<record id="view_order_form_cust_ref_readonly" model="ir.ui.view">
<field name="name">sale.order.form.readonly.cust</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="groups_id" eval="[(6, 0, [ref('base.group_user') ])]"/>
<field name="arch" type="xml">
<field name='client_order_ref'" position="attributes">
<attribute name="attrs">{'readonly':[('state','not in',['draft','sent'])]}</attribute>
</field>
</field>
</record>
这篇关于如何根据组和状态将字段设置为只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!