Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
3171 Näkymät

I have a one2many field and I want that field to have create="false" attribute when the state is not in draft

I tried to use attrs="{'create': [('state', 'not in', ['draft'])]}"
but it does not work

I can't use readonly because some groups can still edit it, how can I achieve this? Thank you

Avatar
Hylkää
Paras vastaus

Hi,

If you need to have this field editable for some user groups, you can do as follows in the version below 16.0


* in the original view, set the readonly attribute for the field based on the state

* Once this is done, field will be readonly in the state and create wont be visible

* now create an inherited view, and set the user group(for need to be editable always) for this view
* remove readonly attribute for the field from here


By doing this, for normal users the create wont be visible always and for higher group, always it can be edited.


You can see more here: Apply Changes In A View For Particular User Groups In Odoo

Thanks

Avatar
Hylkää
Paras vastaus

Hi,

You can use create: False or no_create; True


eg: <field name="customer_field_id" attrs="{'readonly': [('state','in',['done'])]}"
                                       options="{'no_create': True}"/>

or

options="{'create': [('parent.state', '!=', draft)]}"


  

Hope it helps

Avatar
Hylkää

This doesn't seem to work for tree tag. Is there any way for making create=False for a tree view? The below code doesn't work
<field name="your_one2many_field">
<tree options="{'create': [('parent.state', '!=', draft)]}">.
Please let me know if I'm missing out anything