diff --git a/purchase_order_product_recommendation_supermarket/wizards/purchase_order_recommendation.py b/purchase_order_product_recommendation_supermarket/wizards/purchase_order_recommendation.py index 37ab0a4..7dcadc5 100644 --- a/purchase_order_product_recommendation_supermarket/wizards/purchase_order_recommendation.py +++ b/purchase_order_product_recommendation_supermarket/wizards/purchase_order_recommendation.py @@ -79,6 +79,8 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel): if orders[-1].effective_date else orders[-1].date_planned.date() ) + else: + self.date_last_order = False dates = [o.date_order.date() for o in orders if o.date_order] if len(dates) < 2: @@ -160,7 +162,7 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel): days = self._get_total_days() prev_date_end = self.date_begin - timedelta(days=1) - prev_date_begin = prev_date_end - timedelta(days=days) + prev_date_begin = self.date_begin - timedelta(days=days) domain = self.with_context( { "period_date_begin": prev_date_begin, @@ -179,7 +181,6 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel): "period_date_end": prev_date_end, } )._get_days_out_of_stock(product_id) - print(days_with_stock) res["units_avg_delivered_prev"] = ( res["units_delivered_prev"] / days_with_stock if days_with_stock != 0