diff --git a/base_report_to_printer/__manifest__.py b/base_report_to_printer/__manifest__.py index dc96ad25fc7..f55a955536f 100644 --- a/base_report_to_printer/__manifest__.py +++ b/base_report_to_printer/__manifest__.py @@ -7,7 +7,7 @@ { "name": "Report to printer", - "version": "13.0.1.7.0", + "version": "13.0.1.8.1", "category": "Generic Modules/Base", "author": "Agile Business Group & Domsense, Pegueroles SCP, NaN," " LasLabs, Camptocamp, Odoo Community Association (OCA)," diff --git a/base_report_to_printer/models/printing_server.py b/base_report_to_printer/models/printing_server.py index 6ae2c6c14f3..637752c940c 100644 --- a/base_report_to_printer/models/printing_server.py +++ b/base_report_to_printer/models/printing_server.py @@ -36,6 +36,8 @@ def _open_connection(self, raise_on_error=False): self.ensure_one() connection = False try: + cups.setServer(self.address) + cups.setPort(self.port) connection = cups.Connection(host=self.address, port=self.port) except Exception: message = _( diff --git a/base_report_to_printer/static/src/js/qweb_action_manager.js b/base_report_to_printer/static/src/js/qweb_action_manager.js index 67a495bea4e..d37cdf0b5a2 100644 --- a/base_report_to_printer/static/src/js/qweb_action_manager.js +++ b/base_report_to_printer/static/src/js/qweb_action_manager.js @@ -5,6 +5,7 @@ odoo.define("base_report_to_printer.print", function(require) { var core = require("web.core"); var _t = core._t; var framework = require("web.framework"); + var session = require("web.session"); ActionManager.include({ _triggerDownload: function(action, options, type) { @@ -60,7 +61,30 @@ odoo.define("base_report_to_printer.print", function(require) { ); } else { framework.unblockUI(); - return _super.apply(self, [action, options, type]); + const forceClientActionKey = "printing_force_client_action"; + // Update user context with forceClientActionKey if it is present + // in the action context + if (action.context) { + for (var key in action.context) { + if (key === forceClientActionKey) { + session.user_context[key] = action.context[key]; + } + } + } + return _super + .apply(self, [action, options, type]) + .then(function() { + // After the reporting action was called, we need to + // remove the added context again. Otherwise it will + // remain in the user context permanently + if ( + session.user_context.hasOwnProperty( + forceClientActionKey + ) + ) { + delete session.user_context[forceClientActionKey]; + } + }); } }); } else {