Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


How to hide a field on a one2many?

Anirudh Lou
on 6/10/15, 12:17 AM 615 views

I have customize the sale order menu in openerp making it into two menus named as "Local" and the other one is "Export".

I add some field at sale.order class:

'is_local' : fields.boolean('Local'), #Default as true if user clicked the Local menu.

'is_export' : fields.boolean('Export'), #Default as true if user clicked the Export menu.

and at sale.order.line class:

'is_local' : fields.related('order_id','is_local',type='boolean',string='Local',store=True)

'is_export' : fields.related('order_id','is_export',type='boolean',string='Export',store=True)

'length' : fields.float('Length', digits=(12,2)),

'width' : fields.float('Width', digits=(12,2)),

'height' : fields.float('Height', digits=(12,2)),

The situation is this, if i will click the Local menu, the fields: length, width, and height at sale.order.line must be hide on the view.

I did this on my sale_order view:

<field name="order_line" context="{'default_is_local': local}"/>

<tree string="Order line">

<field name="is_local"/>

<field name="length" invisible="context.get('is_local',True)"/>

. . .


Using invisible="context.get('is_local',True)", its problem is that it also hide the field if i choose the export menu w/c is not supposed to be hide. When i use attrs="{'invisible':[('is_local','=',True)]}" it doesn't hide the field both on Local and Export Menu. I don't know what technique is to be use.

I am using openerp v7

Any help is much appreciated!

Turkesh Patel
On 6/10/15, 2:18 AM

May be there can be issue is here

<field name="order_line" context="{'default_is_local': is_local)}"/> instead of local put is_local

<field name="length" invisible="context.get('is_local')"/> do not pass default True

Ah sorry, that was a typo error. it is is_local not local.

Anirudh Lou
on 6/10/15, 2:31 AM

and is_local field is there in your form view?

Turkesh Patel
on 6/10/15, 3:04 AM


Anirudh Lou
on 6/10/15, 3:52 AM

ohky do it like this

Turkesh Patel
on 6/10/15, 3:55 AM

pass this context context="{'default_is_local': is_local, 'is_local': is_local)}" instead of context="{'default_is_local': is_local)}"

Turkesh Patel
on 6/10/15, 3:56 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 6/10/15, 12:17 AM
Seen: 615 times
Last updated: 6/10/15, 2:18 AM