From c594bc67dfe861b180feeb2a3e8b183b415fb008 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Thu, 25 May 2023 15:55:40 +0200 Subject: [PATCH] Manage empty stock end date values on location quantities Closes #12289 --- modules/stock/location.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/stock/location.py b/modules/stock/location.py index c3f4c45953..a854c7bff4 100644 --- a/modules/stock/location.py +++ b/modules/stock/location.py @@ -406,7 +406,7 @@ class Location(DeactivableMixin, tree(), ModelSQL, ModelView): context = {} if (name == 'quantity' - and (trans_context.get('stock_date_end', datetime.date.max) + and ((trans_context.get('stock_date_end') or datetime.date.max) > Date_.today())): context['stock_date_end'] = Date_.today() @@ -494,7 +494,7 @@ class Location(DeactivableMixin, tree(), ModelSQL, ModelView): return Template(trans_context['product_template']) context = {} - if 'stock_date_end' in trans_context: + if trans_context.get('stock_date_end') is not None: # Use the last cost_price of the day context['_datetime'] = datetime.datetime.combine( trans_context['stock_date_end'], datetime.time.max)