Skip to Content
Menu
This question has been flagged

How can we make a field readonly based on group and state?  i have

<field name="store_manager_id"  options="{'no_open':True,'no_create':1,'no_create_edit':1}"   required="True"

attrs="{'readonly': [ ('state', 'not in', ['draft'])]}"

i want to make it read only for user except when in 'draft' state  but editable for manager in all states. How can it be done?

Avatar
Discard
Author Best Answer

Hello anyone reading.....got the answer!!!! I solved it this way! After creating the main form view of my model, i inherited the view and modified it for my manager. Hope it helps anyone looking----------

<record  id="inherited_stock_location_view_form_inherit_store_manager_write_access"  model="ir.ui.view">     

<field name="name">inherited.stock.location.inherit.store.form.custom  </field>           

<field name="model">stock.location</field>           

<field name="inherit_id"  ref="shoe_merchandising.inherited_stock_location_view_form_inherit_store" />           

<field name="groups_id"     eval="[(6, 0, [ref('shoe_merchandising.merchandising_group_manager')])]" />           

<field name="arch" type="xml">               

<xpath expr="//field[@name='store_manager_id']" position="attributes">                   

<attribute name="attrs">   {'readonly':[('state','in',['cancel'])]}   </attribute> 

</xpath> 

</field> 

</record>


Avatar
Discard
Related Posts Replies Views Activity
3
Feb 20
14980
2
Aug 24
699
0
Jul 24
119
0
Jan 24
270
3
Sep 23
798