main.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. window.pdfjsLib.GlobalWorkerOptions.workerSrc = '/print_engine/static/lib/js/pdf.worker.js';
  2. openerp.pdfJs = window.pdfjsLib || {};
  3. openerp.printJs = window.printJS || {};
  4. openerp.print_engine = function (instance, local) {
  5. local.SocketManager = instance.web.Class.extend({
  6. init: function () {
  7. this.socket = null;
  8. this.start();
  9. },
  10. start: function () {
  11. this.open_socket();
  12. },
  13. open_socket: function () {
  14. var self = this;
  15. var setup = self.setup_socket = function (config) {
  16. self.config = config;
  17. self.config.is_mobile = self.is_mobile_browser()
  18. if (!self.config.is_mobile) {
  19. self.socket = io(location.protocol + '//' + config.host + ':' + config.port, {
  20. path: config.path
  21. });
  22. self.socket.on('connect', self.handle_connect);
  23. self.socket.on('error', self.handle_error);
  24. self.socket.on('connect_error', self.handle_connect_error);
  25. self.socket.on('request_printer_name', self.handle_printer_selection);
  26. self.socket.on('show_print_status', self.handle_print_status);
  27. self.socket.on('download_data', self.handle_download_data);
  28. }
  29. }
  30. this.get_socket_config().then(setup);
  31. },
  32. update_config: function () {
  33. instance.web.blockUI();
  34. var self = this;
  35. this.get_socket_config().then(function (config) {
  36. instance.web.unblockUI();
  37. self.config = _.extend(self.config, config);
  38. self.socket.destroy();
  39. self.setup_socket(config);
  40. });
  41. },
  42. handle_connect: function () {
  43. $('#printer-status').removeClass();
  44. $('#printer-status').addClass('printer-status-online');
  45. },
  46. handle_error: function (e) {
  47. instance.webclient.crashmanager.show_message(e);
  48. },
  49. handle_connect_error: function (e) {
  50. $('#printer-status').removeClass();
  51. $('#printer-status').addClass('printer-status-offline');
  52. },
  53. handle_printer_selection: function (data) {
  54. instance.web.unblockUI();
  55. var self = this;
  56. if (data.printers && data.printers.length === 0) {
  57. instance.web.notification.do_notify('Impresión', 'No hay impresoras instaladas');
  58. return;
  59. }
  60. var widget = new local.PrinterSelectionDialog(data);
  61. widget.get_selection().then(function (request) {
  62. self.emit('request_print', request);
  63. });
  64. },
  65. handle_print_status: function (data) {
  66. instance.web.unblockUI();
  67. if (_.isEqual(data.status, 'failed')) {
  68. instance.web.notification.do_warn('Impresión', 'Ha fallado la cola de impresión');
  69. return;
  70. }
  71. if (_.isEqual(data.status, 'canceled')) {
  72. instance.web.notification.do_notify('Impresión', 'Se ha cancelado la impresión');
  73. return;
  74. }
  75. if (_.isEqual(data.status, 'unknown')) {
  76. instance.web.notification.do_warn('Impresión', 'Imposible imprimir un formato de datos desconocido');
  77. return;
  78. }
  79. if (_.isEqual(data.status, 'printing')) {
  80. instance.web.notification.do_notify('Impresión', 'La impresora ' + data.printer + ' está imprimiendo');
  81. return;
  82. }
  83. if (_.isEqual(data.status, 'printed')) {
  84. instance.web.notification.do_notify('Impresión', 'La impresora ' + data.printer + ' finalizó la impresión');
  85. return;
  86. }
  87. if (_.isEqual(data.status, 'error')) {
  88. instance.web.notification.do_warn('Impresión', 'Ocurrió un error al imprimir: ' + data.printer);
  89. }
  90. },
  91. handle_download_data: function (data) {
  92. instance.web.blockUI();
  93. instance.pdfJs.getDocument({
  94. data: atob(data)
  95. }).then(function (pdf) {
  96. if (local.socket_manager.config.action_download_pdf) {
  97. pdf.getData().then(function (data) {
  98. instance.web.unblockUI();
  99. var url = instance.pdfJs.createObjectURL(data, 'application/pdf');
  100. var a = document.createElement('a');
  101. a.href = url;
  102. a.download = 'download.pdf';
  103. a.target = '_parent';
  104. a.click();
  105. });
  106. return;
  107. }
  108. new local.PdfViewerDialog(null, pdf);
  109. });
  110. },
  111. get_socket_config: function () {
  112. var url = '/print_engine/socket_config';
  113. return this.get_from_server(url);
  114. },
  115. get_from_server: function (url) {
  116. instance.web.blockUI();
  117. return $.Deferred(function (d) {
  118. instance.web.jsonRpc(url, 'call').done(function () {
  119. instance.web.unblockUI();
  120. d.resolve.apply(d, arguments);
  121. }).fail(function (e) {
  122. instance.web.unblockUI();
  123. d.reject.apply(d, arguments);
  124. });
  125. });
  126. },
  127. is_mobile_browser: function () {
  128. var userAgent = navigator.userAgent;
  129. return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(userAgent.substr(0, 4));
  130. },
  131. request_print: function (data, print_directly) {
  132. if (!data) {
  133. instance.web.notification.do_warn('Impresión', 'No hay datos para imprimir');
  134. return;
  135. }
  136. if (!this.socket || !this.socket.connected) {
  137. instance.web.notification.do_warn('Impresión', 'La impresora no está preparada');
  138. return;
  139. }
  140. instance.web.blockUI();
  141. var mime_type = 'data:application/pdf;base64,';
  142. if (data instanceof Uint8Array) {
  143. data = mime_type + btoa(String.fromCharCode.apply(null, data));
  144. }
  145. if (!data.startsWith(mime_type)) {
  146. data = mime_type + data;
  147. }
  148. try {
  149. atob(data.replace(mime_type, ''));
  150. this.socket.emit('request_print', {
  151. print_directly: print_directly || this.config.print_directly,
  152. data: data
  153. });
  154. } catch (e) {
  155. instance.web.unblockUI();
  156. instance.webclient.crashmanager.show_message(e);
  157. }
  158. }
  159. });
  160. local.DownloadPrinterTools = instance.web.Widget.extend({
  161. template: 'DownloadPrinterTools',
  162. events: {
  163. 'click .download_button': 'handle_download'
  164. },
  165. init: function (parent) {
  166. this._super(parent);
  167. },
  168. start: function () {
  169. this.renderElement();
  170. this.$el.appendTo($('body'));
  171. this.$el.on('hidden.bs.modal', this, this.on_hide);
  172. if (this.is_linux_platform()) {
  173. this.$('.download_logo_windows').css('display', 'none');
  174. this.$('.windows_download_button').css('display', 'none');
  175. }
  176. if (this.is_win_platform()) {
  177. this.$('.download_logo_linux').css('display', 'none');
  178. this.$('.linux_download_button').css('display', 'none');
  179. }
  180. this.$el.modal('show');
  181. },
  182. on_hide: function (e) {
  183. var self = e.data;
  184. self.$el.remove();
  185. self.destroy();
  186. },
  187. is_win_platform: function () {
  188. return /^Win(?:32|64)$/.test(navigator.platform);
  189. },
  190. is_linux_platform: function () {
  191. return /^Linux\sx86(?:|_64)$/.test(navigator.platform);
  192. },
  193. handle_download: function (e) {
  194. var download_url = 'https://repo.eiru.com.py/attachments/';
  195. if (this.is_linux_platform()) {
  196. download_url += '94bcc4d4-8fe7-45f9-8715-97c11fdcdd6f';
  197. }
  198. if (this.is_win_platform()) {
  199. download_url += '8b9b5283-c5f8-4a62-a798-2691b72936bd';
  200. }
  201. var a = document.createElement('a');
  202. a.href = download_url;
  203. a.target = '_parent';
  204. a.click();
  205. this.$el.modal('hide');
  206. }
  207. });
  208. local.PrinterTopNotificator = instance.web.Widget.extend({
  209. template: 'PrinterTopNotificator',
  210. events: {
  211. 'click .printer_status_notificator': 'handle_click'
  212. },
  213. init: function (parent) {
  214. this._super(parent);
  215. },
  216. handle_click: function (e) {
  217. e.preventDefault();
  218. if (local.socket_manager.socket.disconnected) {
  219. var widget = new local.DownloadPrinterTools(this);
  220. widget.start();
  221. }
  222. }
  223. });
  224. local.PrinterUnavailableDialog = instance.web.Widget.extend({
  225. template: 'PrinterUnavailableDialog',
  226. events: {
  227. 'click li': 'on_download'
  228. },
  229. init: function (parent) {
  230. this._super(parent);
  231. this.start();
  232. },
  233. start: function () {
  234. this.defer = $.Deferred();
  235. this.render_widget();
  236. },
  237. render_widget: function () {
  238. this.renderElement();
  239. $('body').append(this.$el);
  240. this.$el.on('hidden.bs.modal', this, this.on_hide);
  241. this.$el.modal('show');
  242. },
  243. on_download: function () {
  244. this.download_pdf = true;
  245. this.$el.modal('hide');
  246. },
  247. on_hide: function (e) {
  248. var self = e.data;
  249. self.defer.resolve(!!self.download_pdf);
  250. self.destroy();
  251. self.$el.remove();
  252. },
  253. can_download: function () {
  254. return this.defer;
  255. }
  256. });
  257. local.PrinterSelectionDialog = instance.web.Widget.extend({
  258. template: 'PrinterSelectionDialog',
  259. events: {
  260. 'click li': 'on_select'
  261. },
  262. init: function (data) {
  263. var config = local.socket_manager.config;
  264. this.download_pdf = config.action_download_pdf || config.action_preview_pdf || false;
  265. this.printers = data.printers || [];
  266. this.id = data.id;
  267. this.start();
  268. },
  269. start: function () {
  270. this.defer = $.Deferred();
  271. this.render_widget();
  272. },
  273. render_widget: function () {
  274. this.renderElement();
  275. $('body').append(this.$el);
  276. this.$el.on('hidden.bs.modal', this, this.on_hide);
  277. this.$el.modal('show');
  278. },
  279. get_selection: function () {
  280. return this.defer;
  281. },
  282. on_select: function (e) {
  283. var $el = $(e.target).closest('li');
  284. var name = $el.data('name');
  285. this.selected_printer = name;
  286. this.$el.modal('hide');
  287. },
  288. on_hide: function (e) {
  289. var self = e.data;
  290. self.defer.resolve({
  291. id: self.id,
  292. printer: self.selected_printer,
  293. print_directly: true
  294. });
  295. self.$el.remove();
  296. }
  297. });
  298. local.PdfViewerDialog = instance.web.Widget.extend({
  299. template: 'PdfViewerDialog',
  300. events: {
  301. 'click a.btn': 'on_action'
  302. },
  303. init: function (parent, source, name) {
  304. this._super(parent);
  305. this.source = source;
  306. this.name = name;
  307. this.set('current_page', -1);
  308. this.on('change:current_page', this, this.render_page);
  309. if (_.isObject(this.source)) {
  310. this.pdf = source;
  311. this.render_widget();
  312. return;
  313. }
  314. var matchReportUrl = this.source.match(/(?:\/(?:web\/)?report(?:\/pdf)?)/);
  315. if (matchReportUrl) {
  316. var self = this;
  317. instance.web.blockUI();
  318. instance.pdfJs.getDocument(self.source).then(function (pdf) {
  319. self.pdf = pdf;
  320. self.render_widget();
  321. });
  322. return;
  323. }
  324. var matchMimeType = this.source.match(/data:[a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+.*,/);
  325. if (matchMimeType) {
  326. if (self.source.startsWith('data:application/pdf;base64,')) {
  327. self.source = {
  328. data: self.source
  329. };
  330. }
  331. }
  332. try {
  333. atob(this.source.data || this.source);
  334. } catch (e) {
  335. instance.webclient.crashmanager.show_message('Unknown data format');
  336. }
  337. var self = this;
  338. instance.web.blockUI();
  339. instance.pdfJs.getDocument(self.source.data || self.source).then(function (pdf) {
  340. self.pdf = pdf;
  341. self.render_widget();
  342. });
  343. },
  344. render_widget: function () {
  345. this.renderElement();
  346. $('body').append(this.$el);
  347. this.$el.on('shown.bs.modal', this, this.render_pdf);
  348. this.$el.on('hidden.bs.modal', this, this.on_hide);
  349. this.$el.modal('show');
  350. },
  351. render_pdf: function (e) {
  352. var self = e.data;
  353. if (!self.pdf) {
  354. instance.web.unblockUI();
  355. instance.web.notification.do_warn('No hay archivo PDF');
  356. return;
  357. }
  358. self.set('current_page', 1);
  359. },
  360. render_page: function () {
  361. var self = this;
  362. var current_page = self.get('current_page');
  363. self.pdf.getPage(current_page).then(function (page) {
  364. var scale = 1;
  365. var viewport = page.getViewport(scale);
  366. var $canvas = self.$el.find('canvas');
  367. var context = $canvas.get(0).getContext('2d');
  368. $canvas.attr('height', viewport.height);
  369. $canvas.attr('width', viewport.width);
  370. page.render({
  371. canvasContext: context,
  372. viewport: viewport
  373. }).then(function () {
  374. self.$('.page_counter').text('Página ' + current_page + ' de ' + self.pdf.numPages);
  375. instance.web.unblockUI();
  376. });
  377. }, function (error) {
  378. instance.web.unblockUI();
  379. instance.webclient.crashmanager.show_message(error);
  380. });
  381. },
  382. on_hide: function (e) {
  383. var self = e.data;
  384. if (self.pdf) {
  385. self.pdf.destroy();
  386. }
  387. self.destroy();
  388. self.$el.remove();
  389. },
  390. on_action: function (e) {
  391. e.preventDefault();
  392. var action = $(e.target).closest('a').data('action');
  393. this['on_' + action]();
  394. },
  395. on_next: function () {
  396. var current_page = this.get('current_page');
  397. if (current_page >= this.pdf.numPages) {
  398. return;
  399. }
  400. this.set('current_page', current_page + 1);
  401. },
  402. on_previous: function () {
  403. var current_page = this.get('current_page');
  404. if (current_page <= 1) {
  405. return;
  406. }
  407. this.set('current_page', current_page - 1);
  408. },
  409. on_print: function () {
  410. var self = this;
  411. if (!self.pdf) {
  412. return;
  413. }
  414. self.pdf.getData().then(function (data) {
  415. instance.printJs({
  416. printable: instance.pdfJs.createObjectURL(data, 'application/pdf')
  417. });
  418. });
  419. },
  420. on_download: function () {
  421. var self = this;
  422. if (!self.pdf) {
  423. return;
  424. }
  425. self.pdf.getMetadata().then(function (metadata) {
  426. self.pdf.getData().then(function (data) {
  427. var url = instance.pdfJs.createObjectURL(data, 'application/pdf');
  428. var a = document.createElement('a');
  429. a.href = url;
  430. a.download = (self.name || metadata.contentDispositionFilename) + '.pdf';
  431. a.target = '_parent';
  432. a.click();
  433. });
  434. });
  435. }
  436. });
  437. if (instance.web) {
  438. if (instance.web.UserMenu) {
  439. instance.web.UserMenu.include({
  440. do_update: function () {
  441. var printer = new local.PrinterTopNotificator(this);
  442. printer.appendTo($('.oe_systray'));
  443. local.socket_manager = new local.SocketManager();
  444. return this._super.apply(this, arguments);
  445. }
  446. });
  447. }
  448. if (instance.web.FormView) {
  449. instance.web.FormView.include({
  450. record_saved: function (r) {
  451. if (this.model === 'res.users') {
  452. local.socket_manager.update_config();
  453. }
  454. return this._super.apply(this, arguments);
  455. }
  456. });
  457. }
  458. if (instance.web.ActionManager) {
  459. instance.web.ActionManager.include({
  460. trigger_preview_pdf: function (action) {
  461. var self = this;
  462. var regex = /^(?:qweb-(pdf|html)|controller)$/;
  463. if (_.has(action, 'report_type') && regex.test(action.report_type)) {
  464. var format = action.report_type.match(regex)[1];
  465. var url = (format || action.report_file) && ('/report/' + format + '/' + action.report_name);
  466. if (_.isEmpty(action.data) && _.has(action.context, 'active_ids')) {
  467. url += '/' + action.context.active_ids.join(',');
  468. } else {
  469. url += '?options=' + encodeURIComponent(JSON.stringify(action.data)) + '&context=' + encodeURIComponent(JSON.stringify(action.context));
  470. }
  471. new local.PdfViewerDialog(self, url, action.name);
  472. return;
  473. }
  474. var params = {
  475. action: JSON.stringify(action),
  476. token: (new Date()).getTime()
  477. };
  478. new local.PdfViewerDialog(self, this.session.url('/web/report', params), action.name);
  479. },
  480. trigger_download_pdf: function (action) {
  481. var regex = /^(?:qweb-(pdf|html)|controller)$/;
  482. var url = null;
  483. instance.web.blockUI();
  484. if (_.has(action, 'report_type') && regex.test(action.report_type)) {
  485. var format = action.report_type.match(regex)[1];
  486. url = (format || action.report_file) && ('/report/' + format + '/' + action.report_name);
  487. if (_.isEmpty(action.data) && _.has(action.context, 'active_ids')) {
  488. url += '/' + action.context.active_ids.join(',');
  489. } else {
  490. url += '?options=' + encodeURIComponent(JSON.stringify(action.data)) + '&context=' + encodeURIComponent(JSON.stringify(action.context));
  491. }
  492. }
  493. if (!url) {
  494. var params = {
  495. action: JSON.stringify(action),
  496. token: (new Date()).getTime()
  497. };
  498. url = this.session.url('/web/report', params);
  499. }
  500. instance.pdfJs.getDocument(url).then(function (pdf) {
  501. pdf.getData().then(function (data) {
  502. instance.web.unblockUI();
  503. var url = instance.pdfJs.createObjectURL(data, 'application/pdf');
  504. var a = document.createElement('a');
  505. a.href = url;
  506. a.download = (action.name || action.report_name) + '.pdf';
  507. a.target = '_parent';
  508. a.click();
  509. pdf.destroy();
  510. });
  511. });
  512. },
  513. trigger_print_pdf: function (action) {
  514. var url = '/print_engine/get_pdf';
  515. var ctx = _.clone(action.context);
  516. ctx.report_name = action.report_name;
  517. instance.web.jsonRpc(url, 'call', {
  518. context: ctx
  519. }).done(function (result) {
  520. local.socket_manager.request_print(result.data);
  521. }).fail(function (e) {
  522. instance.webclient.crashmanager.show_message(e);
  523. });
  524. },
  525. ir_actions_report_xml: function (action, options) {
  526. var self = this;
  527. var config = local.socket_manager.config;
  528. var eval_contexts = ([instance.session.user_context] || []).concat([action.context]);
  529. action.context = instance.web.pyeval.eval('contexts', eval_contexts);
  530. if (config.is_mobile) {
  531. this.trigger_preview_pdf(action);
  532. return;
  533. }
  534. if (instance.print_engine.socket_manager.socket.disconnected) {
  535. if (config.action_download_pdf) {
  536. self.trigger_download_pdf(action);
  537. return;
  538. }
  539. var widget = new local.PrinterUnavailableDialog(this);
  540. widget.can_download().then(function (can_download) {
  541. if (!can_download) {
  542. return;
  543. }
  544. if (config.action_preview_pdf) {
  545. self.trigger_preview_pdf(action);
  546. return;
  547. }
  548. self.trigger_download_pdf(action);
  549. });
  550. return;
  551. }
  552. self.trigger_print_pdf(action);
  553. }
  554. });
  555. }
  556. }
  557. }