Skip to content

Commit d741d36

Browse files
committed
Merge PR #409 into 18.0
Signed-off-by pedrobaeza
2 parents 1587bdd + 124af20 commit d741d36

9 files changed

Lines changed: 98 additions & 25 deletions

File tree

account_invoice_report_grouped_by_picking/README.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
==================================
62
Account Invoice Grouped by Picking
73
==================================
@@ -17,7 +13,7 @@ Account Invoice Grouped by Picking
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Beta
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoice--reporting-lightgray.png?logo=github

account_invoice_report_grouped_by_picking/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"author": "Tecnativa, Odoo Community Association (OCA)",
1414
"license": "AGPL-3",
1515
"depends": ["sale_stock_picking_invoice_link"],
16-
"data": ["views/report_invoice.xml"],
16+
"data": ["views/report_invoice.xml", "views/account_journal_views.xml"],
1717
"installable": True,
1818
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from . import account_move
2+
from . import account_journal
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# © 2026 Solvos Consultoría Informática (<https://www.solvos.es>)
2+
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html
3+
4+
from odoo import fields, models
5+
6+
7+
class AccountJournal(models.Model):
8+
_inherit = "account.journal"
9+
10+
show_group_by_picking_report = fields.Boolean(
11+
default=True,
12+
string="Invoice Report - Show Grouped by Picking",
13+
help="Leave unmarked if original Odoo behavior (not grouped"
14+
" is required for invoices belonging this journal).",
15+
)

account_invoice_report_grouped_by_picking/models/account_move.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ def lines_grouped_by_picking(self):
5959
"""This prepares a data structure for printing the invoice report
6060
grouped by pickings."""
6161
self.ensure_one()
62+
if not self.journal_id.show_group_by_picking_report:
63+
return [
64+
{
65+
"picking": self.env["stock.picking"],
66+
"line": line,
67+
"quantity": line.quantity,
68+
}
69+
for line in self.invoice_line_ids
70+
]
6271
picking_dict = {}
6372
lines_dict = {}
6473
picking_obj = self.env["stock.picking"]

account_invoice_report_grouped_by_picking/static/description/index.html

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Account Invoice Grouped by Picking</title>
77
<style type="text/css">
88

