From dd24e1c8689c5c483837b497d7704fe2cc68cb06 Mon Sep 17 00:00:00 2001
From: Benjamin <Benjamin@MBP-de-Benj.(none)>
Date: Mon, 17 Jul 2017 11:33:38 +0200
Subject: [PATCH] [fix] erreur calcul heures

---
 lefilament_projets.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lefilament_projets.py b/lefilament_projets.py
index 7220205..f57e2d4 100644
--- a/lefilament_projets.py
+++ b/lefilament_projets.py
@@ -26,9 +26,15 @@ class SapovalPartners(models.Model):
 	@api.one
 	def _total_heures_passees(self):
 		res = 0.0
-		for record in self.task_ids:
-			res = res + record.effective_hours
-		self.lf_heures_passees = res
+		account = self.analytic_account_id.id		
+		##############    Calcul couts annexes   ################
+		self.env.cr.execute("select sum(unit_amount) from account_analytic_line where is_timesheet=TRUE and account_id=%s;", (account, ) )
+		heures_passees = self.env.cr.fetchone()[0]
+		if heures_passees:
+			self.lf_heures_passees = heures_passees
+		else:
+			self.lf_heures_passees = 0.0
+
 
 	@api.one
 	def _total_heures_planifiees(self):
-- 
GitLab