From 8b110754ae89241fe889fd9c9ecc75c7be10ec69 Mon Sep 17 00:00:00 2001 From: les-adhoc Date: Mon, 8 Jun 2026 16:27:37 +0000 Subject: [PATCH] [FIX] purchase_ux: initialize date_planned for new lines in confirmed POs X-original-commit: 89ce1423244589b3cd71213336d8349dccea5625 --- purchase_ux/models/purchase_order_line.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/purchase_ux/models/purchase_order_line.py b/purchase_ux/models/purchase_order_line.py index 03d4c016..a0a7d8a5 100644 --- a/purchase_ux/models/purchase_order_line.py +++ b/purchase_ux/models/purchase_order_line.py @@ -165,6 +165,17 @@ def _compute_price_unit_and_date_planned_and_name(self): price_update_lines = self.filtered(lambda x: x.state not in ["purchase", "done"]) res = super(PurchaseOrderLine, price_update_lines)._compute_price_unit_and_date_planned_and_name() + # Lines in confirmed/done POs without date_planned are new lines added after confirmation. + # Price and description must NOT be updated (rule a), but date_planned must be initialized. + for line in (self - price_update_lines).filtered(lambda x: not x.date_planned and x.product_id): + seller = line.product_id._select_seller( + partner_id=line.partner_id, + quantity=line.product_qty, + date=line.order_id.date_order and line.order_id.date_order.date() or fields.Date.context_today(line), + uom_id=line.product_uom, + ) + line.date_planned = line._get_date_planned(seller) + for line in price_update_lines.filtered(lambda x: x.product_id and not x.price_unit): price_unit = line.with_company(line.company_id.id).product_id.standard_price if price_unit and line.currency_id != line.company_id.currency_id: