Skip to content

Commit

Permalink
[FIX] check current config payment methods to force or not the use of…
Browse files Browse the repository at this point in the history
… the proxy + raise an error when its not properly configured
  • Loading branch information
benwillig committed Jul 9, 2024
1 parent 6ce540e commit 5a03dbd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pos_payment_terminal/static/src/js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,39 @@
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);

const PosPaymentTerminalPosGlobalState = (OriginalPosGlobalState) =>
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"
) {
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);
}
};
Expand Down

0 comments on commit 5a03dbd

Please sign in to comment.