İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
10174 Görünümler

I know by using 

attribute tag we can hide the field in the form

<attribute name="invisible">1<attribute/>

and giving the security groups for the record we can achieve it, like

<field name="groups" eval="[(4,ref('base.group_user'))]"/>

is there any other way to hide the field ?

Avatar
Vazgeç
En İyi Yanıt


You can hide fields depending on the value of other field(s) in the same view. 


for example (see the source):

<field name="valuation" attrs="{'invisible':[('type', 'in', ('service', 'consu'))]}"/>

here, field "valuation" is hidden when value of the "type" field is one of 'service' or 'consu'. You can use more complex domains as well.

So, except of options you listed, there is possibility to hide fields conditionally, based on other field's values.

Avatar
Vazgeç

One more options is "states", used to hide fields/Buttons in a header mainly, see the source

<button name="button_reset_taxes" states="draft,proforma2"
                                        string="(update)" class="oe_link oe_edit_only"
                                        type="object" help="Recompute taxes and total"/>
here states="draft,proforma" means that the button is visible only when document is in the one of "draft" or "proforma2" state. So it's hidden if the document is in different states. You can consider this as one more way hide ( at least for buttons, I have not triedit for field, but it may hide field as well, you can try )

normally you can also manipulate readonly flag for fields, depending on state, not only the visibility

*url for the first comment (copy-paste mistake) see the source here: https://github.com/odoo/odoo/blob/f66fcf97b244ed41a77cd9353e7cba34695c41b4/addons/account/account_invoice_view.xml#L222-L224

İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Mar 15
28615
2
Mar 15
4531
2
Eyl 23
9827
1
Haz 23
2832
1
Haz 16
3888