From 2514d51e3a4c29641ef57461edba10c2dfefc8ad Mon Sep 17 00:00:00 2001 From: valen Date: Wed, 26 May 2021 22:47:36 +0200 Subject: [PATCH] [IMP] account_financial_report: added 'auto sequence' option in Journal Ledger. --- .../readme/CONTRIBUTORS.rst | 4 ++ .../report/journal_ledger.py | 8 +++- .../report/journal_ledger_xlsx.py | 6 +++ .../report/templates/journal_ledger.xml | 39 ++++++++++++++++--- .../wizard/journal_ledger_wizard.py | 2 + .../wizard/journal_ledger_wizard_view.xml | 1 + 6 files changed, 53 insertions(+), 7 deletions(-) diff --git a/account_financial_report/readme/CONTRIBUTORS.rst b/account_financial_report/readme/CONTRIBUTORS.rst index 2e2c067a..88f89af1 100644 --- a/account_financial_report/readme/CONTRIBUTORS.rst +++ b/account_financial_report/readme/CONTRIBUTORS.rst @@ -24,6 +24,10 @@ * Alexandre D. Díaz * Lois Rilo +* `Sygel `__: + + * Harald Panten + * Valentin Vinagre Much of the work in this module was done at a sprint in Sorrento, Italy in April 2016. diff --git a/account_financial_report/report/journal_ledger.py b/account_financial_report/report/journal_ledger.py index 0d0edbc1..e64a8c5c 100644 --- a/account_financial_report/report/journal_ledger.py +++ b/account_financial_report/report/journal_ledger.py @@ -86,7 +86,7 @@ class JournalLedgerReport(models.AbstractModel): def _get_move_lines_order(self, move_ids, wizard, journal_ids): return "" - def _get_move_lines_data(self, ml, wizard, ml_taxes): + def _get_move_lines_data(self, ml, wizard, ml_taxes, auto_sequence): base_debit = ( base_credit ) = tax_debit = tax_credit = base_balance = tax_balance = 0.0 @@ -118,6 +118,7 @@ class JournalLedgerReport(models.AbstractModel): "tax_credit": tax_credit, "base_balance": base_balance, "tax_balance": tax_balance, + "auto_sequence": str(auto_sequence).zfill(6), } def _get_account_data(self, accounts): @@ -202,6 +203,7 @@ class JournalLedgerReport(models.AbstractModel): partners = self.env["res.partner"] currencies = self.env["res.currency"] tax_lines = self.env["account.tax"] + auto_sequence = len(move_ids) for ml in move_lines: if ml.account_id not in accounts: accounts |= ml.account_id @@ -213,13 +215,14 @@ class JournalLedgerReport(models.AbstractModel): tax_lines |= ml.tax_line_id if ml.move_id.id not in Move_Lines.keys(): Move_Lines[ml.move_id.id] = [] + auto_sequence -= 1 taxes = ( ml.id in move_line_ids_taxes_data.keys() and move_line_ids_taxes_data[ml.id] or {} ) Move_Lines[ml.move_id.id].append( - self._get_move_lines_data(ml, wizard, taxes) + self._get_move_lines_data(ml, wizard, taxes, auto_sequence) ) account_ids_data = self._get_account_data(accounts) partner_ids_data = self._get_partner_data(partners) @@ -350,6 +353,7 @@ class JournalLedgerReport(models.AbstractModel): "date_from": data["date_from"], "date_to": data["date_to"], "move_target": data["move_target"], + "with_auto_sequence": data["with_auto_sequence"], "account_ids_data": account_ids_data, "partner_ids_data": partner_ids_data, "currency_ids_data": currency_ids_data, diff --git a/account_financial_report/report/journal_ledger_xlsx.py b/account_financial_report/report/journal_ledger_xlsx.py index 104c531e..aa2cb7f2 100644 --- a/account_financial_report/report/journal_ledger_xlsx.py +++ b/account_financial_report/report/journal_ledger_xlsx.py @@ -27,6 +27,11 @@ class JournalLedgerXslx(models.AbstractModel): {"header": _("Account"), "field": "account_code", "width": 9}, ] + if report.with_auto_sequence: + columns.insert( + 0, {"header": _("Sequence"), "field": "auto_sequence", "width": 10} + ) + if report.with_account_name: columns.append( {"header": _("Account Name"), "field": "account_name", "width": 15} @@ -221,6 +226,7 @@ class JournalLedgerXslx(models.AbstractModel): line["partner"] = self._get_partner_name( line["partner_id"], partner_ids_data ) + line["auto_sequence"] = line["auto_sequence"] line["account_code"] = account_code line["account_name"] = account_name line["currency_name"] = currency_name diff --git a/account_financial_report/report/templates/journal_ledger.xml b/account_financial_report/report/templates/journal_ledger.xml index 3c511218..361cdba6 100644 --- a/account_financial_report/report/templates/journal_ledger.xml +++ b/account_financial_report/report/templates/journal_ledger.xml @@ -12,6 +12,7 @@