This question has been flagged
1 Reply
6002 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)"/>

. . .

</field>

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!

Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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

and is_local field is there in your form view?

Author

yes.

ohky do it like this

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