From d751db0a1bbc3dfb9c4ae83cdc600617d31527b6 Mon Sep 17 00:00:00 2001 From: atg Date: Wed, 6 May 2026 15:18:32 +0200 Subject: [PATCH] [ADD] report_printed_flag: add configurable printed report tracking framework This module provides a reusable framework to track printed QWeb PDF reports across business models. It introduces: - printed configuration models - printed logs - reusable printed mixin - report integration hooks Features: - configurable printed tracking per model and report - optional printed logs - optional printed report names - multi-company support - reusable mixin for extension modules The implementation is designed to be extended by satellite modules such as account and stock integrations. --- report_printed_flag/README.rst | 184 ++++++ report_printed_flag/__init__.py | 1 + report_printed_flag/__manifest__.py | 22 + report_printed_flag/i18n/es.po | 284 ++++++++++ report_printed_flag/models/__init__.py | 4 + .../models/ir_actions_report.py | 105 ++++ .../models/report_printed_config.py | 198 +++++++ .../models/report_printed_log.py | 42 ++ .../models/report_printed_mixin.py | 142 +++++ report_printed_flag/pyproject.toml | 3 + report_printed_flag/readme/CONFIGURATION.md | 19 + report_printed_flag/readme/CONTRIBUTORS.md | 3 + report_printed_flag/readme/DESCRIPTION.md | 34 ++ report_printed_flag/readme/ROADMAP.md | 4 + report_printed_flag/readme/TECHNICAL.md | 74 +++ report_printed_flag/readme/TESTING.md | 19 + report_printed_flag/readme/USAGE.md | 48 ++ .../security/ir.model.access.csv | 4 + report_printed_flag/security/security.xml | 8 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 534 ++++++++++++++++++ report_printed_flag/tests/__init__.py | 1 + report_printed_flag/tests/test_models.py | 21 + .../tests/test_report_printed_flag.py | 496 ++++++++++++++++ report_printed_flag/views/menu_views.xml | 23 + .../views/report_printed_config_views.xml | 103 ++++ .../views/report_printed_log_views.xml | 65 +++ 27 files changed, 2441 insertions(+) create mode 100644 report_printed_flag/README.rst create mode 100644 report_printed_flag/__init__.py create mode 100644 report_printed_flag/__manifest__.py create mode 100644 report_printed_flag/i18n/es.po create mode 100644 report_printed_flag/models/__init__.py create mode 100644 report_printed_flag/models/ir_actions_report.py create mode 100644 report_printed_flag/models/report_printed_config.py create mode 100644 report_printed_flag/models/report_printed_log.py create mode 100644 report_printed_flag/models/report_printed_mixin.py create mode 100644 report_printed_flag/pyproject.toml create mode 100644 report_printed_flag/readme/CONFIGURATION.md create mode 100644 report_printed_flag/readme/CONTRIBUTORS.md create mode 100644 report_printed_flag/readme/DESCRIPTION.md create mode 100644 report_printed_flag/readme/ROADMAP.md create mode 100644 report_printed_flag/readme/TECHNICAL.md create mode 100644 report_printed_flag/readme/TESTING.md create mode 100644 report_printed_flag/readme/USAGE.md create mode 100644 report_printed_flag/security/ir.model.access.csv create mode 100644 report_printed_flag/security/security.xml create mode 100644 report_printed_flag/static/description/icon.png create mode 100644 report_printed_flag/static/description/index.html create mode 100644 report_printed_flag/tests/__init__.py create mode 100644 report_printed_flag/tests/test_models.py create mode 100644 report_printed_flag/tests/test_report_printed_flag.py create mode 100644 report_printed_flag/views/menu_views.xml create mode 100644 report_printed_flag/views/report_printed_config_views.xml create mode 100644 report_printed_flag/views/report_printed_log_views.xml diff --git a/report_printed_flag/README.rst b/report_printed_flag/README.rst new file mode 100644 index 0000000000..3b122084d0 --- /dev/null +++ b/report_printed_flag/README.rst @@ -0,0 +1,184 @@ +=================== +Report Printed Flag +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5d5058bfc9e97f0956c7e54b952e643c0f1a9dcb2ac49f57270d430c82c62804 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github + :target: https://github.com/OCA/reporting-engine/tree/17.0/report_printed_flag + :alt: OCA/reporting-engine +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/reporting-engine-17-0/reporting-engine-17-0-report_printed_flag + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module provides a generic and extensible configuration layer to +mark records as printed when specific PDF reports are generated. + +Main features: + +- **Reusable Mixin** (``report.printed.mixin``) that any model can + inherit to gain: + + - A ``printed`` Boolean field + - A ``printed_log_ids`` One2many relation to audit logs + - A ``printed_report_names`` computed field with printed report names + - An ``action_view_printed_logs()`` method + +- Generic configuration per company and model +- Per-report configuration using rules +- Optional domain conditions per report +- Automatic printed flag update +- Optional logging of report executions +- Optional computation of printed report names +- Full multi-company support with isolated configurations +- User interface for browsing printed report logs + +Extension modules simply inherit the mixin: + +.. code:: python + + class AccountMove(models.Model): + _name = 'account.move' + _inherit = ['account.move', 'report.printed.mixin'] + +All printed flag functionality is inherited automatically. + +Limitations: + +- Only applies to QWeb PDF reports (``qweb-pdf``) +- Extension modules must inherit ``report.printed.mixin`` to gain + printed field support +- Domain expressions must be valid Python domains + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +For End Users +============= + +1. Install ``report_printed_flag`` module +2. Install extension modules that support printed flags (e.g., + ``report_printed_flag_account``) +3. Go to *Settings > Reporting > Printed Flag > Configurations* +4. Create a configuration for your model (Company + Model) +5. Add report rules (select report + optional domain condition) +6. Generate a configured report from a document (e.g., print an invoice) + +Result: + +- The ``printed`` field is automatically set to ``True`` +- A log entry is created (if enabled in configuration) +- Printed report names are computed (if enabled in configuration) + +Access logs via: + +*Settings > Reporting > Printed Flag > Logs* + +For Module Developers +===================== + +To add printed flag support to a custom model: + +1. Create your model inheriting from ``report.printed.mixin``: + + class MyModel(models.Model): \_name = 'my.model' \_inherit = + ['my.model', 'report.printed.mixin'] + +2. Create QWeb PDF reports for your model (standard Odoo process) + +3. Instruct users to configure which reports trigger the printed flag + via the UI + +That's it! The mixin provides all field and method implementations +automatically. + +Optional: Add UI Elements +------------------------- + +You may optionally add buttons to your views to open the logs: + +:: + +