[英]How to make a field readonly for a particular group in Open Erp 7?
I have a field which i want to make it readonly for all the user from a group, lets say base.group_userA. 我有一个字段,我想使它对于组中的所有用户都是只读的,可以说base.group_userA。 any other users will be able to edit and save the field.
其他任何用户都可以编辑和保存该字段。 How do i do that in openerp?.
我如何在openerp中做到这一点? I have already set all CRUD access rights for all users.
我已经为所有用户设置了所有CRUD访问权限。
'WO_NOTES' : fields.text("Description"),
in xml 在xml中
<field name="WO_NOTES"/>
I had the same problem, only I wanted to show fields only to users in a group. 我遇到了同样的问题,只是我只想向组中的用户显示字段。 I solved this by inheriting the view and made changes to the specific group.
我通过继承视图解决了这一问题,并对特定组进行了更改。
In your case it should look something like this: 在您的情况下,它应如下所示:
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="view_id">
<field name="name">view.id</field>
<field name="model">your.model</field>
<field name="inherit_id" ref="id_of_inherited_view"/>
<field name="groups_id" eval="[(6, 0, [ref('base.group_userA') ])]"/>
<field name="arch" type="xml">
<field name="WO_NOTES" position="attributes">
<attribute name="readonly">1</attribute>
</field>
</field>
</record>
</data>
</openerp>
Hope this helps! 希望这可以帮助!
--- A little edit to clarify a little my answer --- ---进行一些编辑以澄清我的答案---
I assume that you have your form view, working fine to all users (with the WO_NOTES editable to all users). 我假设您拥有表单视图,对所有用户都可以正常工作(WO_NOTES对所有用户均可编辑)。 With this inheritance, the change will take place only to users belonging to
base.group_userA
, changing it's attribute to readonly (only to this field and only to users from this group). 有了这种继承,更改将仅发生于属于
base.group_userA
用户,并将其属性更改为readonly(仅更改为该字段,并且仅更改为该组的用户)。
The <field name="WO_NOTES" position="attributes"> <attribute name="readonly">1</attribute></field>
part will locate the field in the parent view and make it readonly. <field name="WO_NOTES" position="attributes"> <attribute name="readonly">1</attribute></field>
部分将在父视图中定位该字段并将其设置为只读。 The <field name="groups_id" eval="[(6, 0, [ref('base.group_userA') ])]"/>
limits this change to the specified group. <field name="groups_id" eval="[(6, 0, [ref('base.group_userA') ])]"/>
将此更改限制为指定的组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.