hello
please ! I need your help I want to add a fields.function 'cost' in my object that returns the sum of two fields from an other object "vehicule". I tried with this code but it seems not working " ProgrammingError: can't adapt type 'dict' "
class location_location(osv.osv):
_name = 'location.location'
def get_total(self, cr, uid, ids, values, arg, context):
x={}
for record in self.browse(cr, uid, ids):
x[record.id]= record.vehicule_id.tarif_id.prixjournalier + record.vehicule_id.tarif_id.prixhebdomadaire
return x
_columns = {
'name': fields.char('ID',size=32,required=True),
'vehicule_id': fields.many2one('vehicule.vehicule','Véhicule',required=True),
'cost' : fields.function(get_total, method=True, string='Total',type='float'),
}
location_location()
class vehicule_vehicule(osv.osv):
_name = 'vehicule.vehicule'
_columns = {
'name': fields.char('ID', size=32, required=True, help='L\'identifiant du véhicule '),
'modele_id': fields.many2one('vehicule.modele','Modéle'),
'tarif_id': fields.many2one('vehicule.tarif','Tarif de location'),
}
vehicule_vehicule()
class vehicule_tarif(osv.osv):
_name = 'vehicule.tarif'
_columns = {
'name': fields.char('ID', size=32, required=True),
'prixjournalier': fields.integer('Prix journalier'),
'prixhebdomadaire': fields.integer('Prix hebdomadaire'),
}
vehicule_tarif()
the value calculated will appear in the tree as "cost" please what I can do ?
where is your vehicule model table?