-2

I want to show a field read-only for all users of group named Manager (having read and update rights for that model). They must not be able to update a field called 'x_name'.

I am using odoo web client (Gui) and don't have access of xml file. I am only able to use the GUI so please suggest a solution for working this out through GUI.

halfer
  • 19,824
  • 17
  • 99
  • 186
Sankalp Kataria
  • 479
  • 7
  • 24

2 Answers2

0

Go to Settings -> User Interface -> Views and create a view, give it the following contents:

<record id="give_an_id" model="ir.ui.view">
            <field name="name">give_a_name</field>

            <field name="model">your.model</field>
            <field name="inherit_id" ref="module.the_id_of_the_view_that_field_is_on" />
            <field name="groups_id" eval="[(6, 0, [ref('module.the_id_of_the_group_for_which_you_want_the_field_hidden') ])]" />                
            <field name="arch" type="xml">                                   
                <field name="x_name" position="attributes">
                   <attribute name="readonly">1</attribute>                   
                </field>                              
            </field>
</record>

So what happens here is that the above view gets activated only when the user belongs in groups_id more here.

George Daramouskas
  • 3,720
  • 3
  • 22
  • 51
  • The user has Read and Write rights for that model so he can also edit information except the name. Adding group attribute will hide that field from the users of that group, but i don't want to hide it – Sankalp Kataria Sep 06 '17 at 10:19
  • @SankalpKataria I have edited my answer, this should work as you need it – George Daramouskas Sep 06 '17 at 10:41
0

You can achieve it by inheriting a view, also you can create a new inherited view from the GUI and add group id for that view. Enable Debug mode.

Go to Settings > Technical > Views > Create new view

Add All the field like which view you want to inherit, view type

Add Group name inside the Access rights

Inside the architecture add :

<field name="your_field_name" position="attributes">
<attribute name="readonly">1</attribute>
</field> 
KbiR
  • 4,047
  • 6
  • 37
  • 103
Heroic
  • 980
  • 4
  • 12