99
/*
@@ -360,21 +360,16 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="account-invoice-grouped-by-picking">
364+
<h1 class="title">Account Invoice Grouped by Picking</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="account-invoice-grouped-by-picking">
370-
<h1>Account Invoice Grouped by Picking</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:9b447a95944dfc6dedc4c45251a0d264eb7056a29a9f0b5e1d07c6fa0963734a
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-invoice-reporting/tree/18.0/account_invoice_report_grouped_by_picking"><img alt="OCA/account-invoice-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--invoice--reporting-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-invoice-reporting-18-0/account-invoice-reporting-18-0-account_invoice_report_grouped_by_picking"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-invoice-reporting&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-invoice-reporting/tree/18.0/account_invoice_report_grouped_by_picking"><img alt="OCA/account-invoice-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--invoice--reporting-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-invoice-reporting-18-0/account-invoice-reporting-18-0-account_invoice_report_grouped_by_picking"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-invoice-reporting&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>This module allows print invoices with picking info. This module groups
379374
invoice lines and shows information related to sales and pickings on
380375
every group.</p>
@@ -396,7 +391,7 @@ <h1>Account Invoice Grouped by Picking</h1>
396391
</ul>
397392
</div>
398393
<div class="section" id="usage">
399-
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
394+
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
400395
<ol class="arabic simple">
401396
<li>Create several quotation orders and confirm them.</li>
402397
<li>Deliver pickings related to each sale order.</li>
@@ -408,23 +403,23 @@ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
408403
</ol>
409404
</div>
410405
<div class="section" id="bug-tracker">
411-
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
406+
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
412407
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-invoice-reporting/issues">GitHub Issues</a>.
413408
In case of trouble, please check there if your issue has already been reported.
414409
If you spotted it first, help us to smash it by providing a detailed and welcomed
415410
<a class="reference external" href="https://github.com/OCA/account-invoice-reporting/issues/new?body=module:%20account_invoice_report_grouped_by_picking%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
416411
<p>Do not contact contributors directly about support or help with technical issues.</p>
417412
</div>
418413
<div class="section" id="credits">
419-
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
414+
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
420415
<div class="section" id="authors">
421-
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
416+
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
422417
<ul class="simple">
423418
<li>Tecnativa</li>
424419
</ul>
425420
</div>
426421
<div class="section" id="contributors">
427-
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
422+
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
428423
<ul class="simple">
429424
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
430425
<li>Carlos Dauden</li>
@@ -446,12 +441,12 @@ <h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
446441
</ul>
447442
</div>
448443
<div class="section" id="other-credits">
449-
<h3><a class="toc-backref" href="#toc-entry-6">Other credits</a></h3>
444+
<h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
450445
<p>The migration of this module from 16.0 to 17.0 was financially supported
451446
by Camptocamp.</p>
452447
</div>
453448
<div class="section" id="maintainers">
454-
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
449+
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
455450
<p>This module is maintained by the OCA.</p>
456451
<a class="reference external image-reference" href="https://odoo-community.org">
457452
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -464,6 +459,5 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
464459
</div>
465460
</div>
466461
</div>
467-
</div>
468462
</body>
469463
</html>

account_invoice_report_grouped_by_picking/tests/test_account_invoice_group_picking.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,30 @@ def test_account_invoice_group_picking_refund_without_return(self):
320320
self.assertEqual(self._count_sale_in_picking_header(content, self.sale.name), 1)
321321
# information about pickings is printed
322322
self.assertTrue(picking.name in tbody)
323+
324+
def test_account_invoice_group_picking_disabled(self):
325+
self.sale.action_confirm()
326+
self.sale.picking_ids[:1].action_confirm()
327+
self.sale.picking_ids[:1].move_line_ids.write({"quantity": 1})
328+
wiz_act = self.sale.picking_ids[:1].button_validate()
329+
wiz = Form(
330+
self.env[wiz_act["res_model"]].with_context(**wiz_act["context"])
331+
).save()
332+
wiz.process()
333+
invoice = self.sale._create_invoices()
334+
invoice.journal_id.show_group_by_picking_report = False
335+
groups = invoice.lines_grouped_by_picking()
336+
self.assertEqual(len(groups), len(invoice.invoice_line_ids))
337+
for group in groups:
338+
self.assertFalse(group["picking"])
339+
content = html.document_fromstring(
340+
self.env["ir.actions.report"]._render_qweb_html(
341+
"account.account_invoices", invoice.id
342+
)[0]
343+
)
344+
tbody = content.xpath("//tbody[@class='invoice_tbody']")
345+
tbody = [html.tostring(line, encoding="utf-8").strip() for line in tbody][
346+
0
347+
].decode()
348+
self.assertEqual(self._count_sale_in_picking_header(content, self.sale.name), 0)
349+
self.assertFalse(self.sale.invoice_ids.picking_ids[:1].name in tbody)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<odoo>
2+
<record
3+
id="view_account_journal_form_inherit_grouped_by_picking"
4+
model="ir.ui.view"
5+
>
6+
<field name="name">
7+
account.journal.form.grouped.by.picking
8+
</field>
9+
<field name="model">account.journal</field>
10+
<field name="inherit_id" ref="account.view_account_journal_form" />
11+
<field name="arch" type="xml">
12+
<xpath
13+
expr="//notebook/page[@name='advanced_settings']/group"
14+
position="after"
15+
>
16+
<group name="invoice_report" string="Invoice Report">
17+
<field
18+
name="show_group_by_picking_report"
19+
string="Show Grouped by Picking"
20+
widget="boolean_toggle"
21+
/>
22+
</group>
23+
</xpath>
24+
</field>
25+
</record>
26+
</odoo>

account_invoice_report_grouped_by_picking/views/report_invoice.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</xpath>
1010
<xpath expr="//tbody[hasclass('invoice_tbody')]" position="inside">
1111
<t t-set="subtotal" t-value="0.0" />
12+
<t t-set="last_picking" t-value="None" />
1213
</xpath>
1314
<xpath expr="//t[contains(@t-foreach, 'lines')]" position="attributes">
1415
<attribute name="t-foreach">lines_grouped</attribute>
@@ -30,7 +31,9 @@
3031
<t t-set="line_last" t-value="False" />
3132
<t t-set="line_index" t-value="0" />
3233

33-
<t t-if="picking != last_picking">
34+
<t
35+
t-if="o.journal_id.show_group_by_picking_report and picking != last_picking"
36+
>
3437
<t t-set="last_picking" t-value="picking" />
3538
<tr t-if="picking">
3639
<td colspan="10">
@@ -96,7 +99,9 @@
9699
expr="//t[@t-foreach='lines_grouped']//td[hasclass('o_price_total')]"
97100
position="after"
98101
>
99-
<tr t-if="picking != next_picking[0]">
102+
<tr
103+
t-if="o.journal_id.show_group_by_picking_report and picking != next_picking[0]"
104+
>
100105
<td colspan="10" class="text-end">
101106
<strong>Subtotal: </strong>
102107
<strong

0 commit comments

Comments
 (0)