From 786c044a39a3bd472af18db73e21ef32eb20b021 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 22 Jun 2018 16:42:29 +0200 Subject: [PATCH] [FIX] pos_restaurant: don't crash when printer have no url set Have a printer in a pos.config that doesn't have a url set Open the pos Before this commit, there was a JS traceback, since we tried to call string operation on undefined. After this commit, we avoid the traceback with a behavior that *looks like* the v9.0's i.e. we don't care if the url actually means something, we put a message in the console though OPW 1858063 closes #25442 --- addons/pos_restaurant/static/src/js/multiprint.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/pos_restaurant/static/src/js/multiprint.js b/addons/pos_restaurant/static/src/js/multiprint.js index 65956ffa66d..5270f103c48 100644 --- a/addons/pos_restaurant/static/src/js/multiprint.js +++ b/addons/pos_restaurant/static/src/js/multiprint.js @@ -29,8 +29,10 @@ var Printer = core.Class.extend(mixins.PropertiesMixin,{ self.connection.rpc('/hw_proxy/print_xml_receipt',{receipt: r},{timeout: 5000}) .then(function(){ send_printing_job(); - },function(){ + },function(error, event){ self.receipt_queue.unshift(r); + console.log('There was an error while trying to print the order:'); + console.log(error); }); } } @@ -54,7 +56,7 @@ models.load_models({ for(var i = 0; i < printers.length; i++){ if(active_printers[printers[i].id]){ - var url = printers[i].proxy_ip; + var url = printers[i].proxy_ip || ''; if(url.indexOf('//') < 0){ url = 'http://'+url; }