zoukankan      html  css  js  c++  java
  • 如何让同一个字段在不同的view中显示不同的内容

    many2one 字段默认显示 对象的name字段,

    但也可以定义name_get方法显示不同的内容

    如res.partner 对象可以根据 context 内容是否显示 客户的地址,职位,email 等其他信息,

    例如下面的代码中 可以显示客户的 地址信息。 if context.get('show_address').

        def name_get(self, cr, uid, ids, context=None):
            if context is None:
                context = {}
            if isinstance(ids, (int, long)):
                ids = [ids]
            res = []
            for record in self.browse(cr, uid, ids, context=context):
                name = record.name
                if record.parent_id and not record.is_company:
                    name =  "%s, %s" % (record.parent_id.name, name)
                if context.get('show_address'):
                    name = name + "
    " + self._display_address(cr, uid, record, without_company=True, context=context)
                    name = name.replace('
    
    ','
    ')
                    name = name.replace('
    
    ','
    ')
                if context.get('show_email') and record.email:
                    name = "%s <%s>" % (name, record.email)
                res.append((record.id, name))
            return res
    

      

    ~~~~~~~ 需要odoo 实施,二开,培训 等服务 QQ:190170444
  • 相关阅读:
    手机发送验证码—.net代码
    AJAX之XMLHttpRequest
    JQuery总结+实例
    ASP.NET总结——更改后
    css总结——position
    JavaScript的程序构成
    初识javascript
    asp总结
    北大青鸟代码---asp.net初学者宝典
    iOS常用技术-Label自适应
  • 原文地址:https://www.cnblogs.com/alangwansui/p/3507236.html
Copyright © 2011-2022 走看看