From 515362a0442c235efab4da19e9f38ee2cfd3f8c9 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Mon, 17 Jan 2022 09:12:25 +0000 Subject: [PATCH] [FIX] sale_management: lines reset on template change The removal of existing order lines on template update was unexpectedly lost in recent code changes. This commit brings back the old expected behavior. closes odoo/odoo#82868 Signed-off-by: Victor Feyens (vfe) --- addons/sale_management/models/sale_order.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/sale_management/models/sale_order.py b/addons/sale_management/models/sale_order.py index 2b430efba7e..6eb22c73cfe 100644 --- a/addons/sale_management/models/sale_order.py +++ b/addons/sale_management/models/sale_order.py @@ -87,13 +87,16 @@ class SaleOrder(models.Model): def _onchange_sale_order_template_id(self): sale_order_template = self.sale_order_template_id.with_context(lang=self.partner_id.lang) - self.order_line = [ + order_lines_data = [fields.Command.clear()] + order_lines_data += [ fields.Command.create( self._compute_line_data_for_template_change(line) ) for line in sale_order_template.sale_order_template_line_ids ] + self.order_line = order_lines_data + option_lines_data = [fields.Command.clear()] option_lines_data += [ fields.Command.create(