From 8f8739bd4b8d87bd6a9920f0b4d25df7f2845e82 Mon Sep 17 00:00:00 2001 From: Alicia FLOREZ Date: Mon, 3 Jun 2013 18:26:07 +0200 Subject: [PATCH] =?utf8?q?Ajout=20d'un=20bouton=20lan=C3=A7ant=20un=20palier?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- axes.py | 27 ++++++++++++++++++++++++++- views/palier.xml | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/axes.py b/axes.py index 7d638cb..0c78468 100644 --- a/axes.py +++ b/axes.py @@ -44,6 +44,10 @@ class Mesurable(osv.Model): string="Nombre de jour"), } + _defaults = { + "statut": "cree", + } + _sql_constraints = [ ( "date_init_deb_before_date_init_fin", @@ -63,6 +67,28 @@ class Mesurable(osv.Model): ] + 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', 'statut'], context) + + if palier['statut'] != 'cree': + return + + self.write( + cr, + uid, ids, { + 'date_init_deb' : palier['date_plan_deb'], + 'date_init_fin' : palier['date_plan_fin'], + 'statut': 'encours' + }, + context) + return self + + #------------ TRAVAIL CALCUL JOURS OUVRES ------------ @staticmethod def _get_date_paques(annee): @@ -182,7 +208,6 @@ class Palier(osv.Model): 'palier_id': palier_id, } ) - return palier_id diff --git a/views/palier.xml b/views/palier.xml index 1656f9a..d53d36c 100644 --- a/views/palier.xml +++ b/views/palier.xml @@ -14,6 +14,8 @@ +