"commentaire": fields.text(string="Commentaire"),
"keywords": fields.text(string="Mots clés"),
"priorite": fields.selection(_priorites, string="Priorité"),
- "statut": fields.selection(_statuts, string="Statut"),
+ "state": fields.selection(_statuts, string="Statut"),
# "charges": fields.one2many("cmmi.evolution.charge", # Supprimé !
# "evolution_id",
# string="Charges"),
domain=_domains['human']),
}
+ _defaults = {
+ "state": "cree",
+ }
-# ================================== PHASE ================================== #
+ 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]
+
+ 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"
return osv.Model.create(self, cr, uid, vals, context=context)
-# ================================== CHARGE ================================= #
+# =========================== EVOLUTION CHARGE ============================== #
class Charge(osv.Model):
_name = "cmmi.evolution.charge"
<field name="model">cmmi.evolution</field>
<field name="arch" type="xml">
<form string="Formulaire évolution" version="7.0">
- <header />
+ <header>
+ <button string="Commencer" type="object" name="action_commencer" states="cree" class="oe_highlight" />
+ <button string="Suspendre" type="object" name="action_suspendre" states="encours" class="oe_highlight" />
+ <button string="Terminer" type="object" name="action_terminer" states="encours" class="oe_highlight" />
+ <button string="Abandonner" type="object" name="action_abandonner" states="encours,cree" class="oe_highlight" />
+ <button string="Reprendre" type="object" name="action_reprendre" states="suspendu" class="oe_highlight" />
+ </header>
<sheet>
<group colspan="4" col="3">
<field name="name" colspan="3"/>
<field name="pid" colspan="3"/>
<field name="priorite" colspan="3"/>
- <field name="statut" colspan="3"/>
+ <field name="state" colspan="3"/>
</group>
<notebook colspan="4">
<page string="Détails">