Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
10173 Zobrazení

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
Zrušit
Nejlepší odpověď


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
Zrušit

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

Related Posts Odpovědi Zobrazení Aktivita
3
bře 15
28615
2
bře 15
4531
2
zář 23
9827
1
čvn 23
2832
1
čvn 16
3887