purchase_order_product_recommendation_supermarket: fix error when last order from vendor is not received yet

This commit is contained in:
Luis 2025-06-19 17:46:36 +02:00
parent e72fa0d59d
commit ea68e3cc30

View file

@ -70,8 +70,12 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel):
], ],
order="date_order asc", order="date_order asc",
) )
if orders:
self.date_last_order = orders[-1].effective_date.date() if orders else False 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] dates = [o.date_order.date() for o in orders if o.date_order]
if len(dates) < 2: if len(dates) < 2: