如何在OpenERP 6中创建参考字段 [英] How to create a reference field in OpenERP 6

查看:76
本文介绍了如何在OpenERP 6中创建参考字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从OpenERP的Web gui创建一个字段,并将字段类型作为参考 第一,没有关于参考的更好的文档

I am trying to create a field from the web gui of OpenERP and field type as reference 1st there is no better docs about reference

第二个我想要的是,当有人选择该字段时,它应该为未发生的选择提供另一种选择(尽管它提供了一些字段,但是第二个字段抛出错误)!

2nd what I want is when someone selects the field it should give another option on selection which is not happening (though it is giving some field but 2nd field throws an error)!

它抛出一个不存在的错误对象

It throws an error object does not exist

推荐答案

参考字段主要用于显示不同模型的记录,以作为记录中的参考.例如,您已经创建了一个模型,以便每当创建并保存销售订单,采购订单,交货订单,项目等时,都应在模型中创建一条包含用户名,日期和一些注释之类的数据的新记录.因此,您在此处添加一个参考字段,该参考字段链接到创建记录的原始记录(销售订单,采购订单等).您可以在openerp 6的res.request模型中找到它

Reference fields are mainly used for showing different model's records as reference in your record. For example you have created a model such that whenever a sale order, purchase order, delivery order, project etc are created and saved, then a new record with data like user name, date, some notes should be created in your model. So here you add a reference field which link to the original record(sale order, purchase order etc) from which your record is created. You can find this in res.request model in openerp 6

要在您的班级中创建参考字段

To create an reference field in your class

def _get_selection_list(self, cr, uid, context=None):
    #@return a list of tuples. tuples containing model name and name of the record
    model_pool = self.pool.get('ir.model')
    ids = model_pool.search(cr, uid, [('name','not ilike','.')])
    res = model_pool.read(cr, uid, ids, ['model', 'name'])
    return [(r['model'], r['name']) for r in res] +  [('','')]

_columns = {
    'ref': fields.reference(Reference', selection=_get_selection_list, size=128)
} 

这篇关于如何在OpenERP 6中创建参考字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