Skip to content

Commit

Permalink
[FIX] l10n_it_central_journal_reportlab: Support lines without account
Browse files Browse the repository at this point in the history
  • Loading branch information
SirAionTech authored and jado95 committed Dec 6, 2024
1 parent a1e13af commit e47b603
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 11 deletions.
5 changes: 4 additions & 1 deletion l10n_it_central_journal_reportlab/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ITA - Libro giornale - Reportlab
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:61dcfdb267425d63d6bee99109adddf11c6a4fe7e90d15b451a13e62d7d8ca8f
!! source digest: sha256:406c815cf9f5d7858e2354cdb28c41b751c27edacf1b580a4ca626ef2ea10a9a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -66,6 +66,9 @@ Contributors
- Lara Baggio <[email protected]>
- Glauco Prina <[email protected]>
- Giuseppe Borruso <[email protected]>
- `Aion Tech <https://aiontech.company/>`__:

- Simone Rubino <[email protected]>

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_central_journal_reportlab/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "ITA - Libro giornale - Reportlab",
"version": "16.0.1.0.4",
"version": "16.0.1.0.5",
"development_status": "Beta",
"category": "Localization/Italy",
"author": "Gianmarco Conte - Dinamiche Aziendali srl, "
Expand Down
2 changes: 2 additions & 0 deletions l10n_it_central_journal_reportlab/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
- Lara Baggio \<<[email protected]>\>
- Glauco Prina \<<[email protected]>\>
- Giuseppe Borruso \<<[email protected]>\>
- [Aion Tech](https://aiontech.company/):
- Simone Rubino \<<[email protected]>\>
17 changes: 12 additions & 5 deletions l10n_it_central_journal_reportlab/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -366,7 +367,7 @@ <h1 class="title">ITA - Libro giornale - Reportlab</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:61dcfdb267425d63d6bee99109adddf11c6a4fe7e90d15b451a13e62d7d8ca8f
!! source digest: sha256:406c815cf9f5d7858e2354cdb28c41b751c27edacf1b580a4ca626ef2ea10a9a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/l10n-italy/tree/16.0/l10n_it_central_journal_reportlab"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-l10n_it_central_journal_reportlab"><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/l10n-italy&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><strong>Italiano</strong></p>
Expand Down Expand Up @@ -408,12 +409,18 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<li>Lara Baggio &lt;<a class="reference external" href="mailto:lbaggio&#64;linkgroup.it">lbaggio&#64;linkgroup.it</a>&gt;</li>
<li>Glauco Prina &lt;<a class="reference external" href="mailto:gprina&#64;linkgroup.it">gprina&#64;linkgroup.it</a>&gt;</li>
<li>Giuseppe Borruso &lt;<a class="reference external" href="mailto:gborruso&#64;dinamicheaziendali.it">gborruso&#64;dinamicheaziendali.it</a>&gt;</li>
<li><a class="reference external" href="https://aiontech.company/">Aion Tech</a>:<ul>
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;aion-tech.it">simone.rubino&#64;aion-tech.it</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2022 Giuseppe Borruso
# Copyright 2024 Simone Rubino - Aion Tech
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

import base64
Expand Down Expand Up @@ -59,3 +60,42 @@ def test_wizard_reportlab(self):
self.minimal_reader_buffer = io.BytesIO(decode_giornale)
self.minimal_pdf_reader = pdf.OdooPdfFileReader(self.minimal_reader_buffer)
self.assertTrue(self.minimal_reader_buffer)

def test_grouped_move_line_no_account(self):
"""Move lines without account are excluded from grouped report."""
# Arrange
out_invoice = Form(
self.env["account.move"].with_context(default_move_type="out_invoice")
)
out_invoice.partner_id = self.env.ref("base.res_partner_1")
out_invoice.invoice_date = self.today
with out_invoice.invoice_line_ids.new() as note_line:
note_line.display_type = "line_note"
note_line.name = "Test note"
with out_invoice.invoice_line_ids.new() as line:
line.name = "Test line"
line.price_unit = 100
out_invoice = out_invoice.save()
out_invoice.action_post()
# pre-condition
account_lines = out_invoice.invoice_line_ids.filtered("account_id")
self.assertTrue(account_lines)
no_account_lines = out_invoice.invoice_line_ids - account_lines
self.assertTrue(no_account_lines)

# Act
wizard_form = Form(self.wizard_model)
wizard_form.daterange_id = self.current_period
wizard_form.group_by_account = True
wizard = wizard_form.save()

# Assert
wizard.print_giornale_reportlab()
giornale_pdf_content = base64.b64decode(wizard.report_giornale)
giornale_content = pdf.PdfFileReader(io.BytesIO(giornale_pdf_content))
has_move = False
for page in giornale_content.pages:
page_content = page.extractText()
if not has_move and out_invoice.name in page_content:
has_move = True
self.assertTrue(has_move)
12 changes: 8 additions & 4 deletions l10n_it_central_journal_reportlab/wizard/print_giornale.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2018 Gianmarco Conte ([email protected])
# Copyright 2022 Giuseppe Borruso ([email protected])
# Copyright 2024 Simone Rubino - Aion Tech

import base64
import io
Expand Down Expand Up @@ -330,18 +331,21 @@ def get_grupped_final_tables_report_giornale(
(self.progressive_debit2, self.progressive_credit),
]
for line in list_grupped_line:
start_row += 1
row = Paragraph(str(start_row), style_name)
date = Paragraph(format_date(self.env, line["date"]), style_name)
move = Paragraph(line["move_name"], style_name)
account_name = (
line["account_code"] + " - " + line["account_name"]
if line["account_code"]
else line["account_name"]
)
if not account_name:
continue
# evitiamo che i caratteri < o > vengano interpretato come tag html
# dalla libreria reportlab
account_name = account_name.replace("<", "&lt;").replace(">", "&gt;")

start_row += 1
row = Paragraph(str(start_row), style_name)
date = Paragraph(format_date(self.env, line["date"]), style_name)
move = Paragraph(line["move_name"], style_name)
account = Paragraph(account_name, style_name)
name = Paragraph(line["name"], style_name)
# dato che nel SQL ho la somma dei crediti e debiti potrei avere
Expand Down

0 comments on commit e47b603

Please sign in to comment.