Odoo 中文社区

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

    Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

    由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

    本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

    开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

    如果您登录系统碰到问题,请在微信公众号留言:

    請教關於many2one欄位畫面資料顯示的問題

    Odoo 新手求助
    2
    4
    2178
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kk071700 last edited by

      例如我自定義一個Table,其中有一個many2one的欄位要referance到product.product
      然後在OperERP顯示該自定義Table的view時,
      我希望該many2one的欄位顯示在畫面上的是product.product中我指定顯示的欄位(例如name_template)
      (當然在該many2one的欄位存放的是對應product.product的id)

      請教大大該如何設定 感恩

      1 Reply Last reply Reply Quote 0
      • digitalsatori
        digitalsatori 管理员 last edited by

        两个方法:
        1. 再建一个fields.related字段,比如:
        fields.related('product_id', 'name_template', type='char', string='Name')
        2. 覆写product.product的name_get方法,并在view中指定context,比如在view中设置context={'name_template':1}
        def name_get(self, cr, uid, ids, context=None):
            if context.get('name_template'):
                XXXX #取需要的值,并返回
            else:
                return super(....).name_get(....)

        【上海先安科技】(tony AT openerp.cn)

        1 Reply Last reply Reply Quote 0
        • K
          kk071700 last edited by

          感恩digitalsatori大不吝指點 謝謝

          [quote author=digitalsatori link=topic=2940.msg9936#msg9936 date=1337663863]
          两个方法:
          1. 再建一个fields.related字段,比如:
          fields.related('product_id', 'name_template', type='char', string='Name')
          2. 覆写product.product的name_get方法,并在view中指定context,比如在view中设置context={'name_template':1}
          def name_get(self, cr, uid, ids, context=None):
              if context.get('name_template'):
                  XXXX #取需要的值,并返回
              else:
                  return super(....).name_get(....)
          [/quote]

          1 Reply Last reply Reply Quote 0
          • First post
            Last post