Reference fields are mainly used to display different model records as a link in your record. For example, you created such a model that when a sales order, purchase order, purchase order, etc. is created and saved, then a new record must be created in your model with data such as username, date, some notes. Thus, here you add a reference field that refers to the original record (sales order, purchase order, etc.) from which your record is created. You can find this in the res.request model in openerp 6
To create a 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) }
source share