Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
10346 Widoki

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 ?

Awatar
Odrzuć
Najlepsza odpowiedź


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.

Awatar
Odrzuć

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

Powiązane posty Odpowiedzi Widoki Czynność
3
mar 15
28864
2
mar 15
4721
2
wrz 23
10002
1
cze 23
2993
1
cze 16
4022