("termine", "Terminé"), ("abandonne", "Abandonné"),
("suspendu", "Suspendu")]
+
+ def _get_charge_init(self, cr, uid, ids, field, arg, context=None):
+ result = {}
+ for evo in self.browse(cr, uid, ids, context=context):
+ result[evo.id] = sum([p.charge_init for p in evo.phases])
+ return result
+
+
+ def _get_charge_plan(self, cr, uid, ids, field, arg, context=None):
+ result = {}
+ for evo in self.browse(cr, uid, ids, context=context):
+ result[evo.id] = sum([p.charge_plan for p in evo.phases])
+ return result
+
+ def _get_charge_reel(self, cr, uid, ids, field, arg, context=None):
+ result = {}
+ for e in self.browse(cr, uid, ids, context=context):
+ result[e.id] = sum([p.quantite for p in e.charge_reel])
+ return result
+
+
_columns = {
"pid": fields.integer(string="PID"),
"name": fields.char(string="Title", size=64, required=True),
"commentaire": fields.text(string="Commentaire"),
"keywords": fields.text(string="Mots clés"),
"priorite": fields.selection(_priorites, string="Priorité"),
- "statut": fields.selection(_statuts, string="Statut"),
-# "charges": fields.one2many("cmmi.evolution.charge", # Supprimé !
-# "evolution_id",
-# string="Charges"),
+ "state": fields.selection(_statuts, string="Statut"),
+ "phases": fields.one2many("cmmi.evolution.phase",
+ "evolution_id",
+ string="Phases"),
# Backrefs
"module_id": fields.many2one("cmmi.description.module",
string="Modules"),
"demandeur": fields.many2one("res.partner",
string="Demandeur",
domain=_domains['human']),
+ # Functions
+ "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 réelle"),
}
+ _defaults = {
+ "state": "cree",
+ }
+
+ def action_commencer(self, cr, uid, ids, context=None):
+ if type(ids) == list:
+ if len(ids) != 1:
+ return # TODO: message d'avertissement
+ ids = ids[0]
+
+ evo = self.read(cr, uid, ids, ['state'], context)
+
+ if evo['state'] != 'cree':
+ return
+ self.write(
+ cr,
+ uid,
+ ids,
+ {'state': 'encours'},
+ context,
+ )
+ return self
+
+ def action_suspendre(self, cr, uid, ids, context=None):
+ if type(ids) == list:
+ if len(ids) != 1:
+ return # TODO: message d'avertissement
+ ids = ids[0]
+
+ evo = self.read(cr, uid, ids, ['state'], context)
+ if evo['state'] != 'encours':
+ return
+ self.write(
+ cr,
+ uid,
+ ids,
+ {'state': 'suspendu'},
+ context,
+ )
+ return self
+
+ def action_terminer(self, cr, uid, ids, context=None):
+ if type(ids) == list:
+ if len(ids) != 1:
+ return # TODO: message d'avertissement
+ ids = ids[0]
-# ================================== PHASE ================================== #
+ evo = self.read(cr, uid, ids, ['state'], context)
+ if evo['state'] != 'encours':
+ return
+ self.write(
+ cr,
+ uid,
+ ids,
+ {'state': 'termine'},
+ context,
+ )
+ return self
+
+ def action_abandonner(self, cr, uid, ids, context=None):
+ if type(ids) == list:
+ if len(ids) != 1:
+ return # TODO: message d'avertissement
+ ids = ids[0]
+
+ evo = self.read(cr, uid, ids, ['state'], context)
+
+ if not ('encours', 'cree').__contains__(evo['state']):
+ return
+ self.write(
+ cr,
+ uid,
+ ids,
+ {'state': 'abandonne'},
+ context,
+ )
+ return self
+
+ def action_reprendre(self, cr, uid, ids, context=None):
+ if type(ids) == list:
+ if len(ids) != 1:
+ return # TODO: message d'avertissement
+ ids = ids[0]
+
+ evo = self.read(cr, uid, ids, ['state'], context)
+
+ if evo['state'] != 'suspendu':
+ return
+ self.write(
+ cr,
+ uid,
+ ids,
+ {'state': 'encours'},
+ context,
+ )
+ return self
+
+
+# =========================== EVOLUTION PHASE =============================== #
class Phase(osv.Model):
_name = "cmmi.evolution.phase"
store=True,
string="Nom de la phase"),
"description": fields.text(string="Description"),
+ "charge_init": fields.integer(string="Charge initiale"),
+ "charge_plan": fields.integer(string="Charge plannifiée"),
"phase_id": fields.many2one("cmmi.axes.palier.phase",
string="Phase"),
"evolution_id": fields.many2one("cmmi.evolution",
return osv.Model.create(self, cr, uid, vals, context=context)
+ def commencer(self, cr, uid, ids, context=None):
+ if type(ids) == list:
+ if len(ids) != 1:
+ return
+ ids = ids[0]
+
+ phase = self.read(cr, uid, ids, ['charge_plan'], context)
+
+ self.write(
+ cr,
+ uid,
+ ids, {
+ 'charge_init' : phase['charge_plan'],
+ },
+ context)
+ return self
-# ================================== CHARGE ================================= #
+
+# =========================== EVOLUTION CHARGE ============================== #
class Charge(osv.Model):
_name = "cmmi.evolution.charge"
_description = "Charge d'une evolution."
+ _selection_qte = [("0.25", "1/4"),
+ ("0.5", "1/2"),
+ ("0.75", "3/4")]
+
_columns = {
"name": fields.char(string="Title", size=64, required=True),
"description": fields.text(string="Description"),
- "evolution_id": fields.many2one("cmmi.evolution",
- string="Palier"),
+ "date": fields.date(string="Date"),
+ "quantite": fields.selection(_selection_qte, string="Quantité"),
"phase_id": fields.many2one("cmmi.evolution.phase",
string="Phase de l'évolution",
required=True),