Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] pos_order_to_sale_order #4

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pos_order_to_sale_order/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
9 changes: 4 additions & 5 deletions pos_order_to_sale_order/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 22 additions & 4 deletions pos_order_to_sale_order/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,25 @@ def test_pos_order_to_sale_order(self):

order = after_orders[-1]

self.assertEqual(order.amount_total, 3.2)
self.assertEqual(order.state, "sale")
self.assertEqual(order.delivery_status, "full")
self.assertEqual(order.invoice_status, "invoiced")
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",
)
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading