diff --git a/account_invoice_report_printed_flag/README.rst b/account_invoice_report_printed_flag/README.rst new file mode 100644 index 000000000..6c51a5e1b --- /dev/null +++ b/account_invoice_report_printed_flag/README.rst @@ -0,0 +1,142 @@ +=================================== +Account Invoice Report Printed Flag +=================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:36ea8855d6cf033ec95b02386337f6686795535fb802efb5c5bd167552c2f77b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Faccount--invoice--reporting-lightgray.png?logo=github + :target: https://github.com/OCA/account-invoice-reporting/tree/17.0/account_invoice_report_printed_flag + :alt: OCA/account-invoice-reporting +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-invoice-reporting-17-0/account-invoice-reporting-17-0-account_invoice_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/account-invoice-reporting&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends ``account.move`` to support the printed flag +mechanism provided by the ``report_printed_flag`` module. + +It adds printed report tracking capabilities to invoices, bills, and +journal entries. + +It adds a ``printed`` field and integrates printed tracking features +into the accounting user interface. + +Main features: + +- Adds ``printed`` field to ``account.move`` +- Tracks printed reports using the core module +- Displays printed report names per record (optional field) +- Provides direct access to printed logs +- Adds search filters: + + - Printed + - Not Printed + +- Adds group by: + + - Printed + - Printed Report Names + +- Supports multi-company configurations + +Printed report names are computed from related printed logs and +displayed as a comma-separated string. + +.. 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 +===== + +To use this module: + +1. Install this module + +2. Configure reports in: + + *Settings > Printed Flag > Configurations* + +3. Generate an account move report (invoice, bill, or journal entry) + +If properly configured: + +- The record will be marked as: + + printed = True + +- Printed logs will be created (if enabled) + +- Printed report names will be computed (if enabled) + +Known issues / Roadmap +====================== + +- Improve performance for large volumes of logs +- Extend support for additional reporting mechanisms if required +- Enhance usability of printed logs in accounting views + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Binhex Systems Solutions S.L + +Contributors +------------ + +- `Binhex Systems Solutions S.L. `__: + + - Ariel Torres + - Rolando Pérez Rebollo + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/account-invoice-reporting `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_invoice_report_printed_flag/__init__.py b/account_invoice_report_printed_flag/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/account_invoice_report_printed_flag/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_invoice_report_printed_flag/__manifest__.py b/account_invoice_report_printed_flag/__manifest__.py new file mode 100644 index 000000000..22be3e029 --- /dev/null +++ b/account_invoice_report_printed_flag/__manifest__.py @@ -0,0 +1,20 @@ +{ + "name": "Account Invoice Report Printed Flag", + "summary": "Adds printed flag support to account moves", + "version": "17.0.1.0.0", + "category": "Accounting", + "license": "AGPL-3", + "author": "Binhex Systems Solutions S.L, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-invoice-reporting", + "depends": [ + "account", + "report_printed_flag", + ], + "data": [ + "views/account_move_views.xml", + ], + "installable": True, + "application": False, + "development_status": "Alpha", + "images": ["static/description/icon.png"], +} diff --git a/account_invoice_report_printed_flag/i18n/es.po b/account_invoice_report_printed_flag/i18n/es.po new file mode 100644 index 000000000..1f693f49f --- /dev/null +++ b/account_invoice_report_printed_flag/i18n/es.po @@ -0,0 +1,95 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_report_printed_flag +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-04-01 10:20+0000\n" +"PO-Revision-Date: 2026-04-01 10:20+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_invoice_report_printed_flag +#: model:ir.model.fields,help:account_invoice_report_printed_flag.field_account_bank_statement_line__printed_report_names +#: model:ir.model.fields,help:account_invoice_report_printed_flag.field_account_move__printed_report_names +#: model:ir.model.fields,help:account_invoice_report_printed_flag.field_account_payment__printed_report_names +msgid "" +"Comma-separated list of printed report names, computed from related printed " +"logs. Only active if enabled in configuration." +msgstr "" +"Lista de nombres de informes impresos separados por comas, calculada a partir de los registros impresos relacionados." +" Solo se activa si está habilitada en la configuración." + +#. module: account_invoice_report_printed_flag +#: model:ir.model.fields,help:account_invoice_report_printed_flag.field_account_bank_statement_line__printed +#: model:ir.model.fields,help:account_invoice_report_printed_flag.field_account_move__printed +#: model:ir.model.fields,help:account_invoice_report_printed_flag.field_account_payment__printed +msgid "" +"Indicates whether at least one configured report has been printed for this " +"record." +msgstr "" +"Indica si se ha impreso al menos un informe configurado para este registro." + +#. module: account_invoice_report_printed_flag +#: model:ir.model,name:account_invoice_report_printed_flag.model_account_move +msgid "Journal Entry" +msgstr "Asiento contable" + +#. module: account_invoice_report_printed_flag +#: model_terms:ir.ui.view,arch_db:account_invoice_report_printed_flag.view_in_invoice_tree_printed +#: model_terms:ir.ui.view,arch_db:account_invoice_report_printed_flag.view_move_tree_printed +#: model_terms:ir.ui.view,arch_db:account_invoice_report_printed_flag.view_out_invoice_tree_printed +msgid "Logs" +msgstr "Registros" + +#. module: account_invoice_report_printed_flag +#: model_terms:ir.ui.view,arch_db:account_invoice_report_printed_flag.view_account_invoice_search_printed +#: model_terms:ir.ui.view,arch_db:account_invoice_report_printed_flag.view_move_search_printed +msgid "Not Printed" +msgstr "No impreso" + +#. module: account_invoice_report_printed_flag +#: model:ir.model.fields,field_description:account_invoice_report_printed_flag.field_account_bank_statement_line__printed +#: model:ir.model.fields,field_description:account_invoice_report_printed_flag.field_account_move__printed +#: model:ir.model.fields,field_description:account_invoice_report_printed_flag.field_account_payment__printed +#: model_terms:ir.ui.view,arch_db:account_invoice_report_printed_flag.view_account_invoice_search_printed +#: model_terms:ir.ui.view,arch_db:account_invoice_report_printed_flag.view_move_search_printed +msgid "Printed" +msgstr "Impreso" + +#. module: account_invoice_report_printed_flag +#: model:ir.model.fields,field_description:account_invoice_report_printed_flag.field_account_bank_statement_line__printed_log_ids +#: model:ir.model.fields,field_description:account_invoice_report_printed_flag.field_account_move__printed_log_ids +#: model:ir.model.fields,field_description:account_invoice_report_printed_flag.field_account_payment__printed_log_ids +msgid "Printed Log" +msgstr "Registro de impresión" + +#. module: account_invoice_report_printed_flag +#: model_terms:ir.ui.view,arch_db:account_invoice_report_printed_flag.view_account_invoice_search_printed +#: model_terms:ir.ui.view,arch_db:account_invoice_report_printed_flag.view_move_search_printed +msgid "Printed Report Names" +msgstr "Nombres de informes impresos" + +#. module: account_invoice_report_printed_flag +#: model:ir.model.fields,field_description:account_invoice_report_printed_flag.field_account_bank_statement_line__printed_report_names +#: model:ir.model.fields,field_description:account_invoice_report_printed_flag.field_account_move__printed_report_names +#: model:ir.model.fields,field_description:account_invoice_report_printed_flag.field_account_payment__printed_report_names +msgid "Printed Reports Names" +msgstr "Nombres de informes impresos" + +#. module: account_invoice_report_printed_flag +#: model:ir.model.fields,help:account_invoice_report_printed_flag.field_account_bank_statement_line__printed_log_ids +#: model:ir.model.fields,help:account_invoice_report_printed_flag.field_account_move__printed_log_ids +#: model:ir.model.fields,help:account_invoice_report_printed_flag.field_account_payment__printed_log_ids +msgid "" +"Technical relation to printed logs using a generic reference pattern " +"(res_model, res_id). Only logs related to account.move are included." +msgstr "" +"Relación técnica con los registros impresos utilizando un patrón de referencia genérico " +"(res_model, res_id). Solo se incluyen los registros relacionados con account.move." diff --git a/account_invoice_report_printed_flag/models/__init__.py b/account_invoice_report_printed_flag/models/__init__.py new file mode 100644 index 000000000..9c0a42138 --- /dev/null +++ b/account_invoice_report_printed_flag/models/__init__.py @@ -0,0 +1 @@ +from . import account_move diff --git a/account_invoice_report_printed_flag/models/account_move.py b/account_invoice_report_printed_flag/models/account_move.py new file mode 100644 index 000000000..8eae8a928 --- /dev/null +++ b/account_invoice_report_printed_flag/models/account_move.py @@ -0,0 +1,19 @@ +from odoo import models + + +class AccountMove(models.Model): + """ + Extension of ``account.move`` to integrate with the + ``report_printed_flag`` infrastructure via the mixin. + + This module adds: + - A ``printed`` Boolean field (from mixin) + - A ``printed_log_ids`` One2many relation to print logs (from mixin) + - A ``printed_report_names`` computed Char field (from mixin) + - An ``action_view_printed_logs()`` method (from mixin) + + All functionality is provided by ``report.printed.mixin``. + """ + + _name = "account.move" + _inherit = ["account.move", "report.printed.mixin"] diff --git a/account_invoice_report_printed_flag/pyproject.toml b/account_invoice_report_printed_flag/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/account_invoice_report_printed_flag/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_invoice_report_printed_flag/readme/CONFIGURATION.md b/account_invoice_report_printed_flag/readme/CONFIGURATION.md new file mode 100644 index 000000000..53f6f74c8 --- /dev/null +++ b/account_invoice_report_printed_flag/readme/CONFIGURATION.md @@ -0,0 +1,9 @@ +Configuration is managed through the ``report_printed_flag`` module. + +For ``account.move``: + +- Select model: ``account.move`` +- Define report rules +- Optionally enable: + - Printed Logs + - Printed Report Names \ No newline at end of file diff --git a/account_invoice_report_printed_flag/readme/CONTRIBUTORS.md b/account_invoice_report_printed_flag/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..cfdc2ca13 --- /dev/null +++ b/account_invoice_report_printed_flag/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Binhex Systems Solutions S.L.](https://www.binhex.cloud): + - Ariel Torres + - Rolando Pérez Rebollo diff --git a/account_invoice_report_printed_flag/readme/DESCRIPTION.md b/account_invoice_report_printed_flag/readme/DESCRIPTION.md new file mode 100644 index 000000000..815a2cb9a --- /dev/null +++ b/account_invoice_report_printed_flag/readme/DESCRIPTION.md @@ -0,0 +1,25 @@ +This module extends ``account.move`` to support the printed flag +mechanism provided by the ``report_printed_flag`` module. + +It adds printed report tracking capabilities to invoices, +bills, and journal entries. + +It adds a ``printed`` field and integrates printed tracking features +into the accounting user interface. + +Main features: + +- Adds ``printed`` field to ``account.move`` +- Tracks printed reports using the core module +- Displays printed report names per record (optional field) +- Provides direct access to printed logs +- Adds search filters: + - Printed + - Not Printed +- Adds group by: + - Printed + - Printed Report Names +- Supports multi-company configurations + +Printed report names are computed from related printed logs and displayed +as a comma-separated string. \ No newline at end of file diff --git a/account_invoice_report_printed_flag/readme/ROADMAP.md b/account_invoice_report_printed_flag/readme/ROADMAP.md new file mode 100644 index 000000000..ce4c5ae61 --- /dev/null +++ b/account_invoice_report_printed_flag/readme/ROADMAP.md @@ -0,0 +1,3 @@ +* Improve performance for large volumes of logs +* Extend support for additional reporting mechanisms if required +* Enhance usability of printed logs in accounting views \ No newline at end of file diff --git a/account_invoice_report_printed_flag/readme/USAGE.md b/account_invoice_report_printed_flag/readme/USAGE.md new file mode 100644 index 000000000..6e9d05b55 --- /dev/null +++ b/account_invoice_report_printed_flag/readme/USAGE.md @@ -0,0 +1,17 @@ +To use this module: + +1. Install this module +2. Configure reports in: + + *Settings > Printed Flag > Configurations* + +3. Generate an account move report (invoice, bill, or journal entry) + +If properly configured: + +- The record will be marked as: + + printed = True + +- Printed logs will be created (if enabled) +- Printed report names will be computed (if enabled) diff --git a/account_invoice_report_printed_flag/static/description/icon.png b/account_invoice_report_printed_flag/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_invoice_report_printed_flag/static/description/icon.png differ diff --git a/account_invoice_report_printed_flag/static/description/index.html b/account_invoice_report_printed_flag/static/description/index.html new file mode 100644 index 000000000..7d429d02b --- /dev/null +++ b/account_invoice_report_printed_flag/static/description/index.html @@ -0,0 +1,491 @@ + + + + + +Account Invoice Report Printed Flag + + + +
+

