From 0eeee0cd53b000f2e3ecc7f5a2d9077b4333ff70 Mon Sep 17 00:00:00 2001 From: AH-Yussef Date: Mon, 4 Dec 2023 08:34:16 +0200 Subject: [PATCH] [FIX] sale_management: maintain template lines order on Confirm Steps to reproduce: - Install Sales app - Open Sales app, Go to Configuration > Quotation Templates - Open a template, or create an new one - Add sections with product(s) under each, so we have a structure like: - Section 1 - Product 1 - Section 2 - Product 2 - Go to Orders > Quotations - Create a New Quotation - Select the recently created/updated template in the Quotation Template field - Click on Confirm - U can notice how the sections are moved to the top, missing up the structure Investigation: - Each sale order order_line has a sequence property associated to it which defaults to 10 if not explicitly specified https://github.com/odoo/odoo/blob/55b452ac0056c7075097fa1324ef53fc5090fb7a/addons/sale/models/sale_order_line.py#L41 - On Choosing a template, the _prepare_order_line_values() method returns the needed properties for each template line https://github.com/odoo/odoo/blob/55b452ac0056c7075097fa1324ef53fc5090fb7a/addons/sale_management/models/sale_order.py#L108 - The returned object for each template is missing the sequence property, resulting in it falling back to 10 when assigning it to the sale order order_line https://github.com/odoo/odoo/blob/55b452ac0056c7075097fa1324ef53fc5090fb7a/addons/sale_management/models/sale_order.py#L117 - Now all order_line(s) has the same sequence -except for the first one which has a sequence value of -99- https://github.com/odoo/odoo/blob/55b452ac0056c7075097fa1324ef53fc5090fb7a/addons/sale_management/models/sale_order.py#L114-L115 opw-3602781 closes odoo/odoo#144700 Signed-off-by: Ali Hassan Youssef (alhy) --- addons/sale_management/models/sale_order_template_line.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/sale_management/models/sale_order_template_line.py b/addons/sale_management/models/sale_order_template_line.py index c318e74c9a9..9321e40458f 100644 --- a/addons/sale_management/models/sale_order_template_line.py +++ b/addons/sale_management/models/sale_order_template_line.py @@ -110,4 +110,5 @@ class SaleOrderTemplateLine(models.Model): 'product_id': self.product_id.id, 'product_uom_qty': self.product_uom_qty, 'product_uom': self.product_uom_id.id, + 'sequence': self.sequence, }