跳至内容
菜单
此问题已终结
1 回复
16280 查看

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?

形象
丢弃
编写者 最佳答案

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>


形象
丢弃
相关帖文 回复 查看 活动
3
2月 20
16001
2
8月 24
2345
0
7月 24
944
0
1月 24
1167
3
9月 23
2190