Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
16284 Prikazi

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
Opusti
Avtor 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
Opusti
Related Posts Odgovori Prikazi Aktivnost
3
feb. 20
16001
2
avg. 24
2346
0
jul. 24
944
0
jan. 24
1167
3
sep. 23
2190