Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
16283 Visualizações

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
Cancelar
Autor Melhor resposta

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
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
3
fev. 20
16001
2
ago. 24
2346
0
jul. 24
944
0
jan. 24
1167
3
set. 23
2190