Account Invoice Report Printed Flag

+ + +

Alpha License: AGPL-3 OCA/account-invoice-reporting Translate me on Weblate Try me on Runboat

+

This module extends account.move to support the printed flag +mechanism provided by the report_printed_flag module.

+

It adds printed report tracking capabilities to invoices, bills, and +journal entries.

+

It adds a printed field and integrates printed tracking features +into the accounting user interface.

+

Main features:

+
    +
  • Adds printed field to account.move
  • +
  • Tracks printed reports using the core module
  • +
  • Displays printed report names per record (optional field)
  • +
  • Provides direct access to printed logs
  • +
  • Adds search filters:
      +
    • Printed
    • +
    • Not Printed
    • +
    +
  • +
  • Adds group by:
      +
    • Printed
    • +
    • Printed Report Names
    • +
    +
  • +
  • Supports multi-company configurations
  • +
+

Printed report names are computed from related printed logs and +displayed as a comma-separated string.

+
+

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

+ +
+

Usage

+

To use this module:

+
    +
  1. Install this module

    +
  2. +
  3. Configure reports in:

    +

    Settings > Printed Flag > Configurations

    +
  4. +
  5. Generate an account move report (invoice, bill, or journal entry)

    +
  6. +
+

If properly configured:

+
    +
  • The record will be marked as:

    +

    printed = True

    +
  • +
  • Printed logs will be created (if enabled)

    +
  • +
  • Printed report names will be computed (if enabled)

    +
  • +
