diff --git a/pos_order_to_sale_order/models/sale_order.py b/pos_order_to_sale_order/models/sale_order.py index 08a7677e87..54768e6ab5 100644 --- a/pos_order_to_sale_order/models/sale_order.py +++ b/pos_order_to_sale_order/models/sale_order.py @@ -31,18 +31,9 @@ def _prepare_from_pos(self, order_data): def create_order_from_pos(self, order_data, action): # Create Draft Sale order order_vals = self._prepare_from_pos(order_data) - sale_order = self.create(order_vals) - - for (i, line_data) in enumerate(order_data["lines"]): - if line_data[2].get("customer_note", False): - order_line = sale_order.order_line.filtered( - lambda x: x.sequence == i + 1 - ) - order_line.write( - { - "name": f"{order_line.name}\n{line_data[2].get('customer_note', False)}" - } - ) + sale_order = self.with_context( + pos_order_lines_data=[x[2] for x in order_data.get("lines", [])] + ).create(order_vals) # Confirm Sale Order if action in ["confirmed", "delivered", "invoiced"]: diff --git a/pos_order_to_sale_order/models/sale_order_line.py b/pos_order_to_sale_order/models/sale_order_line.py index 2810733f83..3a4ec24fc9 100644 --- a/pos_order_to_sale_order/models/sale_order_line.py +++ b/pos_order_to_sale_order/models/sale_order_line.py @@ -18,3 +18,14 @@ def _prepare_from_pos(self, sequence, order_line_data): "price_unit": order_line_data["price_unit"], "tax_id": order_line_data["tax_ids"], } + + def _get_sale_order_line_multiline_description_sale(self): + res = super()._get_sale_order_line_multiline_description_sale() + + for (i, line_data) in enumerate( + self.env.context.get("pos_order_lines_data", []) + ): + if line_data.get("customer_note", False) and self.sequence == i + 1: + res += "\n" + line_data.get("customer_note") + + return res