From d17a0b0c42b90a29ae1bb314744f20d8aa5a082f 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/i18n/fr.po | 10 ++++++++ .../i18n/pos_payment_terminal.pot | 9 ++++++++ pos_payment_terminal/static/src/js/models.js | 23 +++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/pos_payment_terminal/i18n/fr.po b/pos_payment_terminal/i18n/fr.po index 42399b8ca9..53cf4af0c6 100644 --- a/pos_payment_terminal/i18n/fr.po +++ b/pos_payment_terminal/i18n/fr.po @@ -72,6 +72,16 @@ msgid "" "transaction." msgstr "" +#. module: pos_payment_terminal +#. odoo-javascript +#: code:addons/pos_payment_terminal/static/src/js/models.js:0 +#, python-format +msgid "" +"A payment terminal has been linked to one payment provider but the IoT " +"Box location has not been configured." +msgstr "Un terminal de paiement a été lié à une méthode de paiement mais l'emplacement " +"de l'IoT Box n'a pas ếté configuré." + #. module: pos_payment_terminal #: model:ir.model,name:pos_payment_terminal.model_pos_payment_method msgid "Point of Sale Payment Methods" diff --git a/pos_payment_terminal/i18n/pos_payment_terminal.pot b/pos_payment_terminal/i18n/pos_payment_terminal.pot index f0e5f01849..8518dd6d9c 100644 --- a/pos_payment_terminal/i18n/pos_payment_terminal.pot +++ b/pos_payment_terminal/i18n/pos_payment_terminal.pot @@ -67,6 +67,15 @@ msgid "" "transaction." msgstr "" +#. module: pos_payment_terminal +#. odoo-javascript +#: code:addons/pos_payment_terminal/static/src/js/models.js:0 +#, python-format +msgid "" +"A payment terminal has been linked to one payment provider but the IoT " +"Box location has not been configured." +msgstr "" + #. module: pos_payment_terminal #: model:ir.model,name:pos_payment_terminal.model_pos_payment_method msgid "Point of Sale Payment Methods" diff --git a/pos_payment_terminal/static/src/js/models.js b/pos_payment_terminal/static/src/js/models.js index 5face73931..f2fc8b3eda 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,14 +26,30 @@ 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) { - var payment_method = this.payment_methods[payment_method_id]; + for (var index in this.payment_methods) { + var payment_method = this.payment_methods[index]; + var payment_method_id = payment_method.id; + if ( + this.config.payment_method_ids.indexOf(payment_method_id) === -1 + ) { + continue; + } if ( payment_method.use_payment_terminal === "oca_payment_terminal" ) { 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); } };