|
@@ -182,10 +182,78 @@ openerp.print_engine = function (instance, local) {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ local.DownloadPrinterTools = instance.web.Widget.extend({
|
|
|
+ template: 'DownloadPrinterTools',
|
|
|
+ events: {
|
|
|
+ 'click .download_button': 'handle_download'
|
|
|
+ },
|
|
|
+ init: function (parent) {
|
|
|
+ this._super(parent);
|
|
|
+ },
|
|
|
+ start: function () {
|
|
|
+ this.renderElement();
|
|
|
+ this.$el.appendTo($('body'));
|
|
|
+ this.$el.on('hidden.bs.modal', this, this.on_hide);
|
|
|
+
|
|
|
+ if (this.is_linux_platform()) {
|
|
|
+ this.$('.download_logo_windows').css('display', 'none');
|
|
|
+ this.$('.windows_download_button').css('display', 'none');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.is_win_platform()) {
|
|
|
+ this.$('.download_logo_linux').css('display', 'none');
|
|
|
+ this.$('.linux_download_button').css('display', 'none');
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$el.modal('show');
|
|
|
+ },
|
|
|
+ on_hide: function (e) {
|
|
|
+ var self = e.data;
|
|
|
+ self.$el.remove();
|
|
|
+ self.destroy();
|
|
|
+ },
|
|
|
+ is_win_platform: function () {
|
|
|
+ return /^Win(?:32|64)$/.test(navigator.platform);
|
|
|
+ },
|
|
|
+ is_linux_platform: function () {
|
|
|
+ return /^Linux\sx86(?:|_64)$/.test(navigator.platform);
|
|
|
+ },
|
|
|
+ handle_download: function (e) {
|
|
|
+ var download_url = 'https://repo.eiru.com.py/attachments/';
|
|
|
+
|
|
|
+ if (this.is_linux_platform()) {
|
|
|
+ download_url += '94bcc4d4-8fe7-45f9-8715-97c11fdcdd6f';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.is_win_platform()) {
|
|
|
+ download_url += '8b9b5283-c5f8-4a62-a798-2691b72936bd';
|
|
|
+ }
|
|
|
+
|
|
|
+ var a = document.createElement('a');
|
|
|
+
|
|
|
+ a.href = download_url;
|
|
|
+ a.target = '_parent';
|
|
|
+ a.click();
|
|
|
+
|
|
|
+ this.$el.modal('hide');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
local.PrinterTopNotificator = instance.web.Widget.extend({
|
|
|
template: 'PrinterTopNotificator',
|
|
|
+ events: {
|
|
|
+ 'click .printer_status_notificator': 'handle_click'
|
|
|
+ },
|
|
|
init: function (parent) {
|
|
|
this._super(parent);
|
|
|
+ },
|
|
|
+ handle_click: function (e) {
|
|
|
+ e.preventDefault();
|
|
|
+
|
|
|
+ if (local.socket_manager.socket.disconnected) {
|
|
|
+ var widget = new local.DownloadPrinterTools(this);
|
|
|
+ widget.start();
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -455,7 +523,9 @@ openerp.print_engine = function (instance, local) {
|
|
|
do_update: function () {
|
|
|
var printer = new local.PrinterTopNotificator(this);
|
|
|
printer.appendTo($('.oe_systray'));
|
|
|
+
|
|
|
local.socket_manager = new local.SocketManager();
|
|
|
+
|
|
|
return this._super.apply(this, arguments);
|
|
|
}
|
|
|
});
|