Skip to content

[MIG] iot_print_node: Migration to 20.0 - #521

Open
les-adhoc wants to merge 7 commits into
ingadhoc:20.0from
adhoc-dev:20.0-t-76786-les
Open

les-adhoc wants to merge 7 commits into
ingadhoc:20.0from
adhoc-dev:20.0-t-76786-les

Conversation

@les-adhoc

Copy link
Copy Markdown
Contributor

Tarea: https://www.adhoc.inc/odoo/project.task/76786

What changes

Odoo 20.0 removed ir.actions.report.render_document (the method this module overrode to send IoT print jobs to PrintNode) and the IoT menu it hung from. Printing now goes through the new printer module: printer.printer, ir.actions.report.get_print_jobs and the printer.type.handlers registry in the client.

As decided by the product owner in the task, PrintNode becomes a printer type, following the pattern of Odoo's obox module:

  • printnode.account replaces the IoT box that held the API key. It syncs the account printers as printer.printer records of type printnode (create, update and delete, as in 19.0).
  • get_print_jobs adds a printnode job with the report and its ids, without rendering. The client handler calls printer.printer.printnode_print, which renders the report as the current user and sends it to PrintNode (pdf_base64 for qweb-pdf/pdf/aeroo, raw_base64 for qweb-text), as render_document did in 19.0. Rendering in get_print_jobs would run under the sudo of /web/action/load and with docids as a recordset from report_action.
  • printnode_print only prints reports linked to the printer, and only administrators can set the PrintNode account or identifier of a printer (printer.printer is writable by every internal user).
  • The success notification is shown by the client handler instead of a bus message.

Manifest

  • depends: iot → printer. The module no longer needs IoT (Enterprise); license stays AGPL-3.
  • Adds web.assets_backend for the client handler.

Where it is configured

Settings > Technical > Reporting > PrintNode: accounts, Add PrintNode, Printers and Reset Linked Printers. Account and wizard management is restricted to base.group_system (in 19.0 the wizard was reachable from the IoT app).

Removed symbols

All the 19.0 symbols are ported to the new ones: iot.box.print_node_api_key → printnode.account.print_node_api_key; iot.device.connection = printnode_printer → printer.printer.type = printnode; iot.box._get_response, _print_node_submit_job, action_print_update_devices → same methods on printnode.account; iot.box.open_homepage → printnode.account.action_open_printnode; ir.actions.report.render_document → get_print_jobs + printnode_print + client handler; wizard add.iot.printnode → add.printnode.account.

Data

No data migration script for 19.0 → 20.0: no production database has the module installed in 19.0. A 19.0 database would need its API key and printers moved before the -u.

Tests

The module had no tests in 19.0. New tests for the 20.0 code (10, mocking the PrintNode API): printer sync, connection error, wizard, get_print_jobs without rendering, report_action with a recordset, rendering as the user and sending to PrintNode, no job without a PrintNode printer, report not linked, unsupported report type, internal user cannot point a printer to PrintNode. They pass in a local 20.0 database. The full flow (add account, sync, link a report, print from a quotation) was also checked in the browser against a fake PrintNode API; it was not tested against a real PrintNode account.

Odoo 20.0 removed ir.actions.report.render_document and the IoT menu the
module hooked into: printing now goes through the new printer module
(printer.printer + get_print_jobs + printer.type.handlers in the client).
As decided by the PO in task 76786 (option A), PrintNode becomes a printer
type, following the pattern of Odoo's obox module:

- printnode.account replaces the IoT box with an API key; it syncs its
  printers as printer.printer records of type printnode.
- get_print_jobs adds a printnode job (pdf for qweb-pdf/pdf/aeroo, raw
  for qweb-text) and a client handler sends it with printnode_print.
- The module depends on printer instead of iot (no Enterprise needed).
- Account and wizard management is restricted to Settings admins, under
  Settings > Technical > Reporting > PrintNode.
…user

get_print_jobs also runs from _read_format, under the sudo of
/web/action/load and with active_ids from the client, and from
report_action with docids as a recordset. Rendering there sent the
report rendered as superuser back to the browser and failed with a
recordset. Now get_print_jobs only adds the report and its ids, and
printnode_print renders it as the user right before sending it, as
render_document did in 19.0.

Also:
- printnode_print only prints reports linked to the printer.
- Only administrators can set the PrintNode account or identifier of a
  printer: printer.printer is writable by every internal user.
- The views add their condition to ip_address instead of replacing the
  ones of iot and obox.
- Add the Reset Linked Printers menu that the IoT app gave in 19.0.
@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

@les-adhoc
les-adhoc marked this pull request as ready for review November 13, 2026 16:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants