From 64ca93cf98c1a8a253b6fb1fbe4d0dd5fb2d454c Mon Sep 17 00:00:00 2001 From: ??ngel ??lvarez Date: Thu, 12 May 2016 16:11:14 +0200 Subject: [PATCH] if no warehouse defined, get all --- stock.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/stock.py b/stock.py index 302b06d..59a7837 100644 --- a/stock.py +++ b/stock.py @@ -25,11 +25,18 @@ class Lot: def get_lag_quantity(cls, lots, name): pool = Pool() Date = pool.get('ir.date') + Location = pool.get('stock.location') + configuration = pool.get('stock.configuration')(1) products = list(set(l.product for l in lots)) location_ids = (configuration.warehouse and [configuration.warehouse.id] or []) + + if not location_ids: + warehouses = Location.search([('type', '=', 'warehouse')]) + location_ids = [w.storage_location.id for w in warehouses] + lag_days = configuration.lag_days or 0 stock_date_end = Date.today() + relativedelta(days=int(lag_days)) with Transaction().set_context({'stock_date_end': stock_date_end}): @@ -42,9 +49,15 @@ class Lot: pool = Pool() Date = pool.get('ir.date') configuration = pool.get('stock.configuration')(1) + Location = pool.get('stock.location') location_ids = (configuration.warehouse and [configuration.warehouse.id] or []) + + if not location_ids: + warehouses = Location.search([('type', '=', 'warehouse')]) + location_ids = [w.storage_location.id for w in warehouses] + lag_days = configuration.lag_days or 0 stock_date_end = Date.today() + relativedelta(days=int(lag_days)) with Transaction().set_context({'stock_date_end': stock_date_end}):