from openerp.osv import osv, fields
from datetime import date, timedelta, datetime
-
+# ================================ MESURABLE ================================ #
class Mesurable(osv.Model):
_name = "cmmi.axes.mesurable"
_description = "Table de reference des mesusrables."
- _statuts = [("cree", "Crée"), ("encours", "En cours"),
+ _states = [("cree", "Crée"), ("encours", "En cours"),
("termine", "Terminé"), ("abandonne", "Abandonné"),
("suspendu", "Suspendu"), ("generique", "Générique")]
"name": fields.char(string="Title", size=64, required=True),
"description": fields.text(string="Description"),
"commentaire": fields.text(string="Commentaire"),
- "statut": fields.selection(_statuts, string="Statut"),
+ "state": fields.selection(_states, string="State"),
"version": fields.char(string="Version", size=16),
"date_jalon": fields.date(string="Jalon"),
"date_init_deb": fields.date(string="Init début"),
string="Nombre de jour"),
}
+ _defaults = {
+ "state": "cree",
+ }
+
_sql_constraints = [
(
"date_init_deb_before_date_init_fin",
- "CHECK(date_init_deb<> date_init_fin)",
+ "CHECK(date_init_deb <= date_init_fin)",
"The date_init_deb should be previous date_init_fin",
),
(
"date_plan_deb_before_date_plan_fin",
- "CHECK(date_plan_deb <> date_plan_fin)",
+ "CHECK(date_plan_deb <= date_plan_fin)",
"The date_plan_deb should be previous date_plan_fin",
),
(
"date_reel_deb_before_date_reel_fin",
- "CHECK(date_reel_deb<> date_reel_fin)",
+ "CHECK(date_reel_deb <= date_reel_fin)",
"The date_reel_deb should be previous date_reel_fin",
),
]
-#==================== TRAVAIL CALCUL JOURS OUVRES =============================
+ def commencer(self, cr, uid, ids, context=None):
+ if type(ids) == list:
+ if len(ids) != 1:
+ return # TODO: message d'avertissement
+ ids = ids[0]
+
+ palier = self.read(cr, uid, ids, ['date_plan_deb', 'date_plan_fin', 'state'], context)
+
+ if palier['state'] != 'cree':
+ return
+
+ self.write(
+ cr,
+ uid,
+ ids, {
+ 'date_init_deb' : palier['date_plan_deb'],
+ 'date_init_fin' : palier['date_plan_fin'],
+ 'state': 'encours'
+ },
+ context)
+ return self
+
+
+ def suspendre(self, cr, uid, ids, context=None):
+ if type(ids) == list:
+ if len(ids) != 1:
+ return # TODO: message d'avertissement
+ ids = ids[0]
+ mesurable = self.read(cr, uid, ids, ['state'], context, context)
+ if mesurable['state'] != 'encours':
+ return
+ self.write(
+ cr,
+ uid,
+ ids,
+ {'state': 'suspendu'},
+ context,
+ )
+
+
+
+#------------ TRAVAIL CALCUL JOURS OUVRES ------------
@staticmethod
def _get_date_paques(annee):
"""
tmp += timedelta(days=1)
return jour_ouvres
-#==============================================================================
+# ================================= PALIER ================================== #
class Palier(osv.Model):
_name = "cmmi.axes.palier"
string="Phases"),
}
+ _defaults = {
+ "type_palier": "normal",
+ }
+
def create(self, cr, uid, vals, context=None):
palier_id = osv.Model.create(self, cr, uid, vals, context=context)
'palier_id': palier_id,
}
)
-
return palier_id
+# =============================== PALIER-PHASE ============================== #
class PalierPhase(osv.Model):
_name = "cmmi.axes.palier.phase"
return osv.Model.create(self, cr, uid, vals, context=context)
+
+# ================================ CHANTIER ================================= #
class Chantier(osv.Model):
_name = "cmmi.axes.chantier"