From 4a05a12ce473cf182a8b1b2dbfc32bee7b025056 Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Thu, 12 Jan 2023 15:28:14 +0000 Subject: [PATCH] [FIX] pos_sale: down_payment product not imported Current behavior: If you limit the number of product loaded in the pos to 0, and block loading product in the background you will have a traceback when trying to apply a down_payment. Steps to reproduce: - Settings > POS > Limit products to load > Set 0 - Disable the option "Load product in the background" - Start a PoS session - Go in the Quotation / Order screen - Apply a down payment - Results in traceback opw-3113215 closes odoo/odoo#110883 X-original-commit: 77a5e134dd3c87b3ed0bd5708bf63ed76647306b Signed-off-by: Engels Robin (roen) --- .../js/OrderManagementScreen/SaleOrderManagementScreen.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js b/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js index bf5afce6739..d58be411e26 100644 --- a/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js +++ b/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js @@ -240,9 +240,15 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo total: lines[i].price_total, }; } - const down_payment_product = this.env.pos.db.get_product_by_id( + let down_payment_product = this.env.pos.db.get_product_by_id( this.env.pos.config.down_payment_product_id[0] ); + if (!down_payment_product) { + await this.env.pos._addProducts([this.env.pos.config.down_payment_product_id[0]]); + down_payment_product = this.env.pos.db.get_product_by_id( + this.env.pos.config.down_payment_product_id[0] + ); + } const down_payment_tax = this.env.pos.taxes_by_id[down_payment_product.taxes_id] || false; let down_payment;