我试图从OpenERP的web gui和字段类型创建一个字段作为参考1没有更好的文档参考
第二个我想要的是当有人选择该字段时它应该给出选择的另一个选项没有发生(虽然它给了一些字段,但第二个字段引发错误)!
它抛出一个错误对象不存在
参考字段主要用于在记录中显示不同模型的记录作为参考.例如,您创建了一个模型,无论何时创建并保存销售订单,采购订单,交货单,项目等,都应在模型中创建包含用户名,日期,某些注释等数据的新记录.因此,在此处添加一个引用字段,该字段链接到创建记录的原始记录(销售订单,采购订单等).你可以在openerp 6中的res.request模型中找到它
在班级中创建参考字段
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)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3030 次 |
| 最近记录: |