Skip to content

Commit

Permalink
[IMP] base_report_to_printer: Set Server and Port before opening Conn…
Browse files Browse the repository at this point in the history
…ection in case of remote cups Server according to OpenPrinting/pycups#30
  • Loading branch information
baguenth authored and Tobias Sorg committed Jun 18, 2024
2 parents a00c6aa + e9eedda commit 6f3ad33
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base_report_to_printer/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),"
Expand Down
2 changes: 2 additions & 0 deletions base_report_to_printer/models/printing_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = _(
Expand Down
26 changes: 25 additions & 1 deletion base_report_to_printer/static/src/js/qweb_action_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 6f3ad33

Please sign in to comment.