+
+
+

Known issues / Roadmap

+
    +
  • Improve performance for large volumes of logs
  • +
  • Extend support for additional reporting mechanisms if required
  • +
  • Enhance usability of printed logs in accounting views
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Binhex Systems Solutions S.L
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/account-invoice-reporting project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_invoice_report_printed_flag/tests/__init__.py b/account_invoice_report_printed_flag/tests/__init__.py new file mode 100644 index 000000000..85da74a00 --- /dev/null +++ b/account_invoice_report_printed_flag/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_invoice_report_printed_flag diff --git a/account_invoice_report_printed_flag/tests/test_account_invoice_report_printed_flag.py b/account_invoice_report_printed_flag/tests/test_account_invoice_report_printed_flag.py new file mode 100644 index 000000000..f220adfcc --- /dev/null +++ b/account_invoice_report_printed_flag/tests/test_account_invoice_report_printed_flag.py @@ -0,0 +1,261 @@ +from odoo.tests import tagged + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon + + +@tagged("post_install", "-at_install") +class TestReportPrintedFlagAccount(AccountTestInvoicingCommon): + """ + Test suite for account_invoice_report_printed_flag. + Covers: + - printed flag behavior + - log creation + - printed report names computation + - multi-record handling + - non-configured reports + - UI actions + """ + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.company = cls.env.company + # --------------------------- + # ACCOUNT (provided by AccountTestInvoicingCommon) + # --------------------------- + cls.account = cls.company_data["default_account_receivable"] + # --------------------------- + # ACCOUNT MOVE (invoice) + # --------------------------- + cls.move = cls.env["account.move"].create( + { + "move_type": "out_invoice", + "partner_id": cls.partner_a.id, + "company_id": cls.company.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "name": "Test line", + "quantity": 1, + "price_unit": 100, + "account_id": cls.account.id, + }, + ) + ], + } + ) + # --------------------------- + # QWEB TEMPLATE + # --------------------------- + cls.env["ir.ui.view"].create( + { + "name": "test_account_report_template", + "type": "qweb", + "key": "account_invoice_report_printed_flag.test_template", + "arch": """ + + +
+ +
+
+
+ """, + } + ) + # --------------------------- + # REPORT + # --------------------------- + cls.report = cls.env["ir.actions.report"].create( + { + "name": "Test Account Report", + "model": "account.move", + "report_type": "qweb-pdf", + "report_name": "account_invoice_report_printed_flag.test_template", + } + ) + # --------------------------- + # CONFIG + # --------------------------- + cls.config = cls.env["report.printed.config"].create( + { + "name": "Account Config", + "model_id": cls.env["ir.model"]._get("account.move").id, + "company_id": cls.company.id, + "report_printed_log_active": True, + "report_printed_names_active": True, + "line_ids": [ + ( + 0, + 0, + { + "report_id": cls.report.id, + }, + ) + ], + } + ) + + # --------------------------- + # TESTS + # --------------------------- + def test_printed_flag(self): + """Printing should mark move as printed""" + self.assertFalse(self.move.printed) + self.report._render_qweb_pdf( + self.report.report_name, + self.move.ids, + ) + self.move.invalidate_recordset() + self.assertTrue(self.move.printed) + + def test_log_created(self): + """Printing should create a log entry""" + self.env["report.printed.log"].search([]).unlink() + self.report._render_qweb_pdf( + self.report.report_name, + self.move.ids, + ) + logs = self.env["report.printed.log"].search( + [ + ("res_model", "=", "account.move"), + ("res_id", "=", self.move.id), + ] + ) + self.assertTrue(logs) + + def test_printed_report_names(self): + """Printed report names should be computed""" + self.report._render_qweb_pdf( + self.report.report_name, + self.move.ids, + ) + self.move.invalidate_recordset() + self.assertTrue(self.move.printed_report_names) + self.assertIn("Test Account Report", self.move.printed_report_names) + + def test_multiple_records(self): + """Batch printing should mark all moves""" + move2 = self.move.copy() + self.report._render_qweb_pdf( + self.report.report_name, + (self.move | move2).ids, + ) + self.move.invalidate_recordset() + move2.invalidate_recordset() + self.assertTrue(self.move.printed) + self.assertTrue(move2.printed) + + def test_multiple_logs(self): + """Multiple prints should create multiple logs""" + self.env["report.printed.log"].search([]).unlink() + self.report._render_qweb_pdf( + self.report.report_name, + self.move.ids, + ) + self.report._render_qweb_pdf( + self.report.report_name, + self.move.ids, + ) + logs = self.env["report.printed.log"].search( + [ + ("res_model", "=", "account.move"), + ("res_id", "=", self.move.id), + ] + ) + self.assertEqual( + len(logs), + 2, + "Each report execution should create a separate log entry.", + ) + + def test_report_not_configured(self): + """Non-configured report should not mark printed or create logs.""" + other_report = self.env["ir.actions.report"].create( + { + "name": "Other Report", + "model": "account.move", + "report_type": "qweb-pdf", + "report_name": "account_invoice_report_printed_flag.test_template", + } + ) + self.env["report.printed.log"].search([]).unlink() + self.move.write({"printed": False}) + other_report._render_qweb_pdf( + other_report.report_name, + self.move.ids, + ) + self.move.invalidate_recordset() + logs = self.env["report.printed.log"].search( + [ + ("res_model", "=", "account.move"), + ("res_id", "=", self.move.id), + ] + ) + self.assertFalse(self.move.printed) + self.assertFalse(logs) + + def test_action_view_printed_logs(self): + """UI action should return correct domain.""" + action = self.move.action_view_printed_logs() + self.assertEqual(action["type"], "ir.actions.act_window") + self.assertEqual(action["res_model"], "report.printed.log") + self.assertEqual(action["view_mode"], "tree") + self.assertIn( + ("res_model", "=", "account.move"), + action["domain"], + ) + self.assertIn( + ("res_id", "=", self.move.id), + action["domain"], + ) + + def test_account_move_has_printed_mixin_fields(self): + """Account moves should expose fields provided by the printed mixin.""" + self.assertIn("printed", self.move._fields) + self.assertIn("printed_log_ids", self.move._fields) + self.assertIn("printed_report_names", self.move._fields) + + def test_log_values(self): + """Printed log should contain account move metadata.""" + self.env["report.printed.log"].search([]).unlink() + self.report._render_qweb_pdf( + self.report.report_name, + self.move.ids, + ) + log = self.env["report.printed.log"].search( + [ + ("res_model", "=", "account.move"), + ("res_id", "=", self.move.id), + ], + limit=1, + ) + self.assertTrue(log) + self.assertEqual(log.res_model, "account.move") + self.assertEqual(log.res_id, self.move.id) + self.assertEqual(log.report_id, self.report) + self.assertEqual(log.company_id, self.company) + self.assertEqual(log.user_id, self.env.user) + + def test_logs_disabled(self): + """Logs should not be created when disabled in configuration.""" + self.config.write( + { + "report_printed_log_active": False, + "report_printed_names_active": False, + } + ) + self.env["report.printed.log"].search([]).unlink() + self.report._render_qweb_pdf( + self.report.report_name, + self.move.ids, + ) + logs = self.env["report.printed.log"].search( + [ + ("res_model", "=", "account.move"), + ("res_id", "=", self.move.id), + ] + ) + self.assertFalse(logs) diff --git a/account_invoice_report_printed_flag/views/account_move_views.xml b/account_invoice_report_printed_flag/views/account_move_views.xml new file mode 100644 index 000000000..aa46df534 --- /dev/null +++ b/account_invoice_report_printed_flag/views/account_move_views.xml @@ -0,0 +1,134 @@ + + + + + account.move.tree.printed + account.move + + + + + +