Odoo Help

0

Odoo Dymanically Inheriting Product From View

By
Ashish Singh
on 6/6/15, 12:50 AM 1,079 views

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


3
Axel Mendoza
On 9/3/15, 8:41 PM

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)
0
Adnier Rosello
On 9/3/15, 6:26 PM

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

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 6/6/15, 12:50 AM
Seen: 1079 times
Last updated: 9/7/15, 2:40 PM