I'm trying to assigned value to 'hours' toward a compute fuction but this fall in an error. here is the code:
class fly_personne(models.Model):
_name = 'fly.personne'
_inherit = 'fly.pers'
_description = "personne"
def calculTemps(self):
sql1 = "select sum(b.hours) from fly_ligne_personne a, fly_vol b where a.vol_id = b.id and a.pilote_id = '%s' GROUP BY a.pilote_id ;" % self.id
self.env.cr.execute(sql1)
rec.update({'hours': self.env.cr.fetchall()})
hours = fields.Char('Temps de vol', compute='calculTemps')
2) also is it possible to return more than one value for the sql ?
ex: doing something like:
...
sql1 = "select sum(b.hours), sum(b.minutes), a.pers_id from ...
self.env.cr.execute(sql1)
rec.update({'hours': self.env.cr.fetchall()})
rec.update({'minutes': ?????})
rec.update({'pers_id': ????})
hours = fields.Char('Temps de vol', compute='calculTemps')
minutes= fields.Char('mn de vol', compute='calculTemps')
pers_id= fields.Char('id pers', compute='calculTemps')
Odoo Customization Tips: https://learnopenerp.tumblr.com/