diff --git a/modules/stock/product.py b/modules/stock/product.py index 21c4f51110..16f15ae10c 100644 --- a/modules/stock/product.py +++ b/modules/stock/product.py @@ -8,7 +8,7 @@ from copy import deepcopy from simpleeval import simple_eval -from sql import Literal, Select, Window, With +from sql import Literal, Null, Select, Window, With from sql.aggregate import Max, Sum from sql.conditionals import Coalesce, Case from sql.functions import CurrentTimestamp @@ -825,7 +825,10 @@ class ProductQuantitiesByWarehouseMove(ModelSQL, ModelView): warehouse = With('id', query=Location.search([ ('parent', 'child_of', [location_id]), ], query=True, order=[])) - date_column = Coalesce(move.effective_date, move.planned_date) + date_column = Coalesce( + move.effective_date, + Case((move.state == 'assigned', today), else_=Null), + move.planned_date) quantity = Case( (move.to_location.in_(warehouse.select(warehouse.id)), move.internal_quantity),