From 2da7be97da74c1224ab515651552935d8ee1fda6 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Wed, 6 May 2026 17:13:55 +0200 Subject: [PATCH] [IMP] account_invoice_report_grouped_by_picking: make grouping by picking optional --- .../README.rst | 6 +--- .../__manifest__.py | 2 +- .../models/__init__.py | 1 + .../models/account_journal.py | 15 ++++++++++ .../models/account_move.py | 9 ++++++ .../static/description/index.html | 28 ++++++++----------- .../test_account_invoice_group_picking.py | 27 ++++++++++++++++++ .../views/account_journal_views.xml | 26 +++++++++++++++++ .../views/report_invoice.xml | 9 ++++-- 9 files changed, 98 insertions(+), 25 deletions(-) create mode 100644 account_invoice_report_grouped_by_picking/models/account_journal.py create mode 100644 account_invoice_report_grouped_by_picking/views/account_journal_views.xml diff --git a/account_invoice_report_grouped_by_picking/README.rst b/account_invoice_report_grouped_by_picking/README.rst index d8112a37d..d2a301c4a 100644 --- a/account_invoice_report_grouped_by_picking/README.rst +++ b/account_invoice_report_grouped_by_picking/README.rst @@ -1,7 +1,3 @@ -.. image:: https://odoo-community.org/readme-banner-image - :target: https://odoo-community.org/get-involved?utm_source=readme - :alt: Odoo Community Association - ================================== Account Invoice Grouped by Picking ================================== @@ -17,7 +13,7 @@ Account Invoice Grouped by Picking .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png +.. |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 diff --git a/account_invoice_report_grouped_by_picking/__manifest__.py b/account_invoice_report_grouped_by_picking/__manifest__.py index 3f3f6686c..ddb858090 100644 --- a/account_invoice_report_grouped_by_picking/__manifest__.py +++ b/account_invoice_report_grouped_by_picking/__manifest__.py @@ -13,6 +13,6 @@ "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "depends": ["sale_stock_picking_invoice_link"], - "data": ["views/report_invoice.xml"], + "data": ["views/report_invoice.xml", "views/account_journal_views.xml"], "installable": True, } diff --git a/account_invoice_report_grouped_by_picking/models/__init__.py b/account_invoice_report_grouped_by_picking/models/__init__.py index 9c0a42138..ea6d653c8 100644 --- a/account_invoice_report_grouped_by_picking/models/__init__.py +++ b/account_invoice_report_grouped_by_picking/models/__init__.py @@ -1 +1,2 @@ from . import account_move +from . import account_journal diff --git a/account_invoice_report_grouped_by_picking/models/account_journal.py b/account_invoice_report_grouped_by_picking/models/account_journal.py new file mode 100644 index 000000000..970356135 --- /dev/null +++ b/account_invoice_report_grouped_by_picking/models/account_journal.py @@ -0,0 +1,15 @@ +# © 2026 Solvos Consultoría Informática () +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html + +from odoo import fields, models + + +class AccountJournal(models.Model): + _inherit = "account.journal" + + show_group_by_picking_report = fields.Boolean( + default=True, + string="Invoice Report - Show Grouped by Picking", + help="Leave unmarked if original Odoo behavior (not grouped" + " is required for invoices belonging this journal.", + ) diff --git a/account_invoice_report_grouped_by_picking/models/account_move.py b/account_invoice_report_grouped_by_picking/models/account_move.py index 9a6b3fc39..39e3f977e 100644 --- a/account_invoice_report_grouped_by_picking/models/account_move.py +++ b/account_invoice_report_grouped_by_picking/models/account_move.py @@ -59,6 +59,15 @@ def lines_grouped_by_picking(self): """This prepares a data structure for printing the invoice report grouped by pickings.""" self.ensure_one() + if not self.journal_id.show_group_by_picking_report: + return [ + { + "picking": self.env["stock.picking"], + "line": line, + "quantity": line.quantity, + } + for line in self.invoice_line_ids + ] picking_dict = {} lines_dict = {} picking_obj = self.env["stock.picking"] diff --git a/account_invoice_report_grouped_by_picking/static/description/index.html b/account_invoice_report_grouped_by_picking/static/description/index.html index 28e413937..10c3fb3e5 100644 --- a/account_invoice_report_grouped_by_picking/static/description/index.html +++ b/account_invoice_report_grouped_by_picking/static/description/index.html @@ -3,7 +3,7 @@ -README.rst +Account Invoice Grouped by Picking -
+
+

