Odoo Help

Welcome!

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.

0

Field not hiding from tree view using Fields_view_get

By
Saghir A. Khatri
on 1/12/15, 4:23 AM 2,743 views

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

0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3918
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 1/12/15, 4:48 AM

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

0
Saghir A. Khatri
On 1/12/15, 5:17 AM

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

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

 

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)

Stats

Asked: 1/12/15, 4:23 AM
Seen: 2743 times
Last updated: 3/16/15, 8:10 AM