Skip to Content
Menu
This question has been flagged
1 Atsakyti
16276 Rodiniai

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?

Portretas
Atmesti
Autorius 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>


Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
3
vas. 20
16000
2
rugp. 24
2343
0
liep. 24
943
0
saus. 24
1166
3
rugs. 23
2188