From db0d943b0f7ea3e612a9ef5200ff333486b96e6f Mon Sep 17 00:00:00 2001 From: smna-odoo Date: Wed, 7 Jun 2023 06:46:18 +0000 Subject: [PATCH] [FIX] stock: add SM without scheduled date If a user adds a new SM to a picking without any scheduled date, traceback will appear To reproduce the issue: 1. create a new picking and remove the scheduled_date. 2. try to add a new storable product in move lines. Error: A traceback appears: "TypeError: '>' not supported between instances of 'datetime.datetime' and 'bool'" On the picking form, the default SM date is the scheduled date of the picking: https://github.com/odoo/odoo/blob/2c3f53d5a0380e7de27977f56f20307ff2bccabf/addons/stock/views/stock_picking_views.xml#L358 Therefore, in the above use case, when triggering the onchange/compute methods, the field `date` of the SM will not be defined. At some point, we need to get the forecasted quantities of the SM product (see the method updated by this commit) and, to do so, we compare the SM date with `now`. Since this date is `False`, it will lead to the above traceback sentry-3979281197 closes odoo/odoo#124352 X-original-commit: e6179a5147a33dc53ce4ffbdace2585f13f18a14 Signed-off-by: Adrien Widart (awt) --- addons/stock/models/stock_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 98a6a1c11d6..40e8c4d19b6 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -480,7 +480,7 @@ Please change the quantity done or the rounding precision of your unit of measur def key_virtual_available(move, incoming=False): warehouse_id = move.location_dest_id.warehouse_id.id if incoming else move.location_id.warehouse_id.id - return warehouse_id, max(move.date, now) + return warehouse_id, max(move.date or now, now) # Prefetch efficiently virtual_available for _is_consuming draft move. prefetch_virtual_available = defaultdict(set)