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 tafaRU committed Jul 25, 2024
1 parent e86cae7 commit 950e302
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
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.product_id = self.env.ref("product.product_product_5")
line.quantity = 10.00
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,4 +1,5 @@
# Copyright 2018 Gianmarco Conte (gconte@dinamicheaziendali.it)
# Copyright 2024 Simone Rubino - Aion Tech

import base64
import io
Expand Down Expand Up @@ -333,15 +334,18 @@ 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

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 950e302

Please sign in to comment.