From 5f816d635a5ef283634ed007e6d24e1eef085e5e Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Wed, 22 Feb 2023 17:10:13 +0100 Subject: [PATCH] [FIX] stock: copy reservation_date in split moves steps to reproduce: - activate Settings > Reception Report - Create new storable product - Create + confirm planned delivery of 5 of the product - Create + confirm planned receipt of 2 of the product - Open reception report (Allocation button) in receipt - Assign the 2 products to the delivery - create +confirm a new delivery with 2 products - create + confirm a new receipt with 2 products - Open reception report in new receipt Expected result: The stock.move in the original delivery will be split into 2 moves, with Demand qtys of 2 and 3 respectively. Opening the new receipt's reception report will allow you to assign to the remaining 2 in the original delivery Actual result: Only the new delivery is displayed rather than the old delivery Issue was due to the `reservation_date` not being copied into the newly split move even though we would expect it to be the same (instead it is `False` since the default reservation method for operation types is `at_confirm` and the new move does not have `action_confirm` called on it, so the date is never set). Since we usually don't want this date to be copied, we only manually do it in the reception report splits. Part-of: odoo/odoo#126791 --- addons/stock/report/report_stock_reception.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/stock/report/report_stock_reception.py b/addons/stock/report/report_stock_reception.py index f041947cec6..0908484a30a 100644 --- a/addons/stock/report/report_stock_reception.py +++ b/addons/stock/report/report_stock_reception.py @@ -222,7 +222,10 @@ class ReceptionReport(models.AbstractModel): new_move_vals = [] for out, qty_to_link in zip(outs, qtys): if float_compare(out.product_qty, qty_to_link, precision_rounding=out.product_id.uom_id.rounding) == 1: - new_move_vals += out._split(out.product_qty - qty_to_link) + new_move = out._split(out.product_qty - qty_to_link) + if new_move: + new_move[0]['reservation_date'] = out.reservation_date + new_move_vals += new_move out_to_new_out[out.id] = self.env['stock.move'] new_outs = self.env['stock.move'].create(new_move_vals) # don't do action confirm to avoid creating additional unintentional reservations @@ -301,6 +304,7 @@ class ReceptionReport(models.AbstractModel): new_move_vals = out._split(out.product_qty - total_still_linked) if new_move_vals: new_move_vals[0]['procure_method'] = 'make_to_order' + new_move_vals[0]['reservation_date'] = out.reservation_date new_out = self.env['stock.move'].create(new_move_vals) # don't do action confirm to avoid creating additional unintentional reservations new_out.write({'state': 'confirmed'})