简体   繁体   English

如何在Open Erp 7中将特定组的字段设置为只读?

[英]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.

相关问题 如何使开放erp7中特定组下的用户的many2one字段只读? - how to make many2one field readonly for user which is under specific group in open erp7? 如何使用Django ORM进行查询,以便基于特定组中的datetime字段返回最新条目? - How to use Django ORM to make a query so that it returns the latest entry based on a datetime field in a particular group? Django 表格,设为只读字段 - Django Form, make readonly field 如何在 Django 表单中创建一个用户无法编辑的只读字段? - How to make a readonly field that can not be edited by user in a Django forms? 我应该如何在 django 中自动填充字段并使其只读? - How should i auto fill a field and make it readonly in django? 如何在odoo 11中使用widget =“priority”使选择字段不可悬停或只读 - How to make selection field with widget=“priority” unhoverable or readonly in odoo 11 未从代码调用开放ERP-功能字段 - Open ERP- Functional field not getting called from code 使django只读字段在管理员上可见 - Make a django readonly field visible on the admin 如何在开放式ERP中将打印尺寸更改为一半? - How to Change the size of print just half in open ERP? 在 Django 中发送 Post 请求后,如何将字段设为只读? - How can I make a field readonly after sending a Post Request in Django?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM