Skip to content

Commit

Permalink
[REF] pos_order_to_sale_order : add sale order line sequence in the p…
Browse files Browse the repository at this point in the history
…repare function
  • Loading branch information
legalsylvain committed Nov 10, 2023
1 parent 82ff63e commit e8967d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
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(line[2]))
for line in order_data["lines"]
Command.create(SaleOrderLine._prepare_from_pos(i + 1, line_data[2]))
for (i, line_data) in enumerate(order_data["lines"])
]
return {
"partner_id": order_data["partner_id"],
Expand Down
3 changes: 2 additions & 1 deletion pos_order_to_sale_order/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

@api.model
def _prepare_from_pos(self, order_line_data):
def _prepare_from_pos(self, sequence, order_line_data):
ProductProduct = self.env["product.product"]
product = ProductProduct.browse(order_line_data["product_id"])
product_name = product.name
if order_line_data.get("customer_note"):
product_name += "\n" + order_line_data["customer_note"]
return {
"sequence": sequence,
"product_id": order_line_data["product_id"],
"name": product_name,
"product_uom_qty": order_line_data["qty"],
Expand Down

0 comments on commit e8967d2

Please sign in to comment.