diff --git a/models/project.py b/models/project.py index 3f15c05fcc268b87fb3bada2e57876fa82378455..99888ac09a95f56fce3cbee2ac7e038d5d5804f2 100644 --- a/models/project.py +++ b/models/project.py @@ -40,28 +40,26 @@ class FilamentProjet(models.Model): @api.one def _total_heures_prospection(self): - res = 0.0 project = self.id + self.lf_heures_prospection = 0.0 ## Calcul heures - self.env.cr.execute("select sum(aal.unit_amount) from account_analytic_line aal, project_task pt where aal.project_id=%s and pt.name='Prospection' and pt.id=aal.task_id;", (project, ) ) - heures_prospection = self.env.cr.fetchone()[0] - if heures_prospection: - self.lf_heures_prospection = heures_prospection - else: - self.lf_heures_prospection = 0.0 + if self.use_prospection: + self.env.cr.execute("select sum(aal.unit_amount) from account_analytic_line aal, project_task pt where aal.project_id=%s and pt.name like 'Prospection' and pt.id=aal.task_id;", (project, ) ) + heures_prospection = self.env.cr.fetchone()[0] + if heures_prospection: + self.lf_heures_prospection = heures_prospection @api.one def _total_heures_passees(self): - res = 0.0 - project = self.id + project = self.id + self.lf_heures_passees = 0.0 ## Calcul heures self.env.cr.execute("select sum(unit_amount) from account_analytic_line where project_id=%s;", (project, ) ) heures_passees = self.env.cr.fetchone()[0] if heures_passees: self.lf_heures_passees = heures_passees - else: - self.lf_heures_passees = 0.0 - + if self.use_prospection: + self.lf_heures_passees -= self.lf_heures_prospection @api.one def _total_heures_planifiees(self):