This question has been flagged

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="{&quot;required&quot;: true}"/> <!-- ############################################################ --> <field name="product_code" modifiers="{&quot;readonly&quot;: true}"/> <!-- ############################################################ --> <field name="state" invisible="True" modifiers="{&quot;tree_invisible&quot;: true}"/> <field name="size_furn" invisible="0" modifiers="{&quot;tree_invisible&quot;: 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="{&quot;required&quot;: true}"/> <!-- ############################################################ --> <field name="product_code" modifiers="{&quot;readonly&quot;: true}"/> <!-- ############################################################ --> <field name="state" invisible="True" modifiers="{&quot;tree_invisible&quot;: true}"/> <field name="size_furn" invisible="1" modifiers="{&quot;tree_invisible&quot;: 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

Avatar
Discard
Best Answer

Try to use setup_modifiers for setting the change in modifiers.

Refer: https://www.odoo.com/forum/help-1/question/openerp-7-issues-fields-view-get-method-29745

Avatar
Discard
Author Best Answer

i imported from openerp.osv.orm import setup_modifiers  and added line

setup_modifiers(node, res['fields']['size_furn']) but same problem.

 

Avatar
Discard