From 5a03dbda7ee1e5f806a808252a3941f3fcbc9bf1 Mon Sep 17 00:00:00 2001 From: Benjamin Willig Date: Tue, 9 Jul 2024 16:48:52 +0200 Subject: [PATCH] [FIX] check current config payment methods to force or not the use of the proxy + raise an error when its not properly configured --- pos_payment_terminal/static/src/js/models.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pos_payment_terminal/static/src/js/models.js b/pos_payment_terminal/static/src/js/models.js index 5face73931..a3b79cae46 100644 --- a/pos_payment_terminal/static/src/js/models.js +++ b/pos_payment_terminal/static/src/js/models.js @@ -12,10 +12,13 @@ odoo.define("pos_payment_terminal.models", function (require) { "use strict"; + var core = require("web.core"); var models = require("point_of_sale.models"); const {PosGlobalState, Payment} = require("point_of_sale.models"); const Registries = require("point_of_sale.Registries"); + var _t = core._t; + var OCAPaymentTerminal = require("pos_payment_terminal.payment"); models.register_payment_method("oca_payment_terminal", OCAPaymentTerminal); @@ -23,7 +26,8 @@ odoo.define("pos_payment_terminal.models", function (require) { class extends OriginalPosGlobalState { // @override async after_load_server_data() { - for (var payment_method_id in this.payment_methods) { + for (var index in this.config.payment_method_ids) { + var payment_method_id = this.config.payment_method_ids[index]; var payment_method = this.payment_methods[payment_method_id]; if ( payment_method.use_payment_terminal === "oca_payment_terminal" @@ -31,6 +35,16 @@ odoo.define("pos_payment_terminal.models", function (require) { this.config.use_proxy = true; } } + if (Boolean(!this.config.proxy_ip) && this.config.use_proxy) { + throw new Error(_t("Payment Terminal Error"), { + cause: { + message: _t( + "A payment terminal has been linked to one payment provider but the IoT " + + "Box location has not been configured." + ), + }, + }); + } return await super.after_load_server_data(...arguments); } };