【问题标题】:OpenERP Function Many2One with two values (like Value1 | Value2)OpenERP 函数 Many2One 有两个值(如 Value1 | Value2)
【发布时间】:2013-09-19 09:38:03
【问题描述】:

由于Many2one字段只显示一个字段,我想写一个函数在Many2one中显示两个字段,像这样:

def get_services(self, cr, uid, ids, context=None):
        values = cr.execute("""SELECT name, entity
                            FROM services WHERE id = 3""")
        values.fetchall()
        for value__ in values:
            if value__:
                return {'value': {'service_id': value__[0] + " | " + value__[1]},} # Example: "Service 1 | Google"

首先,这可能吗?有没有这样做的模块?所以我可以看到它。

然后,我这样调用函数:

_columns = {
        'service_id':fields.function(get_services, type = 'many2one', obj = 'services_getservices_function', method = True, string = 'Service'),

我没有收到任何错误,但该字段未显示在屏幕上。

【问题讨论】:

    标签: function field openerp


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      解决了。

      我创建了另一个包含名称和实体的字段。

      'name_plus_entity':fields.char('All', size = 300),
      

      然后我创建了一个函数“onchange”,所以每当字段“name”或字段“entity”发生变化时,字段“name_plus_entity”会得到:“name”+“|”+entity。

      另外,我在 XML 表单中隐藏了“name_plus_entity”字段。

      【讨论】:

        猜你喜欢
        • 2020-01-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多