From 2ccc5d7b31a83bcf72b73dc73fcbfd4b6f97cff3 Mon Sep 17 00:00:00 2001 From: Guillem Barba Date: Thu, 22 Jan 2015 18:38:49 +0100 Subject: [PATCH] Add warning message for late production issue4375 review9911002 --- CHANGELOG | 2 ++ production.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 4f5e9d1da5..87a7dd2fc8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Add warning for late production when creating production request. + Version 3.4.0 - 2014-10-20 * Bug fixes (see mercurial logs for details) * Allow to calculate production requests filtered by warehouse diff --git a/production.py b/production.py index b5e09ed6a3..ec4ef3c781 100644 --- a/production.py +++ b/production.py @@ -212,13 +212,33 @@ class CreateProductionRequest(Wizard): ]) create_ = StateAction('stock_supply_production.act_production_request') + @classmethod + def __setup__(cls): + super(CreateProductionRequest, cls).__setup__() + cls._error_messages.update({ + 'late_productions': 'There are some late productions.', + }) + @property def _requests_parameters(self): return {} def do_create_(self, action): pool = Pool() + Date = pool.get('ir.date') + Move = pool.get('stock.move') Production = pool.get('production') + + today = Date.today() + if Move.search([ + ('from_location.type', '=', 'production'), + ('to_location.type', '=', 'storage'), + ('state', '=', 'draft'), + ('planned_date', '<', today), + ], order=[]): + self.raise_user_warning('%s@%s' % (self.__name__, today), + 'late_productions') + Production.generate_requests(**self._requests_parameters) return action, {}