From 7353405aa4fc88ede6b85bbb46fe0308b17c1052 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 2 May 2018 17:14:50 +0200 Subject: [PATCH] [FIX] stock: Scheduled date purchase order wrong When running the scheduler for a reordering rule, the delivery lead time of the seller was not taken into account. opw:1837550 --- addons/stock/models/stock_warehouse.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py index d81efe07404..36a6e696cc6 100644 --- a/addons/stock/models/stock_warehouse.py +++ b/addons/stock/models/stock_warehouse.py @@ -845,7 +845,8 @@ class Orderpoint(models.Model): days = self.lead_days or 0.0 if self.lead_type == 'supplier': # These days will be substracted when creating the PO - days += self.product_id._select_seller().delay or 0.0 + qty = self.env.context.get('product_qty', 0.0) + days += self.product_id._select_seller(quantity=qty).delay or 0.0 date_planned = start_date + relativedelta.relativedelta(days=days) return date_planned.strftime(DEFAULT_SERVER_DATETIME_FORMAT) @@ -853,7 +854,7 @@ class Orderpoint(models.Model): def _prepare_procurement_values(self, product_qty, date=False, group=False): return { 'name': self.name, - 'date_planned': date or self._get_date_planned(datetime.today()), + 'date_planned': date or self.with_context(product_qty=product_qty)._get_date_planned(datetime.today()), 'product_id': self.product_id.id, 'product_qty': product_qty, 'company_id': self.company_id.id,