Account Invoice Grouped by Picking

- - -Odoo Community Association - -
-

Account Invoice Grouped by Picking

-

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

+

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

This module allows print invoices with picking info. This module groups invoice lines and shows information related to sales and pickings on every group.

@@ -396,7 +391,7 @@

Account Invoice Grouped by Picking

-

Usage

+

Usage

  1. Create several quotation orders and confirm them.
  2. Deliver pickings related to each sale order.
  3. @@ -408,7 +403,7 @@

    Usage

-

Bug Tracker

+

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 @@ -416,15 +411,15 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Tecnativa
-

Contributors

+

Contributors

-

Other credits

+

Other credits

The migration of this module from 16.0 to 17.0 was financially supported by Camptocamp.

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association @@ -464,6 +459,5 @@

Maintainers

-
diff --git a/account_invoice_report_grouped_by_picking/tests/test_account_invoice_group_picking.py b/account_invoice_report_grouped_by_picking/tests/test_account_invoice_group_picking.py index 68a5a958e..8224bc4d9 100644 --- a/account_invoice_report_grouped_by_picking/tests/test_account_invoice_group_picking.py +++ b/account_invoice_report_grouped_by_picking/tests/test_account_invoice_group_picking.py @@ -320,3 +320,30 @@ def test_account_invoice_group_picking_refund_without_return(self): self.assertEqual(self._count_sale_in_picking_header(content, self.sale.name), 1) # information about pickings is printed self.assertTrue(picking.name in tbody) + + def test_account_invoice_group_picking_disabled(self): + self.sale.action_confirm() + self.sale.picking_ids[:1].action_confirm() + self.sale.picking_ids[:1].move_line_ids.write({"quantity": 1}) + wiz_act = self.sale.picking_ids[:1].button_validate() + wiz = Form( + self.env[wiz_act["res_model"]].with_context(**wiz_act["context"]) + ).save() + wiz.process() + invoice = self.sale._create_invoices() + invoice.journal_id.show_group_by_picking_report = False + groups = invoice.lines_grouped_by_picking() + self.assertEqual(len(groups), len(invoice.invoice_line_ids)) + for group in groups: + self.assertFalse(group["picking"]) + content = html.document_fromstring( + self.env["ir.actions.report"]._render_qweb_html( + "account.account_invoices", invoice.id + )[0] + ) + tbody = content.xpath("//tbody[@class='invoice_tbody']") + tbody = [html.tostring(line, encoding="utf-8").strip() for line in tbody][ + 0 + ].decode() + self.assertEqual(self._count_sale_in_picking_header(content, self.sale.name), 0) + self.assertFalse(self.sale.invoice_ids.picking_ids[:1].name in tbody) diff --git a/account_invoice_report_grouped_by_picking/views/account_journal_views.xml b/account_invoice_report_grouped_by_picking/views/account_journal_views.xml new file mode 100644 index 000000000..5e9dd75e4 --- /dev/null +++ b/account_invoice_report_grouped_by_picking/views/account_journal_views.xml @@ -0,0 +1,26 @@ + + + + account.journal.form.grouped.by.picking (in account_invoice_report_grouped_by_picking) + + account.journal + + + + + + + + + + diff --git a/account_invoice_report_grouped_by_picking/views/report_invoice.xml b/account_invoice_report_grouped_by_picking/views/report_invoice.xml index 9f71030e5..7d90dd287 100644 --- a/account_invoice_report_grouped_by_picking/views/report_invoice.xml +++ b/account_invoice_report_grouped_by_picking/views/report_invoice.xml @@ -9,6 +9,7 @@ + lines_grouped @@ -30,7 +31,9 @@ - + @@ -96,7 +99,9 @@ expr="//t[@t-foreach='lines_grouped']//td[hasclass('o_price_total')]" position="after" > - + Subtotal: