From 7c628e589613a91634e7a01a77ba0eac7d1d0d9a Mon Sep 17 00:00:00 2001
From: Benjamin <Benjamin@MBP-de-Benj.(none)>
Date: Sat, 17 Jun 2017 14:03:54 +0200
Subject: [PATCH] [mofif] bouton mise a jour

---
 models/lefilament_tdb.py | 24 +++++++++---------------
 views/views.xml          |  2 +-
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/models/lefilament_tdb.py b/models/lefilament_tdb.py
index 8a4be40..dca371d 100644
--- a/models/lefilament_tdb.py
+++ b/models/lefilament_tdb.py
@@ -38,7 +38,6 @@ class LeFilamentTdb(models.Model):
 				self.env.cr.execute("select sum(amount_untaxed) from account_invoice where state!='draft' and type='out_invoice' and date >= date_trunc('month', %s) and date < date_trunc('month', %s + interval '1' month);", (date_tdb, date_tdb) )
 				ca_mois = self.env.cr.fetchone()[0]
 
-
 				##############    COMMANDES    ################
 				# TOTAL
 				self.env.cr.execute("select sum(amount_untaxed) from sale_order where invoice_status='to invoice' and date_order >= date_trunc('month', %s) and date_order < date_trunc('month', %s + interval '1' month);", (date_tdb, date_tdb) )
@@ -56,8 +55,13 @@ class LeFilamentTdb(models.Model):
 				encaisse = self.env.cr.fetchone()[0]
 
 				##############    CHARGES   ################
-				# self.env.cr.execute("select charges_fixes from res_company" )
-				# charges_fixes = self.env.cr.fetchone()[0]
+				self.env.cr.execute("select charges_fixes from res_company" )
+				charges_fixes = self.env.cr.fetchone()[0]
+
+				##############    PIPE    ################
+				# TOTAL
+				self.env.cr.execute("select sum(planned_revenue*probability/100) from crm_lead where active=True;")
+				pipe = self.env.cr.fetchone()[0]
 
 				if not encaisse:
 					encaisse = 0
@@ -70,18 +74,8 @@ class LeFilamentTdb(models.Model):
 				record.charges = charges * (-1.0)
 				record.encaisse = encaisse
 				record.variation = encaisse + charges
-				# record.charges_fixes = charges_fixes
-				
-	@api.multi
-	def maj_pipe(self):
-		for record in self:
-			##############    PIPE    ################
-			# TOTAL
-			self.env.cr.execute("select sum(planned_revenue*probability/100) from crm_lead where active=True;")
-			pipe = self.env.cr.fetchone()[0]
-
-			record.pipe_mois = pipe
-
+				record.charges_fixes = charges_fixes
+				record.pipe_mois = pipe
 
 
 	@api.multi
diff --git a/views/views.xml b/views/views.xml
index f6c52fd..476f5cf 100644
--- a/views/views.xml
+++ b/views/views.xml
@@ -81,7 +81,7 @@
             <field name="model">lefilament.dashboard</field>
             <field name="arch" type="xml">
                 <header>
-                    <button string="MAJ Pipe" type="object" name="maj_pipe" class="oe_highlight"/>
+                    <button string="MàJ Valeurs" type="object" name="dashboard_values" class="oe_highlight"/>
                 </header>
                 <form string="Liste des Mois">
                     <div class="container">
-- 
GitLab