I am trying to add lines to Odoo pos order lines in pos_screen, but this only adds the first selected products somehow.
I am filtering selected orders from order.lines and copying all data from it. Is there any way to set order in Odoo pos without changing this.pos using only created pos.order id.
const filtered_lines = this.pos.get_order().lines
// Step 1: Get all product IDs from refundLines
const refundProductIds = new Set();
const refundOrder = this.pos.add_new_order();
for (const refundLine of refundLines) {
// refundLine format: [0, 0, { product_id: ... }]
const productId = refundLine[2].product_id;
refundProductIds.add(productId);
}
// Step 2: Filter and update the lines
const updatedLines = [];
for (const line of filtered_lines) {
const productId = line.product_id?.id || (line.product && line.product.id);
if (productId && refundProductIds.has(productId)) {
// Find the refund quantity for this product
const refundEntry = refundLines.find(r => r[2].product_id === productId);
const refundQty = refundEntry ? refundEntry[2].qty : 0;
// Create a copy of the line with ONLY qty updated
updatedLines.push({
...line, // Copy all existing fields
qty: refundQty // Override qty with refund value
});
// this.pos.addLineToCurrentOrder({
// ...line, // Copy all existing fields
// qty: refundQty // Override qty with refund value
// })
}
}
updatedLines.forEach(updatedLine =>
{this.pos.addLineToCurrentOrder(updatedLine);
});