Skip to Content
Menu
This question has been flagged

Hello Guys

I want to add new Page tab in Product Form View Dynamically With the help of field_view_get() Method


class product_product(osv.osv):
_inherit = 'product.product'
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False):
"""
Changes the view dynamically
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return: New arch of view.
"""
ret_val = super(product_product, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
if view_type == 'form':
#doc = etree.XML(res['arch'])
doc = etree.XML(ret_val['arch'], parser=None, base_url=None)
_moves_arch_lst = """
<page string='Feature'>
</page>    
"""
first_node = doc.xpath("//page[@string='Sales']")
            if first_node and len(first_node)>0: 
              #<What Code should I have to write so My Page tab will appear in Product From View>         ret_val['arch'] = etree.tostring(doc, encoding="utf-8")
        return ret_val


Avatar
Discard
Best Answer

You need to attach your new page node to the first_node that you found like:

#supposing that the page feature is the one you need to attach to the notebook
feature_page = etree.XML(_moves_arch_lst)
first_node.addnext(feature_page)
Avatar
Discard
Best Answer

Hello, I need to do exactly the same for personalize a module, you have the solution to this post, thanks

Avatar
Discard
Related Posts Replies Views Activity
4
Oct 22
6851
1
Apr 15
2887
3
Sep 24
1870
2
Sep 23
8067
1
May 23
1777