Ajout d'un champ charge_reel dans palier
[OpenERP/cmmi.git] / axes.py
diff --git a/axes.py b/axes.py
index eeb2073..aa5a83f 100644 (file)
--- a/axes.py
+++ b/axes.py
@@ -292,6 +292,13 @@ class Palier(osv.Model):
         return result
 
 
+    def _get_charge_reel(self, cr, uid, ids, field, arg, context=None):
+        result = {}
+        for p in self.browse(cr, uid, ids, context=context):
+            result[p.id] = sum([e.charge_reel for e in p.evolutions])
+        return result
+
+
     _columns = {
         "type_palier": fields.selection(_types_palier, string="Type"),
         "projet_id": fields.many2one("cmmi.projet",
@@ -309,6 +316,9 @@ class Palier(osv.Model):
         "charge_plan": fields.function(_get_charge_plan,
                                        type="integer",
                                        string="Charge plannifiée"),
+        "charge_reel": fields.function(_get_charge_reel,
+                                       type="integer",
+                                       string="Charge réelle"),
     }
 
     _defaults = {
@@ -371,6 +381,12 @@ class PalierPhase(osv.Model):
             result[pp.id] = sum([p.charge_plan for p in pp.phases])
         return result
 
+    def _get_charge_reel(self, cr, uid, ids, field, arg, context=None):
+        result = {}
+        for pp in self.browse(cr, uid, ids, context=context):
+            result[pp.id] = sum([c.quantite for c in pp.charges])
+        return result
+
 
     _columns = {
         "name": fields.function(_get_name,
@@ -381,6 +397,15 @@ class PalierPhase(osv.Model):
                                     string="Phase du projet"),
         "palier_id": fields.many2one("cmmi.axes.palier",
                                      string="Palier"),
+        "charge_init": fields.function(_get_charge_init,
+                                       type="integer",
+                                       string="Charge initiale"),
+        "charge_plan": fields.function(_get_charge_plan,
+                                       type="integer",
+                                       string="Charge plannifiée"),
+        "charge_reel": fields.function(_get_charge_reel,
+                                       type="integer",
+                                       string="Charge plannifiée"),
         # backrefs
         "charges": fields.one2many("cmmi.evolution.charge",
                                    "phase_id",
@@ -427,6 +452,13 @@ class Chantier(osv.Model):
         return result
 
 
+    def _get_charge_reel(self, cr, uid, ids, field, arg, context=None):
+        result = {}
+        for c in self.browse(cr, uid, ids, context=context):
+            result[c.id] = sum([e.charge_reel for e in c.evolutions])
+        return result
+
+
     _columns = {
         "projet_id": fields.many2one("cmmi.projet",
                                      string="Projet",
@@ -445,4 +477,7 @@ class Chantier(osv.Model):
         "charge_plan": fields.function(_get_charge_plan,
                                        type="integer",
                                        string="Charge plannifiée"),
+        "charge_reel": fields.function(_get_charge_reel,
+                                       type="integer",
+                                       string="Charge réelle"),
     }