0 down vote favorite
I have written a code to update my treeview according to input. it is basically working using context. My fields_view_get method is like this:
def fields_view_get(self,cr,uid,view_id=None,view_type='form',context=None, toolbar=False, submenu=False): if context is None: context={} res=super(product_product,self).fields_view_get(cr,uid,view_id=view_id,view_type=view_type,context=context,toolbar=toolbar,submenu=submenu) doc=etree.XML(res['arch']) if context.get('parent',False): parent=context.get('parent',False) if parent==85: ####Vehicle print etree.tostring(doc,pretty_print=True) for node in doc.xpath("//field[@name='size_furn']"): node.set('invisible','1') res['arch']=etree.tostring(doc) print "\n\n\n\nxml ",res['arch'] return res
Here i am updating visibility of size_furn
I have printed output on console. here is res['arch'] before change
<tree colors="red: state in ('draft', 'end', 'obsolete');black: state not in ('draft', 'end', 'obsolete')" string="Asset Products"> <!-- <field name="default_code"/> --> <field name="name" modifiers="{"required": true}"/> <!-- ############################################################ --> <field name="product_code" modifiers="{"readonly": true}"/> <!-- ############################################################ --> <field name="state" invisible="True" modifiers="{"tree_invisible": true}"/> <field name="size_furn" invisible="0" modifiers="{"tree_invisible": false}"/> </tree>
here is the changes on res['arch']
<tree colors="red: state in ('draft', 'end', 'obsolete');black: state not in ('draft', 'end', 'obsolete')" string="Asset Products"> <!-- <field name="default_code"/> --> <field name="name" modifiers="{"required": true}"/> <!-- ############################################################ --> <field name="product_code" modifiers="{"readonly": true}"/> <!-- ############################################################ --> <field name="state" invisible="True" modifiers="{"tree_invisible": true}"/> <field name="size_furn" invisible="1" modifiers="{"tree_invisible": false}"/> </tree>
As we can see xml is updating, but problem is changes are not visible on openerp application. I can view this field in any case. i tried to use True and False too. but it didnot work. any way to resolve this issue.
Thanks