From f8ea8abf2e97c482b48d8acaf5b66fc09f11e11b Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Tue, 17 May 2022 12:44:17 +0000 Subject: [PATCH] [FIX] point_of_sale: prevent pos from crashing with archived product Current behavior: If you create an order in a PoS then go in the backend and archive any of the product in the order. If you try to go back in the PoS session it will crash Steps to reproduce: - Open PoS session and create an order with some products - Leave the session and archive atleast one of these products - Go back to the session, the session crash opw-2854018 closes odoo/odoo#92248 X-original-commit: 0a01e0b97f96754ac2ae84da207584b6b6860b0e Signed-off-by: Masereel Pierre Signed-off-by: Engels Robin (roen) --- addons/point_of_sale/static/src/js/models.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 7b25097ee38..7f56650e412 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -2199,7 +2199,9 @@ class Order extends PosModel { var orderlines = json.lines; for (var i = 0; i < orderlines.length; i++) { var orderline = orderlines[i][2]; - this.add_orderline(Orderline.create({}, {pos: this.pos, order: this, json: orderline})); + if (this.pos.db.get_product_by_id(orderline.product_id)) { + this.add_orderline(Orderline.create({}, { pos: this.pos, order: this, json: orderline })); + } } var paymentlines = json.statement_ids;