diff --git a/l10n_it_central_journal_reportlab/README.rst b/l10n_it_central_journal_reportlab/README.rst
index 299607c02f6..c61a1e01857 100644
--- a/l10n_it_central_journal_reportlab/README.rst
+++ b/l10n_it_central_journal_reportlab/README.rst
@@ -7,7 +7,7 @@ ITA - Libro giornale - Reportlab
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !! source digest: sha256:91af559133071364b21113152d074c2e22096b825300936d3a24de75f65d2fe9
+ !! source digest: sha256:406c815cf9f5d7858e2354cdb28c41b751c27edacf1b580a4ca626ef2ea10a9a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ ITA - Libro giornale - Reportlab
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
- :target: https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_central_journal_reportlab
+ :target: https://github.com/OCA/l10n-italy/tree/18.0/l10n_it_central_journal_reportlab
:alt: OCA/l10n-italy
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-l10n_it_central_journal_reportlab
+ :target: https://translation.odoo-community.org/projects/l10n-italy-18-0/l10n-italy-18-0-l10n_it_central_journal_reportlab
: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/l10n-italy&target_branch=16.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=18.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -47,7 +47,7 @@ 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -62,13 +62,13 @@ Authors
Contributors
------------
-- Gianmarco Conte
-- Lara Baggio
-- Glauco Prina
-- Giuseppe Borruso
-- `Aion Tech `__:
+- Gianmarco Conte
+- Lara Baggio
+- Glauco Prina
+- Giuseppe Borruso
+- `Aion Tech `__:
- - Simone Rubino
+ - Simone Rubino
Maintainers
-----------
@@ -94,6 +94,6 @@ Current `maintainers `__:
|maintainer-MarcoCalcagni| |maintainer-Borruso|
-This module is part of the `OCA/l10n-italy `_ project on GitHub.
+This module is part of the `OCA/l10n-italy `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/l10n_it_central_journal_reportlab/__manifest__.py b/l10n_it_central_journal_reportlab/__manifest__.py
index 451c8a79638..9437a145d8f 100644
--- a/l10n_it_central_journal_reportlab/__manifest__.py
+++ b/l10n_it_central_journal_reportlab/__manifest__.py
@@ -3,7 +3,7 @@
{
"name": "ITA - Libro giornale - Reportlab",
- "version": "16.0.1.0.6",
+ "version": "18.0.1.0.0",
"development_status": "Beta",
"category": "Localization/Italy",
"author": "Gianmarco Conte - Dinamiche Aziendali srl, "
diff --git a/l10n_it_central_journal_reportlab/security/ir.model.access.csv b/l10n_it_central_journal_reportlab/security/ir.model.access.csv
index 88bfafe2bf0..29704dc0c7a 100644
--- a/l10n_it_central_journal_reportlab/security/ir.model.access.csv
+++ b/l10n_it_central_journal_reportlab/security/ir.model.access.csv
@@ -1,3 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_date_range_group_account_manager,group_account_manager model_date_range,model_date_range,account.group_account_manager,1,1,0,0
-access_wizard_giornale_reportlab_manager,access_wizard_giornale_reportlab manager,l10n_it_central_journal_reportlab.model_wizard_giornale_reportlab,,1,1,1,1
+access_wizard_giornale_reportlab_manager,access_wizard_giornale_reportlab manager,l10n_it_central_journal_reportlab.model_wizard_giornale_reportlab,account.group_account_manager,1,1,1,1
diff --git a/l10n_it_central_journal_reportlab/static/description/index.html b/l10n_it_central_journal_reportlab/static/description/index.html
index 57c980f665d..e6067273432 100644
--- a/l10n_it_central_journal_reportlab/static/description/index.html
+++ b/l10n_it_central_journal_reportlab/static/description/index.html
@@ -367,9 +367,9 @@ ITA - Libro giornale - Reportlab
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!! source digest: sha256:91af559133071364b21113152d074c2e22096b825300936d3a24de75f65d2fe9
+!! source digest: sha256:406c815cf9f5d7858e2354cdb28c41b751c27edacf1b580a4ca626ef2ea10a9a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
![Try me on Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)
+
![Try me on Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)
Italiano
Modulo per la stampa del libro giornale con reportlab
English
@@ -391,7 +391,7 @@
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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
diff --git a/l10n_it_central_journal_reportlab/tests/test_central_journal_reportlab.py b/l10n_it_central_journal_reportlab/tests/test_central_journal_reportlab.py
index 58351cf438b..d0beaeda78d 100644
--- a/l10n_it_central_journal_reportlab/tests/test_central_journal_reportlab.py
+++ b/l10n_it_central_journal_reportlab/tests/test_central_journal_reportlab.py
@@ -8,7 +8,8 @@
from dateutil.rrule import MONTHLY
-from odoo.tests.common import Form, TransactionCase
+from odoo.tests import Form
+from odoo.tests.common import TransactionCase
from odoo.tools import pdf
@@ -20,8 +21,8 @@ def setUp(self):
self.range_type = self.env["date.range.type"].create({"name": "Fiscal year"})
self.env["date.range.generator"].create(
{
- "date_start": "%s-01-01" % self.today.year,
- "name_prefix": "%s-" % self.today.year,
+ "date_start": f"{self.today.year}-01-01",
+ "name_prefix": f"{self.today.year}-",
"type_id": self.range_type.id,
"duration_count": 1,
"unit_of_time": str(MONTHLY),
diff --git a/l10n_it_central_journal_reportlab/views/date_range_view.xml b/l10n_it_central_journal_reportlab/views/date_range_view.xml
index d6342529c36..2306f31c5df 100644
--- a/l10n_it_central_journal_reportlab/views/date_range_view.xml
+++ b/l10n_it_central_journal_reportlab/views/date_range_view.xml
@@ -29,12 +29,12 @@
-
- date.range.tree.inherit
+
+ date.range.list.inherit
date.range
-
+
-
+
diff --git a/l10n_it_central_journal_reportlab/wizard/print_giornale.py b/l10n_it_central_journal_reportlab/wizard/print_giornale.py
index 5a661aef6f2..68183949cac 100644
--- a/l10n_it_central_journal_reportlab/wizard/print_giornale.py
+++ b/l10n_it_central_journal_reportlab/wizard/print_giornale.py
@@ -5,7 +5,6 @@
import base64
import io
from datetime import timedelta
-from xml.sax.saxutils import escape
from reportlab.lib import colors
from reportlab.lib.enums import TA_RIGHT
@@ -18,7 +17,7 @@
from odoo import _, api, fields, models
from odoo.exceptions import UserError
-from odoo.tools.misc import flatten, format_date, formatLang
+from odoo.tools.misc import format_date, formatLang
gap = 1 * cm # gap between header/footer and page content
gap_text = 0.5 * cm # gap between text
@@ -128,71 +127,89 @@ def get_grupped_line_reportlab_ids(self):
target_type = ["posted", "draft"]
else:
target_type = [wizard.target_move]
- sql = """
- SELECT
+ sql = """SELECT
+ aml.account_id AS account_id,
am.date,
am.name AS move_name,
- aa.code AS account_code,
+ COALESCE(aml.ref, '') AS ref,
aa.name AS account_name,
- COALESCE(am.ref, '') AS name,
+ COALESCE(rp.name, '') AS name,
SUM(aml.debit) AS debit,
SUM(aml.credit) AS credit
FROM
account_move_line aml
LEFT JOIN account_move am ON (am.id = aml.move_id)
LEFT JOIN account_account aa ON (aa.id = aml.account_id)
+ LEFT JOiN res_partner rp ON am.partner_id = rp.id
WHERE
aml.date >= %(date_from)s
AND aml.date <= %(date_to)s
- AND am.state in %(target_type)s
- AND aml.journal_id in %(journal_ids)s
+ AND am.state IN %(target_type)s
+ AND aml.journal_id IN %(journal_ids)s
+ AND aml.company_id = %(company_id)s
+ AND (aml.debit + aml.credit) != 0.0
GROUP BY
+ aml.account_id,
am.date,
am.name,
- aa.code,
+ aml.ref,
aa.name,
- am.ref
+ am.ref,
+ rp.name
ORDER BY
am.date,
- am.name,
- aa.code
- """
+ am.name
+ """
params = {
"date_from": wizard.date_move_line_from,
"date_to": wizard.date_move_line_to,
"target_type": tuple(target_type),
"journal_ids": tuple(self.journal_ids.ids),
+ "company_id": self.env.company.id,
}
self.env.cr.execute(sql, params)
list_grupped_line = self.env.cr.dictfetchall()
return list_grupped_line
def get_line_reportlab_ids(self):
- if self.target_move == "all":
+ wizard = self
+ if wizard.target_move == "all":
target_type = ["posted", "draft"]
else:
- target_type = [self.target_move]
- sql = """
- SELECT aml.id FROM account_move_line aml
- LEFT JOIN account_move am ON (am.id = aml.move_id)
- LEFT JOIN account_account aa ON (aa.id = aml.account_id)
- WHERE
- aml.date >= %(date_from)s
- AND aml.date <= %(date_to)s
- AND am.state in %(target_type)s
- AND aml.journal_id in %(journal_ids)s
- ORDER BY am.date, am.name, aa.code
- """
+ target_type = [wizard.target_move]
+ sql = """SELECT
+ aml.account_id AS account_id,
+ am.date,
+ am.name AS move_name,
+ COALESCE(aml.ref, '') AS ref,
+ aa.name AS account_name,
+ COALESCE(aml.name, '') AS name,
+ aml.debit AS debit,
+ aml.credit AS credit
+ FROM
+ account_move_line aml
+ LEFT JOIN account_move am ON (am.id = aml.move_id)
+ LEFT JOIN account_account aa ON (aa.id = aml.account_id)
+ WHERE
+ aml.date >= %(date_from)s
+ AND aml.date <= %(date_to)s
+ AND am.state IN %(target_type)s
+ AND aml.journal_id IN %(journal_ids)s
+ AND aml.company_id = %(company_id)s
+ ORDER BY
+ am.date,
+ am.name
+ """
params = {
- "date_from": self.date_move_line_from,
- "date_to": self.date_move_line_to,
+ "date_from": wizard.date_move_line_from,
+ "date_to": wizard.date_move_line_to,
"target_type": tuple(target_type),
"journal_ids": tuple(self.journal_ids.ids),
+ "company_id": self.env.company.id,
}
self.env.cr.execute(sql, params)
- res = self.env.cr.fetchall()
- move_line_ids = flatten(res)
- return move_line_ids
+ list_line_not_grouped = self.env.cr.dictfetchall()
+ return list_line_not_grouped
def _get_account_name_reportlab(self, line):
return " - ".join(filter(None, [line.account_id.code, line.account_id.name]))
@@ -273,7 +290,8 @@ def get_styles_report_giornale_line(self):
}
def get_colwidths_report_giornale(self, width_available):
- colwidths = [32, 40, 50, 120, 130, 100, 50, 50]
+ # colwidths = [32, 40, 50, 120, 130, 100, 50, 50]
+ colwidths = [28, 40, 80, 70, 100, 150, 52, 52]
total = sum(colwidths)
return [c / total * width_available for c in colwidths]
@@ -309,16 +327,18 @@ def get_initial_balance_data_report_giornale(self):
"",
"",
Paragraph(_("Initial Balance"), style_name),
- Paragraph(
- escape(formatLang(self.env, self.progressive_debit2)), style_number
- ),
- Paragraph(
- escape(formatLang(self.env, self.progressive_credit)), style_number
- ),
+ Paragraph(formatLang(self.env, self.progressive_debit2), style_number),
+ Paragraph(formatLang(self.env, self.progressive_credit), style_number),
]
]
return initial_balance_data
+ def get_account_dict(self, all_account):
+ account_dict = {}
+ for account in all_account:
+ account_dict[account.id] = account.code
+ return account_dict
+
def get_grupped_final_tables_report_giornale(
self, list_grupped_line, tables, start_row, width_available
):
@@ -329,44 +349,59 @@ def get_grupped_final_tables_report_giornale(
"style_table_line_above"
]
colwidths = self.get_colwidths_report_giornale(width_available)
-
previous_move_name = ""
list_balance = [
(0, 0),
(self.progressive_debit2, self.progressive_credit),
]
+
+ company = self.env.company
+ user_lang = company.partner_id.lang
+ model_account = self.env["account.account"]
+ all_account = model_account.search([]).filtered(
+ lambda acc: company.id in acc.company_ids.ids
+ )
+ account_dict = self.get_account_dict(all_account)
+
for line in list_grupped_line:
+ start_row += 1
account_name = (
- line["account_code"] + " - " + line["account_name"]
- if line["account_code"]
- else line["account_name"]
+ account_dict[line["account_id"]]
+ + " - "
+ + line["account_name"][user_lang]
+ if account_dict
+ and "line_id" in account_dict.keys()
+ and "account_id" in account_dict[line].keys()
+ else line["account_name"][user_lang]
)
if not account_name:
continue
-
- start_row += 1
- row = Paragraph(escape(str(start_row)), style_name)
- date = Paragraph(escape(format_date(self.env, line["date"])), style_name)
- move = Paragraph(escape(line["move_name"]), style_name)
- account = Paragraph(escape(account_name), style_name)
- name = Paragraph(escape(line["name"]), style_name)
+ # evitiamo che i caratteri < o > vengano interpretato come tag html
+ # dalla libreria reportlab
+ account_name = account_name.replace("<", "<").replace(">", ">")
+ row = Paragraph(str(start_row), style_name)
+ date = Paragraph(format_date(self.env, line["date"]), style_name)
+ ref = Paragraph(str(line["ref"]), 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
# che un conto ha sia debito che credito
lines_data = []
if line["debit"] > 0:
- debit = Paragraph(
- escape(formatLang(self.env, line["debit"])), style_number
- )
- credit = Paragraph(escape(formatLang(self.env, 0)), style_number)
+ debit = Paragraph(formatLang(self.env, line["debit"]), style_number)
+ credit = Paragraph(formatLang(self.env, 0), style_number)
list_balance.append((line["debit"], 0))
- lines_data.append([[row, date, move, account, name, debit, credit]])
- if line["credit"] > 0:
- debit = Paragraph(escape(formatLang(self.env, 0)), style_number)
- credit = Paragraph(
- escape(formatLang(self.env, line["credit"])), style_number
+ lines_data.append(
+ [[row, date, ref, move, account, name, debit, credit]]
)
+ if line["credit"] > 0:
+ debit = Paragraph(formatLang(self.env, 0), style_number)
+ credit = Paragraph(formatLang(self.env, line["credit"]), style_number)
list_balance.append((0, line["credit"]))
- lines_data.append([[row, date, move, account, name, debit, credit]])
+ lines_data.append(
+ [[row, date, ref, move, account, name, debit, credit]]
+ )
for line_data in lines_data:
if previous_move_name != line["move_name"]:
previous_move_name = line["move_name"]
@@ -382,7 +417,7 @@ def get_grupped_final_tables_report_giornale(
return tables, list_balance
def get_final_tables_report_giornale(
- self, move_line_ids, tables, start_row, width_available
+ self, list_line_not_grouped, tables, start_row, width_available
):
style_name = self.get_styles_report_giornale_line()["style_name"]
style_number = self.get_styles_report_giornale_line()["style_number"]
@@ -398,27 +433,40 @@ def get_final_tables_report_giornale(
(self.progressive_debit2, self.progressive_credit),
]
- for line in self.env["account.move.line"].browse(move_line_ids):
+ company = self.env.company
+ user_lang = company.partner_id.lang
+ model_account = self.env["account.account"]
+ all_account = model_account.search([]).filtered(
+ lambda acc: company.id in acc.company_ids.ids
+ )
+ account_dict = self.get_account_dict(all_account)
+
+ for line in list_line_not_grouped:
start_row += 1
- row = Paragraph(escape(str(start_row)), style_name)
- date = Paragraph(escape(format_date(self.env, line.date)), style_name)
- ref = Paragraph(escape(str(line.ref or "")), style_name)
- move_name = line.move_id.name or ""
- move = Paragraph(escape(move_name), style_name)
- account_name = self._get_account_name_reportlab(line)
+ account_name = (
+ account_dict[line["account_id"]]
+ + " - "
+ + line["account_name"][user_lang]
+ if account_dict
+ and "line_id" in account_dict.keys()
+ and "account_id" in account_dict[line].keys()
+ else line["account_name"][user_lang]
+ )
+ if not account_name:
+ continue
+ account_name = account_name.replace("<", "<").replace(">", ">")
+ row = Paragraph(str(start_row), style_name)
+ date = Paragraph(format_date(self.env, line["date"]), style_name)
+ ref = Paragraph(str(line["ref"]), style_name)
+ move = Paragraph(line["move_name"], style_name)
+ move_name = line["move_name"] or ""
+ account = Paragraph(account_name, style_name)
+ name = Paragraph(line["name"], style_name)
# evitiamo che i caratteri < o > vengano interpretato come tag html
# dalla libreria reportlab
- account = Paragraph(escape(account_name), style_name)
- if line.account_id.account_type in [
- "asset_receivable",
- "liability_payable",
- ]:
- name = Paragraph(escape(str(line.partner_id.name or "")), style_name)
- else:
- name = Paragraph(escape(str(line.name or "")), style_name)
- debit = Paragraph(escape(formatLang(self.env, line.debit)), style_number)
- credit = Paragraph(escape(formatLang(self.env, line.credit)), style_number)
- list_balance.append((line.debit, line.credit))
+ debit = Paragraph(formatLang(self.env, line["debit"]), style_number)
+ credit = Paragraph(formatLang(self.env, line["credit"]), style_number)
+ list_balance.append((line["debit"], line["credit"]))
line_data = [[row, date, ref, move, account, name, debit, credit]]
if previous_move_name != move_name:
previous_move_name = move_name
@@ -446,8 +494,8 @@ def get_balance_data_report_giornale(self, tot_debit, tot_credit, final=False):
"",
"",
name,
- Paragraph(escape(formatLang(self.env, tot_debit)), style_number),
- Paragraph(escape(formatLang(self.env, tot_credit)), style_number),
+ Paragraph(formatLang(self.env, tot_debit), style_number),
+ Paragraph(formatLang(self.env, tot_credit), style_number),
]
]
return balance_data
@@ -484,11 +532,11 @@ def create_report_giornale_reportlab(self):
list_grupped_line, tables, start_row, width_available
)
else:
- move_line_ids = self.get_line_reportlab_ids()
- if not move_line_ids:
+ list_line_not_grouped = self.get_line_reportlab_ids()
+ if not list_line_not_grouped:
raise UserError(_("No documents found in the current selection"))
final_tables, list_balance = self.get_final_tables_report_giornale(
- move_line_ids, tables, start_row, width_available
+ list_line_not_grouped, tables, start_row, width_available
)
height_available -= gap
@@ -594,10 +642,10 @@ def print_giornale_reportlab_final(self):
end_row, end_debit, end_credit = self.create_report_giornale_reportlab()
if (
- not self.company_id.period_lock_date
- or self.company_id.period_lock_date < self.date_move_line_to
+ not self.company_id.tax_lock_date
+ or self.company_id.tax_lock_date < self.date_move_line_to
):
- self.company_id.sudo().period_lock_date = self.date_move_line_to
+ self.company_id.sudo().tax_lock_date = self.date_move_line_to
daterange_vals = {
"date_last_print": self.date_move_line_to,