From aefd5f7d643afa558d3c845c94a381bab84a5ac8 Mon Sep 17 00:00:00 2001 From: clesgow Date: Tue, 9 Nov 2021 13:43:01 +0000 Subject: [PATCH] [FIX] purchase: Don't plan PO line at the middle of the day No longer converts the date_planned of a purchase_order_line to the middle of the day. In case of multi-steps receipts, this caused a discrepancy between the actual receipt and the later internal transfers. Let's say a reordering rule is triggered : - The date is set to midnight for the procurement, so the internal transfer's date is set to midnight as well. - The date is increased to noon for the PO line, which define the PO planned_date, which define the linked receipt picking. - So in the end : - Receipt is planned to day X at noon. - Transfer from Input -> Stock is planned to day X at midnight. Task-2656397 closes odoo/odoo#79523 Signed-off-by: Arnold Moyaux Signed-off-by: William Henrotin (whe) --- addons/purchase/models/purchase.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 0dc5e298ea4..3cb86fbc292 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -1068,10 +1068,9 @@ class PurchaseOrderLine(models.Model): """ date_order = po.date_order if po else self.order_id.date_order if date_order: - date_planned = date_order + relativedelta(days=seller.delay if seller else 0) + return date_order + relativedelta(days=seller.delay if seller else 0) else: - date_planned = datetime.today() + relativedelta(days=seller.delay if seller else 0) - return self._convert_to_middle_of_day(date_planned) + return datetime.today() + relativedelta(days=seller.delay if seller else 0) @api.depends('product_id', 'date_order') def _compute_analytic_id_and_tag_ids(self):