From 96a82c151b015981918133cd4c1cc8544adeb9fb Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Tue, 13 May 2014 10:40:18 +0200 Subject: [PATCH] Allow to calculate production requests filtered by warehouse issue3887 review12271003 --- CHANGELOG | 2 ++ production.py | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e5f2927829..1ae07d6a75 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Allow to calculate production requests filtered by warehouse + Version 3.2.0 - 2014-04-21 * Bug fixes (see mercurial logs for details) diff --git a/production.py b/production.py index 338334b305..37941e6813 100644 --- a/production.py +++ b/production.py @@ -27,12 +27,15 @@ class Production: __name__ = 'production' @classmethod - def generate_requests(cls, clean=True): + def generate_requests(cls, clean=True, warehouses=None): """ For each product compute the production request that must be created today to meet product outputs. If clean is set, it will remove all previous requests. + + If warehouses is specified it will compute the production requests + only for the selected warehouses. """ pool = Pool() OrderPoint = pool.get('stock.order_point') @@ -48,10 +51,11 @@ class Production: ]) cls.delete(reqs) - # fetch warehouse - warehouses = Location.search([ - ('type', '=', 'warehouse'), - ]) + if warehouses is None: + # fetch warehouse + warehouses = Location.search([ + ('type', '=', 'warehouse'), + ]) warehouse_ids = [w.id for w in warehouses] # fetch order points order_points = OrderPoint.search([ @@ -99,7 +103,7 @@ class Production: req.set_moves() requests.append(req) if requests: - cls.generate_requests(clean=False) + cls.generate_requests(False, warehouses) return requests @classmethod @@ -206,10 +210,14 @@ class CreateProductionRequest(Wizard): ]) create_ = StateAction('stock_supply_production.act_production_request') + @property + def _requests_parameters(self): + return {} + def do_create_(self, action): pool = Pool() Production = pool.get('production') - Production.generate_requests() + Production.generate_requests(**self._requests_parameters) return action, {} def transition_create_(self):