From eb77cf2ab7f0c4b6c61a6cdb5ccd59c51858e5a6 Mon Sep 17 00:00:00 2001 From: geomer198 Date: Sat, 18 Nov 2023 19:57:00 +0400 Subject: [PATCH 1/2] [FIX] pos_order_to_sale_order: Code refactoring and fix comments. --- pos_order_to_sale_order/models/sale_order.py | 4 ++-- .../models/sale_order_line.py | 9 ++++----- pos_order_to_sale_order/tests/test_module.py | 9 ++++++++- .../tours/PosOrderToSaleOrderTour.tour.js | 19 +++++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/pos_order_to_sale_order/models/sale_order.py b/pos_order_to_sale_order/models/sale_order.py index 54768e6ab5..8ba87fc24c 100644 --- a/pos_order_to_sale_order/models/sale_order.py +++ b/pos_order_to_sale_order/models/sale_order.py @@ -14,8 +14,8 @@ def _prepare_from_pos(self, order_data): session = PosSession.browse(order_data["pos_session_id"]) SaleOrderLine = self.env["sale.order.line"] order_lines = [ - Command.create(SaleOrderLine._prepare_from_pos(i + 1, line_data[2])) - for (i, line_data) in enumerate(order_data["lines"]) + Command.create(SaleOrderLine._prepare_from_pos(sequence, line_data[2])) + for sequence, line_data in enumerate(order_data["lines"], start=1) ] return { "partner_id": order_data["partner_id"], 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 3a4ec24fc9..a990903754 100644 --- a/pos_order_to_sale_order/models/sale_order_line.py +++ b/pos_order_to_sale_order/models/sale_order_line.py @@ -22,10 +22,9 @@ def _prepare_from_pos(self, sequence, order_line_data): 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", []) + for i, line_data in enumerate( + self.env.context.get("pos_order_lines_data", []), start=1 ): - if line_data.get("customer_note", False) and self.sequence == i + 1: - res += "\n" + line_data.get("customer_note") - + if line_data.get("customer_note", False) and self.sequence == i: + res += f"\n{line_data.get('customer_note')}" return res diff --git a/pos_order_to_sale_order/tests/test_module.py b/pos_order_to_sale_order/tests/test_module.py index 57976285c5..68041cd29f 100644 --- a/pos_order_to_sale_order/tests/test_module.py +++ b/pos_order_to_sale_order/tests/test_module.py @@ -37,7 +37,14 @@ def test_pos_order_to_sale_order(self): order = after_orders[-1] - self.assertEqual(order.amount_total, 3.2) + expected_note = "Product Note" + + self.assertEqual(order.amount_total, 5.18) self.assertEqual(order.state, "sale") self.assertEqual(order.delivery_status, "full") self.assertEqual(order.invoice_status, "invoiced") + + line_1, line_2 = order.order_line + + self.assertNotIn(expected_note, line_1.name) + self.assertIn(expected_note, line_2.name) diff --git a/pos_order_to_sale_order/tests/tours/PosOrderToSaleOrderTour.tour.js b/pos_order_to_sale_order/tests/tours/PosOrderToSaleOrderTour.tour.js index 629103770f..a979106413 100644 --- a/pos_order_to_sale_order/tests/tours/PosOrderToSaleOrderTour.tour.js +++ b/pos_order_to_sale_order/tests/tours/PosOrderToSaleOrderTour.tour.js @@ -31,6 +31,25 @@ odoo.define("pos_order_to_sale_order.tour.PosOrderToSaleOrderTour", function (re "Test pos_order_to_sale_order: Order a 'Whiteboard Pen' (price 3.20)", trigger: ".product-list .product-name:contains('Whiteboard Pen')", }, + { + content: + "Test pos_order_to_sale_order: Order a 'Wall Shelf Unit' (price 1.98)", + trigger: ".product-list .product-name:contains('Wall Shelf Unit')", + }, + { + context: "Test pos_order_to_sale_order: Customer Note for 'Whiteboard'", + trigger: '.control-buttons .control-button span:contains("Customer Note")', + }, + { + context: + "Test pos_order_to_sale_order: Set Customer Note for product 'Whiteboard'", + trigger: ".popups .popup-textarea .popup-textarea-wrap textarea", + run: "text Product Note", + }, + { + context: "Test pos_order_to_sale_order: Confirm Customer Note", + trigger: ".modal-dialog .confirm", + }, { content: "Test pos_order_to_sale_order: Click on 'Customer' Button", trigger: "button.set-partner", From d52439d3e44b06061085f96995111441db95b7ac Mon Sep 17 00:00:00 2001 From: geomer198 Date: Mon, 20 Nov 2023 16:18:50 +0400 Subject: [PATCH 2/2] [FIX] pos_order_to_sale_order: test is fixed. --- pos_order_to_sale_order/tests/test_module.py | 33 +++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/pos_order_to_sale_order/tests/test_module.py b/pos_order_to_sale_order/tests/test_module.py index 68041cd29f..7a7627b04a 100644 --- a/pos_order_to_sale_order/tests/test_module.py +++ b/pos_order_to_sale_order/tests/test_module.py @@ -37,14 +37,25 @@ def test_pos_order_to_sale_order(self): order = after_orders[-1] - expected_note = "Product Note" - - self.assertEqual(order.amount_total, 5.18) - self.assertEqual(order.state, "sale") - self.assertEqual(order.delivery_status, "full") - self.assertEqual(order.invoice_status, "invoiced") - - line_1, line_2 = order.order_line - - self.assertNotIn(expected_note, line_1.name) - self.assertIn(expected_note, line_2.name) + self.assertEqual( + order.amount_total, 5.18, msg="Total Amount must be equal to 5.18" + ) + self.assertEqual(order.state, "sale", msg="Order state must be equal to 'sale'") + self.assertEqual( + order.delivery_status, "full", msg="Delivery status must be equal to 'full'" + ) + self.assertEqual( + order.invoice_status, + "invoiced", + msg="Invoice status must be equal to 'invoiced'", + ) + self.assertNotIn( + "Product Note", + order.order_line[0].name, + msg="'Product Note' must contains in sale order line description", + ) + self.assertIn( + "Product Note", + order.order_line[1].name, + msg="'Product Note' must not contains in sale order line description", + )