Skip to content

Commit

Permalink
[IMP] pos_order_to_sale_order : use customer_note to prepare sale ord…
Browse files Browse the repository at this point in the history
…er line name fields
  • Loading branch information
legalsylvain committed Nov 10, 2023
1 parent e8967d2 commit 2b18895
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 11 additions & 0 deletions pos_order_to_sale_order/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ def create_order_from_pos(self, order_data, action):
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)}"
}
)

# Confirm Sale Order
if action in ["confirmed", "delivered", "invoiced"]:
sale_order.action_confirm()
Expand Down
6 changes: 0 additions & 6 deletions pos_order_to_sale_order/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,9 @@ class SaleOrderLine(models.Model):

@api.model
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"],
"discount": order_line_data["discount"],
"price_unit": order_line_data["price_unit"],
Expand Down

0 comments on commit 2b18895

Please sign in to comment.