Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.0] pos_cashbox #1342

Open
wants to merge 2 commits into
base: 11.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pos_cashbox/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"post_init_hook": None,
"uninstall_hook": None,
"auto_install": False,
"installable": False,
"installable": True,
"demo_title": "Open CashBox from Backend",
"demo_addons": [],
"demo_addons_hidden": [],
Expand Down
20 changes: 10 additions & 10 deletions pos_cashbox/static/src/js/cashbox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright 2018 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>
* License MIT (https://opensource.org/licenses/MIT). */
odoo.define("pos_cashbox.open", function(require) {
odoo.define("pos_cashbox.open", function (require) {
"use strict";

var WidgetButton = require("web.form_widgets").WidgetButton;
Expand All @@ -11,7 +11,7 @@ odoo.define("pos_cashbox.open", function(require) {
var _t = core._t;

WidgetButton.include({
on_click: function() {
on_click: function () {
var self = this;
if (this.node.attrs.special === "open_backend_cashbox") {
var proxy_ip = this.view.datarecord.proxy_ip;
Expand All @@ -23,12 +23,12 @@ odoo.define("pos_cashbox.open", function(require) {
var url = this.get_full_url(proxy_ip);
this.connect(url);
this.open_cashbox()
.done(function() {
.done(function () {
if (self.$el.hasClass("o_wow")) {
self.show_wow();
}
})
.fail(function() {
.fail(function () {
return self.show_warning_message(
_t(
"Connection Refused. Please check the connection to CashBox"
Expand All @@ -39,15 +39,15 @@ odoo.define("pos_cashbox.open", function(require) {
this._super.apply(this, arguments);
}
},
show_warning_message: function(message) {
show_warning_message: function (message) {
new CrashManager().show_warning({
data: {
exception_type: _t("Incorrect Operation"),
message: message,
},
});
},
get_full_url: function(current_url) {
get_full_url: function (current_url) {
var port = ":8069";
var url = current_url;
if (url.indexOf("//") < 0) {
Expand All @@ -58,19 +58,19 @@ odoo.define("pos_cashbox.open", function(require) {
}
return url;
},
connect: function(url) {
connect: function (url) {
this.connection = new Session(undefined, url, {use_cors: true});
},
open_cashbox: function() {
open_cashbox: function () {
var self = this;
function send_opening_job(retries, done) {
done = done || new $.Deferred();
self.connection
.rpc("/hw_proxy/open_cashbox")
.done(function() {
.done(function () {
done.resolve();
})
.fail(function() {
.fail(function () {
if (retries > 0) {
send_opening_job(retries - 1, done);
} else {
Expand Down