콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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


아바타
취소
베스트 답변

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)
아바타
취소
베스트 답변

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

아바타
취소
관련 게시물 답글 화면 활동
4
10월 22
8358
1
4월 15
4054
3
9월 24
4916
2
9월 23
10439
1
5월 23
3293