From 231c519f747793caa9fb4442ce5c50c419ff45bb Mon Sep 17 00:00:00 2001 From: "Loukas Wets (lowe)" Date: Mon, 30 Oct 2023 09:51:01 +0100 Subject: [PATCH] [FIX] point_of_sale: comboline changes Step to reproduce: - Order a combo product in pos_restaurant - Order the same combo product for the same table - The second order will not be processed Previously the getOrderChanges method was computing the orderline changes based on a key composed of the product id, the full product name and the note. This was done considering the fact that the merge orderline was working. Combo products are not handled by the merge orderline. Because of this, if 2 orderlines of combo product were the same, only the last orderline would be taken into account. To prevent this, this commit changes the key to the uuid wich is a unique identifier to an orderline. closes odoo/odoo#140416 Related: odoo/enterprise#49893 Signed-off-by: David Monnom (moda) --- addons/point_of_sale/static/src/app/store/models.js | 13 ++++++------- .../pages/confirmation_page/confirmation_page.js | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/addons/point_of_sale/static/src/app/store/models.js b/addons/point_of_sale/static/src/app/store/models.js index af487dc0fc6..74b81ec4e8b 100644 --- a/addons/point_of_sale/static/src/app/store/models.js +++ b/addons/point_of_sale/static/src/app/store/models.js @@ -1632,7 +1632,7 @@ export class Order extends PosModel { } /** - * @returns {{ [productKey: string]: { product_id: number, name: string, note: string, quantity: number } }} + * @returns {{ [lineKey: string]: { product_id: number, name: string, note: string, quantity: number } }} * This function recalculates the information to be sent to the preparation tools, * it uses the variable lastOrderPrepaChange which contains the last changes sent * to perform this calculation. @@ -1650,7 +1650,6 @@ export class Order extends PosModel { const orderline = this.orderlines[orderlineIdx]; const product = orderline.get_product(); const note = orderline.getNote(); - const productKey = `${product.id} - ${orderline.get_full_product_name()} - ${note}`; const lineKey = `${orderline.uuid} - ${note}`; if ( prepaCategoryIds.size === 0 || @@ -1662,7 +1661,7 @@ export class Order extends PosModel { : quantity; if (quantityDiff && orderline.skipChange === skipped) { - changes[productKey] = { + changes[lineKey] = { name: orderline.get_full_product_name(), product_id: product.id, attribute_value_ids: orderline.attribute_value_ids, @@ -1686,9 +1685,9 @@ export class Order extends PosModel { // was last sent to the preparation tools. If so we add this to the changes. for (const [lineKey, lineResume] of Object.entries(this.lastOrderPrepaChange)) { if (!this.getOrderedLine(lineKey)) { - const productKey = `${lineResume["product_id"]} - ${lineResume["name"]} - ${lineResume["note"]}`; - if (!changes[productKey]) { - changes[productKey] = { + const lineKey = `${lineResume["line_uuid"]} - ${lineResume["note"]}`; + if (!changes[lineKey]) { + changes[lineKey] = { product_id: lineResume["product_id"], name: lineResume["name"], note: lineResume["note"], @@ -1696,7 +1695,7 @@ export class Order extends PosModel { quantity: -lineResume["quantity"], }; } else { - changes[productKey]["quantity"] -= lineResume["quantity"]; + changes[lineKey]["quantity"] -= lineResume["quantity"]; } } } diff --git a/addons/pos_self_order/static/src/app/pages/confirmation_page/confirmation_page.js b/addons/pos_self_order/static/src/app/pages/confirmation_page/confirmation_page.js index bc5b2636a7a..44a099eef73 100644 --- a/addons/pos_self_order/static/src/app/pages/confirmation_page/confirmation_page.js +++ b/addons/pos_self_order/static/src/app/pages/confirmation_page/confirmation_page.js @@ -27,9 +27,9 @@ export class ConfirmationPage extends Component { this.setDefautLanguage(); }, 5000); - setTimeout(() => { + setTimeout(async () => { try { - this.printer.print(OrderReceipt, { + await this.printer.print(OrderReceipt, { data: this.selfOrder.export_for_printing(this.confirmedOrder), formatCurrency: this.selfOrder.formatMonetary, });