4

我正在尝试从 OpenERP 的 web gui 和字段类型创建一个字段作为参考 1st 没有更好的参考文档

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

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

4

1 回答 1

7

参考字段主要用于在您的记录中显示不同模型的记录作为参考。例如,您创建了一个模型,每当创建和保存销售订单、采购订单、交货单、项目等时,就应该在您的模型中创建一个包含用户名、日期等数据的新记录。因此,您可以在此处添加一个参考字段,该字段链接到创建记录的原始记录(销售订单、采购订单等)。您可以在 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)
} 
于 2012-12-04T09:12:06.373 回答