I have many2one fields in one class. I have to auto fill this fields. I have written an on change function to auto fill. But the auto filled value are ID since it is a many2one field. How can I get the value in the many2one field.
First class:
class vansdent(osv.osv):
_name = "vans.dent"
_description = "Vans Dent"
_rec_name = 'service'
_description = "Vals Dent"
_columns = {
'year': fields.many2one('dent.year', 'Year', required=True, select=True),
'make': fields.many2one('vals.make','Make', required=True),
'model': fields.many2one('car.model','Model', required=True, select=True),
'service': fields.char('Service ID', required=True),
'customer': fields.char('Customer', required=True),
}
Second class:
class vansdent_bill(osv.osv):
_name = "vansdent.bill"
_description = "Vans Dent"
_columns = {
'name': fields.char('Year', required=True),
'make': fields.char('Make', required=True),
'model': fields.char('Model', required=True),
'customer': fields.char('Customer', required=True),
'serviceid': fields.many2one('vans.dent', 'Service ID', select=True),
}
Onchange function:
def vansdent_service(self, cr, uid, ids, serviceid=False, context=None):
res = {}
if serviceid:
service_obj = self.pool.get('vans.dent')
rec = service_obj.browse(cr, uid, serviceid)
res = {'value': {'name': rec.year, 'model': rec.model, 'make': rec.make, 'customer':rec.customer}}
else:
res = {'value': {'name': False, 'model': False, 'make': False, 'customer': False}}
return res
XML :
<field name="serviceid" on_change="vansdent_service(serviceid)"/>
The auto fill value is filled with
dent.year(1,)
vals.make(123,)
car.model(144,)
How can I solve this?
I see in table that in many2one field the value is saved as ID number not as values. How can I save the many2one value as the value shown in UI and not as ID number in table