@api.model def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False): """ Changes the view dynamically @param self: The object pointer. @return: New arch of view. """
# 首先执行父类的方法,以保证父类的方法能顺利进行,然后再进行自定义的方法的创建
result = super(ExtentPartnerBank, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu) if view_type == 'form': # 如果类型为form才能动态创建按钮 # result = etree.XML(ret_val['arch'], parser=None, base_url=None) # 判断是否存在<header> # root = etree.fromstring(result['arch']) root = etree.XML(result['arch']) print('******',result['arch']) footers = root.xpath("//sheet/group//field[@name='字段名']")[0] # 字段名在视图中是必须有的
#if not footers: # header = etree.Element('group') # root.insert(len(header), header) # header = etree.SubElement(root, "button") # 创建并插入节点 #else: # header = footers[0] # 重新提交 # MainElement = ET.Element("MainElement") # subelement = ET.SubElement(MainElement, "subelement") # sub_subelement = ET.SubElement(subelement, "sub-subelement") dd_submit_button = etree.Element("button") dd_submit_button.set('string', u'提交审批') dd_submit_button.set('class', 'oe_highlight') dd_submit_button.set('position', 'before') dd_submit_button.set('type', 'object') dd_submit_button.set('name', 'commit_hyper_approve') dd_submit_button.set('confirm', '确认提交审批吗?') # setup_modifiers(dd_submit_button, result['fields']) # 设置审批按钮的 隐藏条件 # dd_submit_button.set('modifiers', '{"invisible": [["hyper_approve_state", "!=", "wait_start"]]}') header.addnext(dd_submit_button) result['arch'] = etree.tostring(root) return result
标签:set,模型,submit,生成,dd,result,按钮,button,view From: https://www.cnblogs.com/lyt263/p/17043732.html