zoukankan      html  css  js  c++  java
  • 通过代码修改视图

    在odoo中, 修改表单视图的传统方法是写xml文件, 继承原有的视图。

    〈 xpath expr='//form[@string="Invoice"]' possition='attributes'〉

    〈!-- Frist intent : nothing happened --〉

    〈attribute name="edit" attrs="{'invisible:[('state','=','paid')]'}"/〉

    <xpath expr='//form[@string="Process Line"]' position='attributes'>
    <attribute name="attrs">{'colors':'gray:line_new == True;'}</attribute>
    </xpath>

    有些模块,比如sales.order,  经过了多次继承, 二次开发时再使用这种方法,会使系统结构更加复杂, 并且还可能与其他的继承方法发生冲突。

    今天在openerp-开发群(69195329)中, 宁波-FEIGAMES(390717298) 介绍了通过python代码修改视图的例子 --重写view_get

    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(rhwl_gene, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) 
    if res['type']=="form": 
    id = res['id'] 
    //根据id去取得资料,并进行判断 
    if 条件成立: 
    doc = etree.XML(res['arch']) 
    doc.xpath("//form")[0].set("edit","false") 
    res['arch']=etree.tostring(doc) 
    return res

  • 相关阅读:
    石子合并之一
    最长公共子序列
    最长上升子序列
    剑圣的逃跑
    方格取数
    数字三角形
    Omkar and Last Class of Math
    IDEA中对代码进行测试
    Spark(一)【spark-3.0安装和入门】
    HTTP请求 Java API
  • 原文地址:https://www.cnblogs.com/chjbbs/p/5305677.html
Copyright © 2011-2022 走看看