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 260d664..c54c2e9 100644 --- a/purchase_order_product_recommendation_supermarket/wizards/purchase_order_recommendation.py +++ b/purchase_order_product_recommendation_supermarket/wizards/purchase_order_recommendation.py @@ -70,8 +70,12 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel): ], order="date_order asc", ) - - self.date_last_order = orders[-1].effective_date.date() if orders else False + if orders: + self.date_last_order = ( + orders[-1].effective_date.date() + if orders[-1].effective_date + else orders[-1].date_planned.date() + ) dates = [o.date_order.date() for o in orders if o.date_order] if len(dates) < 2: