Browse Source

[FIX] local widget config

Gogs 6 years ago
parent
commit
82e5a27597
1 changed files with 8 additions and 11 deletions
  1. 8 11
      static/src/js/main.js

+ 8 - 11
static/src/js/main.js

@@ -11,14 +11,14 @@ openerp.print_engine = function (instance, local) {
             var self = this;
 
             var setup_socket = function (config) {
-                var protocol = window.location.protocol;
-                self.socket = io(protocol + '//' + config.host + ':' + config.port, {
+                self.config = config;
+                self.socket = io(location.protocol + '//' + config.host + ':' + config.port, {
                     path: config.path
                 });
                 self.socket.on('connect', self.handle_connect);
                 self.socket.on('connect_error', self.handle_connect_error);
-                self.socket.on('show-printers', self.handle_printers);
-                self.socket.on('show-print-status', self.handle_print_status);
+                self.socket.on('request_printer_name', self.handle_printer_selection);
+                self.socket.on('show_print_status', self.handle_print_status);
             }
 
             this.get_socket_config().then(setup_socket);
@@ -31,7 +31,7 @@ openerp.print_engine = function (instance, local) {
             $('#printer-status').removeClass();
             $('#printer-status').addClass('printer-status-offline');
         },
-        handle_printers: function (printers) {
+        handle_printer_selection: function (printers) {
             instance.web.unblockUI();
         
             var widget = new local.PrinterSelectionWidget(printers);
@@ -77,11 +77,11 @@ openerp.print_engine = function (instance, local) {
                 instance.web.notification.do_warn('Impresión', 'La impresora no está preparada');
                 return;
             }
-
+            
             instance.web.blockUI();
-
             try {
-                this.socket.emit('request-print', {
+                this.socket.emit('request_print', {
+                    print_direcly: this.config.print_direcly,
                     data: data
                 });
             } catch (e) {
@@ -95,9 +95,6 @@ openerp.print_engine = function (instance, local) {
         template: 'PrinterTopWidget',
         init: function (parent) {
             this._super(parent);
-        },
-        start: function () {
-            // this.$el.click(this, this.selectDefaultPrinter);
         }
     });