Browse Source

Merge f4e7646adc into 384532e4cf

pull/744/merge
Tom 4 years ago
committed by GitHub
parent
commit
d118bf21d5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 34
      account_financial_report/README.rst
  2. 3
      account_financial_report/__manifest__.py
  3. 1749
      account_financial_report/i18n/account_financial_report.pot
  4. 1852
      account_financial_report/i18n/ar.po
  5. 1726
      account_financial_report/i18n/ca.po
  6. 2611
      account_financial_report/i18n/da.po
  7. 2120
      account_financial_report/i18n/de.po
  8. 1824
      account_financial_report/i18n/es.po
  9. 1785
      account_financial_report/i18n/es_AR.po
  10. 1914
      account_financial_report/i18n/fr.po
  11. 1899
      account_financial_report/i18n/fr_CH.po
  12. 1852
      account_financial_report/i18n/hr.po
  13. 1704
      account_financial_report/i18n/hr_HR.po
  14. 1969
      account_financial_report/i18n/it.po
  15. 1678
      account_financial_report/i18n/ja.po
  16. 1968
      account_financial_report/i18n/nl.po
  17. 1693
      account_financial_report/i18n/nl_NL.po
  18. 2133
      account_financial_report/i18n/pt.po
  19. 2052
      account_financial_report/i18n/pt_BR.po
  20. 2028
      account_financial_report/i18n/ro.po
  21. 2615
      account_financial_report/i18n/sl.po
  22. 1
      account_financial_report/models/__init__.py
  23. 20
      account_financial_report/models/account_group.py
  24. 10
      account_financial_report/models/account_move_line.py
  25. 25
      account_financial_report/models/ir_actions_report.py
  26. 9
      account_financial_report/readme/CONTRIBUTORS.rst
  27. 1
      account_financial_report/readme/ROADMAP.rst
  28. 1
      account_financial_report/report/__init__.py
  29. 25
      account_financial_report/report/abstract_report.py
  30. 208
      account_financial_report/report/abstract_report_xlsx.py
  31. 1051
      account_financial_report/report/aged_partner_balance.py
  32. 153
      account_financial_report/report/aged_partner_balance_xlsx.py
  33. 2535
      account_financial_report/report/general_ledger.py
  34. 269
      account_financial_report/report/general_ledger_xlsx.py
  35. 1039
      account_financial_report/report/journal_ledger.py
  36. 123
      account_financial_report/report/journal_ledger_xlsx.py
  37. 1291
      account_financial_report/report/open_items.py
  38. 160
      account_financial_report/report/open_items_xlsx.py
  39. 595
      account_financial_report/report/templates/aged_partner_balance.xml
  40. 481
      account_financial_report/report/templates/general_ledger.xml
  41. 200
      account_financial_report/report/templates/journal_ledger.xml
  42. 412
      account_financial_report/report/templates/open_items.xml
  43. 1125
      account_financial_report/report/templates/trial_balance.xml
  44. 217
      account_financial_report/report/templates/vat_report.xml
  45. 1288
      account_financial_report/report/trial_balance.py
  46. 129
      account_financial_report/report/trial_balance_xlsx.py
  47. 573
      account_financial_report/report/vat_report.py
  48. 41
      account_financial_report/report/vat_report_xlsx.py
  49. 134
      account_financial_report/reports.xml
  50. 70
      account_financial_report/static/description/index.html
  51. 33
      account_financial_report/static/src/js/account_financial_report_backend.js
  52. 4
      account_financial_report/tests/__init__.py
  53. 444
      account_financial_report/tests/abstract_test.py
  54. 94
      account_financial_report/tests/abstract_test_foreign_currency.py
  55. 89
      account_financial_report/tests/abstract_test_tax_report.py
  56. 41
      account_financial_report/tests/test_aged_partner_balance.py
  57. 608
      account_financial_report/tests/test_general_ledger.py
  58. 366
      account_financial_report/tests/test_journal_ledger.py
  59. 39
      account_financial_report/tests/test_open_items.py
  60. 770
      account_financial_report/tests/test_trial_balance.py
  61. 410
      account_financial_report/tests/test_vat_report.py
  62. 30
      account_financial_report/view/report_template.xml
  63. 0
      account_financial_report/view/report_vat_report.xml
  64. 9
      account_financial_report/wizard/abstract_wizard.py
  65. 108
      account_financial_report/wizard/aged_partner_balance_wizard.py
  66. 23
      account_financial_report/wizard/aged_partner_balance_wizard_view.xml
  67. 174
      account_financial_report/wizard/general_ledger_wizard.py
  68. 114
      account_financial_report/wizard/general_ledger_wizard_view.xml
  69. 100
      account_financial_report/wizard/journal_ledger_wizard.py
  70. 101
      account_financial_report/wizard/open_items_wizard.py
  71. 20
      account_financial_report/wizard/open_items_wizard_view.xml
  72. 109
      account_financial_report/wizard/trial_balance_wizard.py
  73. 18
      account_financial_report/wizard/trial_balance_wizard_view.xml
  74. 49
      account_financial_report/wizard/vat_report_wizard.py
  75. 9
      account_financial_report/wizard/vat_report_wizard_view.xml

34
account_financial_report/README.rst

@ -14,19 +14,19 @@ Account Financial Reports
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github
:target: https://github.com/OCA/account-financial-reporting/tree/13.0/account_financial_report
:target: https://github.com/OCA/account-financial-reporting/tree/12.0/account_financial_report
:alt: OCA/account-financial-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-reporting-13-0/account-financial-reporting-13-0-account_financial_report
:target: https://translation.odoo-community.org/projects/account-financial-reporting-12-0/account-financial-reporting-12-0-account_financial_report
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/91/13.0
:target: https://runbot.odoo-community.org/runbot/91/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
This module adds a set of financial reports. They are accessible under
Invoicing / Reporting / OCA accounting reports.
Accounting / Reporting / OCA Reports.
- General ledger
- Trial Balance
@ -47,17 +47,6 @@ currency balances are not available.
.. contents::
:local:
Known issues / Roadmap
======================
* 'VAT Report' is valid only for cases where it's met that for each
Tax defined: all the "Account tags" of all the
'Repartition for Invoices' or 'Repartition for Credit Notes'
are different.
* It would be nice to have in reports a column indicating the
state of the entries when the option "All Entries" is selected
in "Target Moves" field in a wizard
Changelog
=========
@ -87,7 +76,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_financial_report%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_financial_report%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -100,12 +89,12 @@ Authors
* Camptocamp SA
* initOS GmbH
* redCOR AG
* ForgeFlow
* Eficent
Contributors
~~~~~~~~~~~~
* Jordi Ballester <jordi.ballester@forgeflow.com>
* Jordi Ballester <jordi.ballester@eficient.com>
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
* Simone Orsi <simone.orsi@abstract.com>
* Leonardo Pistone <leonardo.pistone@camptocamp.com>
@ -121,15 +110,14 @@ Contributors
* Akim Juillerat <akim.juillerat@camptocamp.com>
* Alexis de Lattre <alexis@via.ecp.fr>
* Mihai Fekete <feketemihai@gmail.com>
* Miquel Raïch <miquel.raich@forgeflow.com>
* Joan Sisquella <joan.sisquella@forgeflow.com>
* Miquel Raïch <miquel.raich@eficent.com>
* `Tecnativa <https://www.tecnativa.com>`__:
* Pedro M. Baeza
* Sergio Teruel
* Ernesto Tejeda
* `Druidoo <https://www.druidoo.io>`__:
* Lois Rilo <lois.rilo@forgeflow.com>
* Iván Todorovich
Much of the work in this module was done at a sprint in Sorrento, Italy in
April 2016.
@ -147,6 +135,6 @@ 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.
This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/13.0/account_financial_report>`_ project on GitHub.
This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/12.0/account_financial_report>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

3
account_financial_report/__manifest__.py

@ -1,11 +1,10 @@
# Author: Damien Crier
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Financial Reports",
"version": "13.0.1.4.2",
"version": "13.0.2.0.0",
"category": "Reporting",
"summary": "OCA Financial Reports",
"author": "Camptocamp SA,"

1749
account_financial_report/i18n/account_financial_report.pot
File diff suppressed because it is too large
View File

1852
account_financial_report/i18n/ar.po
File diff suppressed because it is too large
View File

1726
account_financial_report/i18n/ca.po
File diff suppressed because it is too large
View File

2611
account_financial_report/i18n/da.po
File diff suppressed because it is too large
View File

2120
account_financial_report/i18n/de.po
File diff suppressed because it is too large
View File

1824
account_financial_report/i18n/es.po
File diff suppressed because it is too large
View File

1785
account_financial_report/i18n/es_AR.po
File diff suppressed because it is too large
View File

1914
account_financial_report/i18n/fr.po
File diff suppressed because it is too large
View File

1899
account_financial_report/i18n/fr_CH.po
File diff suppressed because it is too large
View File

1852
account_financial_report/i18n/hr.po
File diff suppressed because it is too large
View File

1704
account_financial_report/i18n/hr_HR.po
File diff suppressed because it is too large
View File

1969
account_financial_report/i18n/it.po
File diff suppressed because it is too large
View File

1678
account_financial_report/i18n/ja.po
File diff suppressed because it is too large
View File

1968
account_financial_report/i18n/nl.po
File diff suppressed because it is too large
View File

1693
account_financial_report/i18n/nl_NL.po
File diff suppressed because it is too large
View File

2133
account_financial_report/i18n/pt.po
File diff suppressed because it is too large
View File

2052
account_financial_report/i18n/pt_BR.po
File diff suppressed because it is too large
View File

2028
account_financial_report/i18n/ro.po
File diff suppressed because it is too large
View File

2615
account_financial_report/i18n/sl.po
File diff suppressed because it is too large
View File

1
account_financial_report/models/__init__.py

@ -1,4 +1,3 @@
from . import account
from . import account_group
from . import account_move_line
from . import ir_actions_report

20
account_financial_report/models/account_group.py

@ -20,26 +20,6 @@ class AccountGroup(models.Model):
string="Compute accounts",
store=True,
)
complete_name = fields.Char("Full Name", compute="_compute_complete_name")
complete_code = fields.Char("Full Code", compute="_compute_complete_code")
@api.depends("name", "parent_id.complete_name")
def _compute_complete_name(self):
""" Forms complete name of location from parent location to child location. """
if self.parent_id.complete_name:
self.complete_name = "{}/{}".format(self.parent_id.complete_name, self.name)
else:
self.complete_name = self.name
@api.depends("code_prefix", "parent_id.complete_code")
def _compute_complete_code(self):
""" Forms complete code of location from parent location to child location. """
if self.parent_id.complete_code:
self.complete_code = "{}/{}".format(
self.parent_id.complete_code, self.code_prefix
)
else:
self.complete_code = self.code_prefix
@api.depends("parent_id", "parent_id.level")
def _compute_level(self):

10
account_financial_report/models/account_move_line.py

@ -1,6 +1,6 @@
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
from odoo import api, models
from odoo import models
class AccountMoveLine(models.Model):
@ -30,11 +30,3 @@ class AccountMoveLine(models.Model):
CREATE INDEX account_move_line_account_id_partner_id_index
ON account_move_line (account_id, partner_id)"""
)
@api.model
def search_count(self, args):
# In Big DataBase every time you change the domain widget this method
# takes a lot of time. This improves performance
if self.env.context.get("skip_search_count"):
return 0
return super(AccountMoveLine, self).search_count(args)

25
account_financial_report/models/ir_actions_report.py

@ -1,25 +0,0 @@
# Copyright 2020 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, models
class IrActionsReport(models.Model):
_inherit = "ir.actions.report"
@api.model
def _prepare_account_financial_report_context(self, data):
lang = data and data.get("account_financial_report_lang") or ""
return dict(self.env.context or {}, lang=lang) if lang else False
@api.model
def render_qweb_html(self, docids, data=None):
context = self._prepare_account_financial_report_context(data)
obj = self.with_context(context) if context else self
return super(IrActionsReport, obj).render_qweb_html(docids, data)
@api.model
def render_xlsx(self, docids, data):
context = self._prepare_account_financial_report_context(data)
obj = self.with_context(context) if context else self
return super(IrActionsReport, obj).render_xlsx(docids, data)

9
account_financial_report/readme/CONTRIBUTORS.rst

@ -14,15 +14,18 @@
* Akim Juillerat <akim.juillerat@camptocamp.com>
* Alexis de Lattre <alexis@via.ecp.fr>
* Mihai Fekete <feketemihai@gmail.com>
* Miquel Raïch <miquel.raich@forgeflow.com>
* Joan Sisquella <joan.sisquella@forgeflow.com>
* Miquel Raïch <miquel.raich@eficent.com>
* `Tecnativa <https://www.tecnativa.com>`__:
* Pedro M. Baeza
* Sergio Teruel
* Ernesto Tejeda
* Lois Rilo <lois.rilo@forgeflow.com>
* `Druidoo <https://www.druidoo.io>`__:
* Iván Todorovich
* Tom Blauwendraat <tom@sunflowerweb.nl>
Much of the work in this module was done at a sprint in Sorrento, Italy in
April 2016.

1
account_financial_report/readme/ROADMAP.rst

@ -5,3 +5,4 @@
* It would be nice to have in reports a column indicating the
state of the entries when the option "All Entries" is selected
in "Target Moves" field in a wizard

1
account_financial_report/report/__init__.py

@ -3,6 +3,7 @@
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
from . import abstract_report
from . import abstract_report_xlsx
from . import aged_partner_balance
from . import aged_partner_balance_xlsx

25
account_financial_report/report/abstract_report.py

@ -0,0 +1,25 @@
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from psycopg2.extensions import AsIs
from odoo import models
class AbstractReport(models.AbstractModel):
_name = "account_financial_report_abstract"
_description = "Abstract Report"
def _transient_clean_rows_older_than(self, seconds):
assert self._transient, (
"Model %s is not transient, it cannot be vacuumed!" % self._name
)
# Never delete rows used in last 5 minutes
seconds = max(seconds, 300)
query = (
"DELETE FROM %s"
" WHERE COALESCE("
"write_date, create_date, (now() at time zone 'UTC'))"
"::timestamp < ((now() at time zone 'UTC') - interval %s)"
)
self.env.cr.execute(query, (AsIs(self._table), "%s seconds" % seconds))

208
account_financial_report/report/abstract_report_xlsx.py

@ -1,7 +1,10 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import datetime
from odoo import models
from odoo.tools import format_date
class AbstractReportXslx(models.AbstractModel):
@ -41,7 +44,7 @@ class AbstractReportXslx(models.AbstractModel):
self._define_formats(workbook)
report_name = self._get_report_name(report, data=data)
report_name = self._get_report_name(report)
report_footer = self._get_report_footer()
filters = self._get_report_filters(report)
self.columns = self._get_report_columns(report)
@ -54,13 +57,14 @@ class AbstractReportXslx(models.AbstractModel):
self._write_filters(filters)
self._generate_report_content(workbook, report, data)
self._generate_report_content(workbook, report)
self._write_report_footer(report_footer)
def _define_formats(self, workbook):
""" Add cell formats to current workbook.
Those formats can be used on all cell.
Available formats are :
* format_bold
* format_right
@ -202,6 +206,8 @@ class AbstractReportXslx(models.AbstractModel):
"""
for col_pos, column in self.columns.items():
value = getattr(line_object, column["field"])
if isinstance(value, datetime.date):
value = format_date(self.env, value)
cell_type = column.get("type", "string")
if cell_type == "many2one":
self.sheet.write_string(
@ -236,54 +242,10 @@ class AbstractReportXslx(models.AbstractModel):
)
self.row_pos += 1
def write_line_from_dict(self, line_dict):
"""Write a line on current line
"""
for col_pos, column in self.columns.items():
value = line_dict.get(column["field"], False)
cell_type = column.get("type", "string")
if cell_type == "string":
if (
line_dict.get("account_group_id", False)
and line_dict["account_group_id"]
):
self.sheet.write_string(
self.row_pos, col_pos, value or "", self.format_bold
)
else:
if (
not isinstance(value, str)
and not isinstance(value, bool)
and not isinstance(value, int)
):
value = value and value.strftime("%d/%m/%Y")
self.sheet.write_string(self.row_pos, col_pos, value or "")
elif cell_type == "amount":
if (
line_dict.get("account_group_id", False)
and line_dict["account_group_id"]
):
cell_format = self.format_amount_bold
else:
cell_format = self.format_amount
self.sheet.write_number(
self.row_pos, col_pos, float(value), cell_format
)
elif cell_type == "amount_currency":
if line_dict.get("currency_name", False):
format_amt = self._get_currency_amt_format_dict(line_dict)
self.sheet.write_number(
self.row_pos, col_pos, float(value), format_amt
)
elif cell_type == "currency_name":
self.sheet.write_string(
self.row_pos, col_pos, value or "", self.format_right
)
self.row_pos += 1
def write_initial_balance(self, my_object, label):
"""Write a specific initial balance line on current line
using defined columns field_initial_balance name.
Columns are defined with `_get_report_columns` method.
"""
col_pos_label = self._get_col_pos_initial_balance_label()
@ -314,42 +276,10 @@ class AbstractReportXslx(models.AbstractModel):
)
self.row_pos += 1
def write_initial_balance_from_dict(self, my_object, label):
"""Write a specific initial balance line on current line
using defined columns field_initial_balance name.
Columns are defined with `_get_report_columns` method.
"""
col_pos_label = self._get_col_pos_initial_balance_label()
self.sheet.write(self.row_pos, col_pos_label, label, self.format_right)
for col_pos, column in self.columns.items():
if column.get("field_initial_balance"):
value = my_object.get(column["field_initial_balance"], False)
cell_type = column.get("type", "string")
if cell_type == "string":
self.sheet.write_string(self.row_pos, col_pos, value or "")
elif cell_type == "amount":
self.sheet.write_number(
self.row_pos, col_pos, float(value), self.format_amount
)
elif cell_type == "amount_currency":
if my_object["currency_id"]:
format_amt = self._get_currency_amt_format(my_object)
self.sheet.write_number(
self.row_pos, col_pos, float(value), format_amt
)
elif column.get("field_currency_balance"):
value = my_object.get(column["field_currency_balance"], False)
cell_type = column.get("type", "string")
if cell_type == "many2one":
if my_object["currency_id"]:
self.sheet.write_string(
self.row_pos, col_pos, value.name or "", self.format_right
)
self.row_pos += 1
def write_ending_balance(self, my_object, name, label):
"""Write a specific ending balance line on current line
using defined columns field_final_balance name.
Columns are defined with `_get_report_columns` method.
"""
for i in range(0, len(self.columns)):
@ -396,103 +326,30 @@ class AbstractReportXslx(models.AbstractModel):
)
self.row_pos += 1
def write_ending_balance_from_dict(self, my_object, name, label):
"""Write a specific ending balance line on current line
using defined columns field_final_balance name.
Columns are defined with `_get_report_columns` method.
"""
for i in range(0, len(self.columns)):
self.sheet.write(self.row_pos, i, "", self.format_header_right)
row_count_name = self._get_col_count_final_balance_name()
col_pos_label = self._get_col_pos_final_balance_label()
self.sheet.merge_range(
self.row_pos,
0,
self.row_pos,
row_count_name - 1,
name,
self.format_header_left,
)
self.sheet.write(self.row_pos, col_pos_label, label, self.format_header_right)
for col_pos, column in self.columns.items():
if column.get("field_final_balance"):
value = my_object.get(column["field_final_balance"], False)
cell_type = column.get("type", "string")
if cell_type == "string":
self.sheet.write_string(
self.row_pos, col_pos, value or "", self.format_header_right
)
elif cell_type == "amount":
self.sheet.write_number(
self.row_pos, col_pos, float(value), self.format_header_amount
)
elif cell_type == "amount_currency":
if my_object["currency_id"] and value:
format_amt = self._get_currency_amt_format_dict(my_object)
self.sheet.write_number(
self.row_pos, col_pos, float(value), format_amt
)
elif column.get("field_currency_balance"):
value = my_object.get(column["field_currency_balance"], False)
cell_type = column.get("type", "string")
if cell_type == "many2one":
if my_object["currency_id"]:
self.sheet.write_string(
self.row_pos, col_pos, value or "", self.format_header_right
)
elif cell_type == "currency_name":
self.sheet.write_string(
self.row_pos, col_pos, value or "", self.format_header_right
)
self.row_pos += 1
def _get_currency_amt_format(self, line_object):
""" Return amount format specific for each currency. """
if "account_group_id" in line_object and line_object["account_group_id"]:
if hasattr(line_object, "account_group_id") and line_object.account_group_id:
format_amt = self.format_amount_bold
field_prefix = "format_amount_bold"
else:
format_amt = self.format_amount
field_prefix = "format_amount"
if "currency_id" in line_object and line_object.get("currency_id", False):
field_name = "{}_{}".format(field_prefix, line_object["currency_id"].name)
if line_object.currency_id:
field_name = "{}_{}".format(field_prefix, line_object.currency_id.name)
if hasattr(self, field_name):
format_amt = getattr(self, field_name)
else:
format_amt = self.workbook.add_format()
self.field_name = format_amt
format_amount = "#,##0." + (
"0" * line_object["currency_id"].decimal_places
"0" * line_object.currency_id.decimal_places
)
format_amt.set_num_format(format_amount)
return format_amt
def _get_currency_amt_format_dict(self, line_dict):
""" Return amount format specific for each currency. """
if line_dict.get("account_group_id", False) and line_dict["account_group_id"]:
format_amt = self.format_amount_bold
field_prefix = "format_amount_bold"
else:
format_amt = self.format_amount
field_prefix = "format_amount"
if line_dict.get("currency_id", False) and line_dict["currency_id"]:
if isinstance(line_dict["currency_id"], int):
currency = self.env["res.currency"].browse(line_dict["currency_id"])
else:
currency = line_dict["currency_id"]
field_name = "{}_{}".format(field_prefix, currency.name)
if hasattr(self, field_name):
format_amt = getattr(self, field_name)
else:
format_amt = self.workbook.add_format()
self.field_name = format_amt
format_amount = "#,##0." + ("0" * currency.decimal_places)
format_amt.set_num_format(format_amount)
return format_amt
def _get_currency_amt_header_format(self, line_object):
""" Return amount header format for each currency. """
format_amt = self.format_header_amount
format_amt = getattr(self, "format_header_amount")
if line_object.currency_id:
field_name = "format_header_amount_%s" % line_object.currency_id.name
if hasattr(self, field_name):
@ -501,49 +358,33 @@ class AbstractReportXslx(models.AbstractModel):
format_amt = self.workbook.add_format(
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
)
self.field_name = format_amt
setattr(self, "field_name", format_amt)
format_amount = "#,##0." + (
"0" * line_object.currency_id.decimal_places
)
format_amt.set_num_format(format_amount)
return format_amt
def _get_currency_amt_header_format_dict(self, line_object):
""" Return amount header format for each currency. """
format_amt = self.format_header_amount
if line_object["currency_id"]:
field_name = "format_header_amount_%s" % line_object["currency_name"]
if hasattr(self, field_name):
format_amt = getattr(self, field_name)
else:
format_amt = self.workbook.add_format(
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
)
self.field_name = format_amt
format_amount = "#,##0." + (
"0" * line_object["currency_id"].decimal_places
)
format_amt.set_num_format(format_amount)
return format_amt
def _generate_report_content(self, workbook, report, data):
def _generate_report_content(self, workbook, report):
"""
Allow to fetch report content to be displayed.
"""
raise NotImplementedError()
def _get_report_complete_name(self, report, prefix, data=None):
def _get_report_complete_name(self, report, prefix):
if report.company_id:
suffix = " - {} - {}".format(
report.company_id.name, report.company_id.currency_id.name
report.company_id.name,
report.company_id.currency_id.name,
)
return prefix + suffix
return prefix
def _get_report_name(self, report, data=False):
def _get_report_name(self, report):
"""
Allow to define the report name.
Report name will be used as sheet name and as report title.
:return: the report name
"""
raise NotImplementedError()
@ -559,8 +400,11 @@ class AbstractReportXslx(models.AbstractModel):
"""
Allow to define the report columns
which will be used to generate report.
:return: the report columns as dict
:Example:
{
0: {'header': 'Simple column',
'field': 'field_name_on_my_object',
@ -576,7 +420,9 @@ class AbstractReportXslx(models.AbstractModel):
def _get_report_filters(self, report):
"""
:return: the report filters as list
:Example:
[
['first_filter_name', 'first_filter_value'],
['second_filter_name', 'second_filter_value']

1051
account_financial_report/report/aged_partner_balance.py
File diff suppressed because it is too large
View File

153
account_financial_report/report/aged_partner_balance_xlsx.py

@ -7,73 +7,68 @@ from odoo import _, models
class AgedPartnerBalanceXslx(models.AbstractModel):
_name = "report.a_f_r.report_aged_partner_balance_xlsx"
_description = "Aged Partner Balance XLSL Report"
_description = "Aged Partner Balance XLSX Report"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report, data=False):
company_id = data.get("company_id", False)
def _get_report_name(self, report):
report_name = _("Aged Partner Balance")
if company_id:
company = self.env["res.company"].browse(company_id)
suffix = " - {} - {}".format(company.name, company.currency_id.name)
report_name = report_name + suffix
return report_name
return self._get_report_complete_name(report, report_name)
def _get_report_columns(self, report):
if not report.show_move_line_details:
return {
0: {"header": _("Partner"), "field": "name", "width": 70},
0: {"header": _("Partner"), "field": "partner", "width": 70},
1: {
"header": _("Residual"),
"field": "residual",
"field_footer_total": "residual",
"field": "amount_residual",
"field_footer_total": "cumul_amount_residual",
"type": "amount",
"width": 14,
},
2: {
"header": _("Current"),
"field": "current",
"field_footer_total": "current",
"field_footer_total": "cumul_current",
"field_footer_percent": "percent_current",
"type": "amount",
"width": 14,
},
3: {
"header": _(u"Age ≤ 30 d."),
"field": "30_days",
"field_footer_total": "30_days",
"field_footer_percent": "percent_30_days",
"field": "age_30_days",
"field_footer_total": "cumul_age_30_days",
"field_footer_percent": "percent_age_30_days",
"type": "amount",
"width": 14,
},
4: {
"header": _(u"Age ≤ 60 d."),
"field": "60_days",
"field_footer_total": "60_days",
"field_footer_percent": "percent_60_days",
"field": "age_60_days",
"field_footer_total": "cumul_age_60_days",
"field_footer_percent": "percent_age_60_days",
"type": "amount",
"width": 14,
},
5: {
"header": _(u"Age ≤ 90 d."),
"field": "90_days",
"field_footer_total": "90_days",
"field_footer_percent": "percent_90_days",
"field": "age_90_days",
"field_footer_total": "cumul_age_90_days",
"field_footer_percent": "percent_age_90_days",
"type": "amount",
"width": 14,
},
6: {
"header": _(u"Age ≤ 120 d."),
"field": "120_days",
"field_footer_total": "120_days",
"field_footer_percent": "percent_120_days",
"field": "age_120_days",
"field_footer_total": "cumul_age_120_days",
"field_footer_percent": "percent_age_120_days",
"type": "amount",
"width": 14,
},
7: {
"header": _("Older"),
"field": "older",
"field_footer_total": "older",
"field_footer_total": "cumul_older",
"field_footer_percent": "percent_older",
"type": "amount",
"width": 14,
@ -85,20 +80,20 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
2: {"header": _("Journal"), "field": "journal", "width": 8},
3: {"header": _("Account"), "field": "account", "width": 9},
4: {"header": _("Partner"), "field": "partner", "width": 25},
5: {"header": _("Ref - Label"), "field": "ref_label", "width": 40},
6: {"header": _("Due date"), "field": "due_date", "width": 11},
5: {"header": _("Ref - Label"), "field": "label", "width": 40},
6: {"header": _("Due date"), "field": "date_due", "width": 11},
7: {
"header": _("Residual"),
"field": "residual",
"field_footer_total": "residual",
"field_final_balance": "residual",
"field": "amount_residual",
"field_footer_total": "cumul_amount_residual",
"field_final_balance": "amount_residual",
"type": "amount",
"width": 14,
},
8: {
"header": _("Current"),
"field": "current",
"field_footer_total": "current",
"field_footer_total": "cumul_current",
"field_footer_percent": "percent_current",
"field_final_balance": "current",
"type": "amount",
@ -106,44 +101,44 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
},
9: {
"header": _(u"Age ≤ 30 d."),
"field": "30_days",
"field_footer_total": "30_days",
"field_footer_percent": "percent_30_days",
"field_final_balance": "30_days",
"field": "age_30_days",
"field_footer_total": "cumul_age_30_days",
"field_footer_percent": "percent_age_30_days",
"field_final_balance": "age_30_days",
"type": "amount",
"width": 14,
},
10: {
"header": _(u"Age ≤ 60 d."),
"field": "60_days",
"field_footer_total": "60_days",
"field_footer_percent": "percent_60_days",
"field_final_balance": "60_days",
"field": "age_60_days",
"field_footer_total": "cumul_age_60_days",
"field_footer_percent": "percent_age_60_days",
"field_final_balance": "age_60_days",
"type": "amount",
"width": 14,
},
11: {
"header": _(u"Age ≤ 90 d."),
"field": "90_days",
"field_footer_total": "90_days",
"field_footer_percent": "percent_90_days",
"field_final_balance": "90_days",
"field": "age_90_days",
"field_footer_total": "cumul_age_90_days",
"field_footer_percent": "percent_age_90_days",
"field_final_balance": "age_90_days",
"type": "amount",
"width": 14,
},
12: {
"header": _(u"Age ≤ 120 d."),
"field": "120_days",
"field_footer_total": "120_days",
"field_footer_percent": "percent_120_days",
"field_final_balance": "120_days",
"field": "age_120_days",
"field_footer_total": "cumul_age_120_days",
"field_footer_percent": "percent_age_120_days",
"field_final_balance": "age_120_days",
"type": "amount",
"width": 14,
},
13: {
"header": _("Older"),
"field": "older",
"field_footer_total": "older",
"field_footer_total": "cumul_older",
"field_footer_percent": "percent_older",
"field_final_balance": "older",
"type": "amount",
@ -153,11 +148,11 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
def _get_report_filters(self, report):
return [
[_("Date at filter"), report.date_at.strftime("%d/%m/%Y")],
[_("Date at filter"), report.date_at],
[
_("Target moves filter"),
_("All posted entries")
if report.target_move == "posted"
if report.only_posted_moves
else _("All entries"),
],
]
@ -177,39 +172,34 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
def _get_col_pos_final_balance_label(self):
return 5
def _generate_report_content(self, workbook, report, data):
res_data = self.env[
"report.account_financial_report.aged_partner_balance"
]._get_report_values(report, data)
show_move_line_details = res_data["show_move_lines_details"]
aged_partner_balance = res_data["aged_partner_balance"]
if not show_move_line_details:
def _generate_report_content(self, workbook, report):
if not report.show_move_line_details:
# For each account
for account in aged_partner_balance:
for account in report.account_ids:
# Write account title
self.write_array_title(account["code"] + " - " + account["name"])
self.write_array_title(account.code + " - " + account.name)
# Display array header for partners lines
self.write_array_header()
# Display partner lines
for partner in account["partners"]:
self.write_line_from_dict(partner)
for partner in account.partner_ids:
self.write_line(partner.line_ids)
# Display account lines
self.write_account_footer_from_dict(
self.write_account_footer(
report,
account,
("Total"),
_("Total"),
"field_footer_total",
self.format_header_right,
self.format_header_amount,
False,
)
self.write_account_footer_from_dict(
self.write_account_footer(
report,
account,
("Percents"),
_("Percents"),
"field_footer_percent",
self.format_right_bold_italic,
self.format_percent_bold_italic,
@ -220,43 +210,42 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
self.row_pos += 2
else:
# For each account
for account in aged_partner_balance:
for account in report.account_ids:
# Write account title
self.write_array_title(account["code"] + " - " + account["name"])
self.write_array_title(account.code + " - " + account.name)
# For each partner
for partner in account["partners"]:
for partner in account.partner_ids:
# Write partner title
self.write_array_title(partner["name"])
self.write_array_title(partner.name)
# Display array header for move lines
self.write_array_header()
# Display account move lines
for line in partner["move_lines"]:
self.write_line_from_dict(line)
for line in partner.move_line_ids:
self.write_line(line)
# Display ending balance line for partner
self.write_ending_balance_from_dict(partner)
self.write_ending_balance(partner.line_ids)
# Line break
self.row_pos += 1
# Display account lines
self.write_account_footer_from_dict(
self.write_account_footer(
report,
account,
("Total"),
_("Total"),
"field_footer_total",
self.format_header_right,
self.format_header_amount,
False,
)
self.write_account_footer_from_dict(
self.write_account_footer(
report,
account,
("Percents"),
_("Percents"),
"field_footer_percent",
self.format_right_bold_italic,
self.format_percent_bold_italic,
@ -266,18 +255,16 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
# 2 lines break
self.row_pos += 2
def write_ending_balance_from_dict(self, my_object):
def write_ending_balance(self, my_object):
"""
Specific function to write ending partner balance
for Aged Partner Balance
"""
name = None
label = _("Partner cumul aged balance")
super(AgedPartnerBalanceXslx, self).write_ending_balance_from_dict(
my_object, name, label
)
super(AgedPartnerBalanceXslx, self).write_ending_balance(my_object, name, label)
def write_account_footer_from_dict(
def write_account_footer(
self,
report,
account,
@ -296,7 +283,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
if col_pos == col_pos_footer_label:
value = label
else:
value = account.get(column[field_name], False)
value = getattr(account, column[field_name])
cell_type = column.get("type", "string")
if cell_type == "string" or col_pos == col_pos_footer_label:
self.sheet.write_string(

2535
account_financial_report/report/general_ledger.py
File diff suppressed because it is too large
View File

269
account_financial_report/report/general_ledger_xlsx.py

@ -8,43 +8,26 @@ from odoo import _, models
class GeneralLedgerXslx(models.AbstractModel):
_name = "report.a_f_r.report_general_ledger_xlsx"
_description = "General Ledger XLSL Report"
_description = "General Ledger XLSX Report"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report, data=False):
company_id = data.get("company_id", False)
def _get_report_name(self, report):
report_name = _("General Ledger")
if company_id:
company = self.env["res.company"].browse(company_id)
suffix = " - {} - {}".format(company.name, company.currency_id.name)
report_name = report_name + suffix
return report_name
return self._get_report_complete_name(report, report_name)
def _get_report_columns(self, report):
res = [
{"header": _("Date"), "field": "date", "width": 11},
{"header": _("Entry"), "field": "entry", "width": 18},
{"header": _("Journal"), "field": "journal", "width": 8},
{"header": _("Account"), "field": "account", "width": 9},
{"header": _("Taxes"), "field": "taxes_description", "width": 15},
{"header": _("Partner"), "field": "partner_name", "width": 25},
{"header": _("Ref - Label"), "field": "ref_label", "width": 40},
]
if report.show_cost_center:
res += [
{
"header": _("Analytic Account"),
"field": "analytic_account",
"width": 20,
},
]
if report.show_analytic_tags:
res += [
{"header": _("Tags"), "field": "tags", "width": 10},
]
res += [
{"header": _("Rec."), "field": "rec_name", "width": 15},
{
res = {
0: {"header": _("Date"), "field": "date", "width": 11},
1: {"header": _("Entry"), "field": "entry", "width": 18},
2: {"header": _("Journal"), "field": "journal", "width": 8},
3: {"header": _("Account"), "field": "account", "width": 9},
4: {"header": _("Taxes"), "field": "taxes_description", "width": 15},
5: {"header": _("Partner"), "field": "partner", "width": 25},
6: {"header": _("Ref - Label"), "field": "label", "width": 40},
7: {"header": _("Cost center"), "field": "cost_center", "width": 15},
8: {"header": _("Tags"), "field": "tags", "width": 10},
9: {"header": _("Rec."), "field": "matching_number", "width": 5},
10: {
"header": _("Debit"),
"field": "debit",
"field_initial_balance": "initial_debit",
@ -52,7 +35,7 @@ class GeneralLedgerXslx(models.AbstractModel):
"type": "amount",
"width": 14,
},
{
11: {
"header": _("Credit"),
"field": "credit",
"field_initial_balance": "initial_credit",
@ -60,37 +43,35 @@ class GeneralLedgerXslx(models.AbstractModel):
"type": "amount",
"width": 14,
},
{
12: {
"header": _("Cumul. Bal."),
"field": "balance",
"field": "cumul_balance",
"field_initial_balance": "initial_balance",
"field_final_balance": "final_balance",
"type": "amount",
"width": 14,
},
]
}
if report.foreign_currency:
res += [
{
foreign_currency = {
13: {
"header": _("Cur."),
"field": "currency_name",
"field_currency_balance": "currency_name",
"type": "currency_name",
"field": "currency_id",
"field_currency_balance": "currency_id",
"type": "many2one",
"width": 7,
},
{
14: {
"header": _("Amount cur."),
"field": "bal_curr",
"field_initial_balance": "initial_bal_curr",
"field_final_balance": "final_bal_curr",
"field": "amount_currency",
"field_initial_balance": "initial_balance_foreign_currency",
"field_final_balance": "final_balance_foreign_currency",
"type": "amount_currency",
"width": 14,
},
]
res_as_dict = {}
for i, column in enumerate(res):
res_as_dict[i] = column
return res_as_dict
}
res = {**res, **foreign_currency}
return res
def _get_report_filters(self, report):
return [
@ -101,14 +82,14 @@ class GeneralLedgerXslx(models.AbstractModel):
[
_("Target moves filter"),
_("All posted entries")
if report.target_move == "posted"
if report.only_posted_moves
else _("All entries"),
],
[
_("Account balance at 0 filter"),
_("Hide") if report.hide_account_at_0 else _("Show"),
],
[_("Centralize filter"), _("Yes") if report.centralize else _("No")],
[_("Centralize filter"), _("Yes") if report.centralize else _("No"),],
[
_("Show analytic tags"),
_("Yes") if report.show_analytic_tags else _("No"),
@ -134,197 +115,67 @@ class GeneralLedgerXslx(models.AbstractModel):
def _get_col_pos_final_balance_label(self):
return 5
# flake8: noqa: C901
def _generate_report_content(self, workbook, report, data):
res_data = self.env[
"report.account_financial_report.general_ledger"
]._get_report_values(report, data)
general_ledger = res_data["general_ledger"]
accounts_data = res_data["accounts_data"]
partners_data = res_data["partners_data"]
journals_data = res_data["journals_data"]
taxes_data = res_data["taxes_data"]
tags_data = res_data["tags_data"]
filter_partner_ids = res_data["filter_partner_ids"]
foreign_currency = res_data["foreign_currency"]
def _generate_report_content(self, workbook, report):
# For each account
for account in general_ledger:
for account in report.account_ids:
# Write account title
self.write_array_title(
account["code"] + " - " + accounts_data[account["id"]]["name"]
)
self.write_array_title(account.code + " - " + account.name)
if not account["partners"]:
if not account.partner_ids:
# Display array header for move lines
self.write_array_header()
# Display initial balance line for account
account.update(
{
"initial_debit": account["init_bal"]["debit"],
"initial_credit": account["init_bal"]["credit"],
"initial_balance": account["init_bal"]["balance"],
}
)
if foreign_currency:
account.update(
{"initial_bal_curr": account["init_bal"]["bal_curr"]}
)
self.write_initial_balance_from_dict(account)
self.write_initial_balance(account)
# Display account move lines
for line in account["move_lines"]:
line.update(
{
"account": account["code"],
"journal": journals_data[line["journal_id"]]["code"],
}
)
if line["currency_id"]:
line.update(
{
"currency_name": line["currency_id"][1],
"currency_id": line["currency_id"][0],
}
)
if line["ref_label"] != "Centralized entries":
taxes_description = ""
tags = ""
for tax_id in line["tax_ids"]:
taxes_description += taxes_data[tax_id]["tax_name"] + " "
for tag_id in line["tag_ids"]:
tags += tags_data[tag_id]["name"] + " "
line.update(
{"taxes_description": taxes_description, "tags": tags,}
)
self.write_line_from_dict(line)
# Display ending balance line for account
account.update(
{
"final_debit": account["fin_bal"]["debit"],
"final_credit": account["fin_bal"]["credit"],
"final_balance": account["fin_bal"]["balance"],
}
)
if foreign_currency:
account.update(
{"final_bal_curr": account["fin_bal"]["bal_curr"],}
)
self.write_ending_balance_from_dict(account)
for line in account.move_line_ids:
self.write_line(line)
else:
# For each partner
for partner in account["list_partner"]:
for partner in account.partner_ids:
# Write partner title
self.write_array_title(partners_data[partner["id"]]["name"])
self.write_array_title(partner.name)
# Display array header for move lines
self.write_array_header()
# Display initial balance line for partner
partner.update(
{
"initial_debit": partner["init_bal"]["debit"],
"initial_credit": partner["init_bal"]["credit"],
"initial_balance": partner["init_bal"]["balance"],
"name": partners_data[partner["id"]]["name"],
"type": "partner",
"currency_id": accounts_data[account["id"]]["currency_id"],
}
)
if foreign_currency:
partner.update(
{"initial_bal_curr": partner["init_bal"]["bal_curr"],}
)
self.write_initial_balance_from_dict(partner)
self.write_initial_balance(partner)
# Display account move lines
for line in partner["move_lines"]:
line.update(
{
"account": account["code"],
"journal": journals_data[line["journal_id"]]["code"],
}
)
if line["currency_id"]:
line.update(
{
"currency_name": line["currency_id"][1],
"currency_id": line["currency_id"][0],
}
)
if line["ref_label"] != "Centralized entries":
taxes_description = ""
tags = ""
for tax_id in line["tax_ids"]:
taxes_description += (
taxes_data[tax_id]["tax_name"] + " "
)
for tag_id in line["tag_ids"]:
tags += tags_data[tag_id]["name"] + " "
line.update(
{"taxes_description": taxes_description, "tags": tags,}
)
self.write_line_from_dict(line)
for line in partner.move_line_ids:
self.write_line(line)
# Display ending balance line for partner
partner.update(
{
"final_debit": partner["fin_bal"]["debit"],
"final_credit": partner["fin_bal"]["credit"],
"final_balance": partner["fin_bal"]["balance"],
}
)
if foreign_currency and partner["currency_id"]:
partner.update(
{
"final_bal_curr": partner["fin_bal"]["bal_curr"],
"currency_name": partner["currency_id"].name,
"currency_id": partner["currency_id"].id,
}
)
self.write_ending_balance_from_dict(partner)
self.write_ending_balance(partner)
# Line break
self.row_pos += 1
if not filter_partner_ids:
account.update(
{
"final_debit": account["fin_bal"]["debit"],
"final_credit": account["fin_bal"]["credit"],
"final_balance": account["fin_bal"]["balance"],
}
)
if foreign_currency and account["currency_id"]:
account.update(
{
"final_bal_curr": account["fin_bal"]["bal_curr"],
"currency_name": account["currency_id"].name,
"currency_id": account["currency_id"].id,
}
)
self.write_ending_balance_from_dict(account)
# Display ending balance line for account
if not report.filter_partner_ids:
self.write_ending_balance(account)
# 2 lines break
self.row_pos += 2
def write_initial_balance_from_dict(self, my_object):
def write_initial_balance(self, my_object):
"""Specific function to write initial balance for General Ledger"""
if "partner" in my_object["type"]:
if "partner" in my_object._name:
label = _("Partner Initial balance")
elif "account" in my_object["type"]:
my_object.currency_id = my_object.report_account_id.currency_id
elif "account" in my_object._name:
label = _("Initial balance")
super(GeneralLedgerXslx, self).write_initial_balance_from_dict(my_object, label)
super(GeneralLedgerXslx, self).write_initial_balance(my_object, label)
def write_ending_balance_from_dict(self, my_object):
def write_ending_balance(self, my_object):
"""Specific function to write ending balance for General Ledger"""
if "partner" in my_object["type"]:
name = my_object["name"]
if "partner" in my_object._name:
name = my_object.name
label = _("Partner ending balance")
elif "account" in my_object["type"]:
name = my_object["code"] + " - " + my_object["name"]
elif "account" in my_object._name:
name = my_object.code + " - " + my_object.name
label = _("Ending balance")
super(GeneralLedgerXslx, self).write_ending_balance_from_dict(
my_object, name, label
)
super(GeneralLedgerXslx, self).write_ending_balance(my_object, name, label)

1039
account_financial_report/report/journal_ledger.py
File diff suppressed because it is too large
View File

123
account_financial_report/report/journal_ledger_xlsx.py

@ -8,17 +8,12 @@ from odoo import _, models
class JournalLedgerXslx(models.AbstractModel):
_name = "report.a_f_r.report_journal_ledger_xlsx"
_description = "Journal Ledger XLSX Report"
_description = "Journal Ledger Report XLSX"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report, data=False):
company_id = data.get("company_id", False)
def _get_report_name(self, report):
report_name = _("Journal Ledger")
if company_id:
company = self.env["res.company"].browse(company_id)
suffix = " - {} - {}".format(company.name, company.currency_id.name)
report_name = report_name + suffix
return report_name
return self._get_report_complete_name(report, report_name)
def _get_report_columns(self, report):
columns = [
@ -29,14 +24,14 @@ class JournalLedgerXslx(models.AbstractModel):
if report.with_account_name:
columns.append(
{"header": _("Account Name"), "field": "account_name", "width": 15}
{"header": _("Account Name"), "field": "account", "width": 15}
)
columns += [
{"header": _("Partner"), "field": "partner", "width": 25},
{"header": _("Ref - Label"), "field": "label", "width": 40},
{"header": _("Taxes"), "field": "taxes_description", "width": 11},
{"header": _("Debit"), "field": "debit", "type": "amount", "width": 14},
{"header": _("Debit"), "field": "debit", "type": "amount", "width": 14,},
{"header": _("Credit"), "field": "credit", "type": "amount", "width": 14},
]
@ -44,9 +39,9 @@ class JournalLedgerXslx(models.AbstractModel):
columns += [
{
"header": _("Currency"),
"field": "currency_name",
"field": "currency_id",
"type": "many2one",
"width": 14,
"type": "currency_name",
},
{
"header": _("Amount Currency"),
@ -143,58 +138,55 @@ class JournalLedgerXslx(models.AbstractModel):
", ".join(
[
"{} - {}".format(report_journal.code, report_journal.name)
for report_journal in report.journal_ids
for report_journal in report.report_journal_ledger_ids
]
),
],
]
def _generate_report_content(self, workbook, report, data):
res_data = self.env[
"report.account_financial_report.journal_ledger"
]._get_report_values(report, data)
def _generate_report_content(self, workbook, report):
group_option = report.group_option
if group_option == "journal":
for ledger in res_data["Journal_Ledgers"]:
self._generate_journal_content(workbook, report, res_data, ledger)
for report_journal in report.report_journal_ledger_ids:
self._generate_journal_content(workbook, report_journal)
elif group_option == "none":
self._generate_no_group_content(workbook, report, res_data)
self._generate_no_group_content(workbook, report)
def _generate_no_group_content(self, workbook, report, res_data):
self._generate_moves_content(
workbook, "Report", report, res_data, res_data["Moves"]
)
self._generate_no_group_taxes_summary(workbook, report, res_data)
def _generate_journal_content(self, workbook, report, res_data, ledger):
journal = self.env["account.journal"].browse(ledger["id"])
currency_name = (
journal.currency_id
and journal.currency_id.name
or journal.company_id.currency_id.name
def _generate_no_group_content(self, workbook, report):
self._generate_moves_content(workbook, report, "Report", report.report_move_ids)
self._generate_no_group_taxes_summary(workbook, report)
def _generate_journal_content(self, workbook, report_journal):
sheet_name = "{} ({}) - {}".format(
report_journal.code,
report_journal.currency_id.name,
report_journal.name,
)
sheet_name = "{} ({}) - {}".format(journal.code, currency_name, journal.name)
self._generate_moves_content(
workbook, sheet_name, report, res_data, ledger["report_moves"]
workbook,
report_journal.report_id,
sheet_name,
report_journal.report_move_ids,
)
self._generate_journal_taxes_summary(workbook, ledger)
def _generate_no_group_taxes_summary(self, workbook, report, res_data):
self._generate_taxes_summary(workbook, "Tax Report", res_data["tax_line_data"])
self._generate_journal_taxes_summary(workbook, report_journal)
def _generate_journal_taxes_summary(self, workbook, ledger):
journal = self.env["account.journal"].browse(ledger["id"])
currency_name = (
journal.currency_id
and journal.currency_id.name
or journal.company_id.currency_id.name
def _generate_no_group_taxes_summary(self, workbook, report):
self._generate_taxes_summary(
workbook, report, "Tax Report", report.report_tax_line_ids
)
def _generate_journal_taxes_summary(self, workbook, report_journal):
sheet_name = "Tax - {} ({}) - {}".format(
journal.code, currency_name, journal.name
report_journal.code,
report_journal.currency_id.name,
report_journal.name,
)
report = report_journal.report_id
self._generate_taxes_summary(
workbook, report, sheet_name, report_journal.report_tax_line_ids
)
self._generate_taxes_summary(workbook, sheet_name, ledger["tax_lines"])
def _generate_moves_content(self, workbook, sheet_name, report, res_data, moves):
def _generate_moves_content(self, workbook, report, sheet_name, moves):
self.workbook = workbook
self.sheet = workbook.add_worksheet(sheet_name)
self._set_column_width()
@ -205,46 +197,15 @@ class JournalLedgerXslx(models.AbstractModel):
self.row_pos += 2
self.write_array_header()
account_ids_data = res_data["account_ids_data"]
partner_ids_data = res_data["partner_ids_data"]
currency_ids_data = res_data["currency_ids_data"]
move_ids_data = res_data["move_ids_data"]
for move in moves:
for line in move["report_move_lines"]:
currency_data = currency_ids_data.get(line["currency_id"], False)
currency_name = currency_data and currency_data["name"] or ""
account_data = account_ids_data.get(line["account_id"], False)
account_name = account_data and account_data["name"] or ""
account_code = account_data and account_data["code"] or ""
move_data = move_ids_data.get(line["move_id"], False)
move_entry = move_data and move_data["entry"] or ""
line["partner"] = self._get_partner_name(
line["partner_id"], partner_ids_data
)
line["account_code"] = account_code
line["account_name"] = account_name
line["currency_name"] = currency_name
line["entry"] = move_entry
line["taxes_description"] = report._get_ml_tax_description(
line,
res_data["tax_line_data"].get(line["tax_line_id"]),
res_data["move_line_ids_taxes_data"].get(
line["move_line_id"], False
),
)
self.write_line_from_dict(line)
for line in move.report_move_line_ids:
self.write_line(line)
self.row_pos += 1
def _generate_taxes_summary(self, workbook, sheet_name, tax_lines_dict):
def _generate_taxes_summary(self, workbook, report, sheet_name, tax_lines):
self.workbook = workbook
self.sheet = workbook.add_worksheet(sheet_name)
self.row_pos = 1
self.write_array_title(sheet_name)
self.row_pos += 2
def _get_partner_name(self, partner_id, partner_data):
if partner_id in partner_data.keys():
return partner_data[partner_id]["name"]
else:
return ""

1291
account_financial_report/report/open_items.py
File diff suppressed because it is too large
View File

160
account_financial_report/report/open_items_xlsx.py

@ -7,37 +7,32 @@ from odoo import _, models
class OpenItemsXslx(models.AbstractModel):
_name = "report.a_f_r.report_open_items_xlsx"
_description = "Open Items XLSX Report"
_description = "Open Items Report XLSX"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report, data=False):
company_id = data.get("company_id", False)
def _get_report_name(self, report):
report_name = _("Open Items")
if company_id:
company = self.env["res.company"].browse(company_id)
suffix = " - {} - {}".format(company.name, company.currency_id.name)
report_name = report_name + suffix
return report_name
return self._get_report_complete_name(report, report_name)
def _get_report_columns(self, report):
res = {
0: {"header": _("Date"), "field": "date", "width": 11},
1: {"header": _("Entry"), "field": "move_name", "width": 18},
1: {"header": _("Entry"), "field": "entry", "width": 18},
2: {"header": _("Journal"), "field": "journal", "width": 8},
3: {"header": _("Account"), "field": "account", "width": 9},
4: {"header": _("Partner"), "field": "partner_name", "width": 25},
5: {"header": _("Ref - Label"), "field": "ref_label", "width": 40},
6: {"header": _("Due date"), "field": "date_maturity", "width": 11},
4: {"header": _("Partner"), "field": "partner", "width": 25},
5: {"header": _("Ref - Label"), "field": "label", "width": 40},
6: {"header": _("Due date"), "field": "date_due", "width": 11},
7: {
"header": _("Original"),
"field": "original",
"field": "amount_total_due",
"type": "amount",
"width": 14,
},
8: {
"header": _("Residual"),
"field": "amount_residual",
"field_final_balance": "residual",
"field_final_balance": "final_amount_residual",
"type": "amount",
"width": 14,
},
@ -46,22 +41,22 @@ class OpenItemsXslx(models.AbstractModel):
foreign_currency = {
9: {
"header": _("Cur."),
"field": "currency_name",
"field_currency_balance": "currency_name",
"type": "currency_name",
"field": "currency_id",
"field_currency_balance": "currency_id",
"type": "many2one",
"width": 7,
},
10: {
"header": _("Cur. Original"),
"field": "amount_currency",
"field_final_balance": "amount_currency",
"field": "amount_total_due_currency",
"field_final_balance": "final_amount_total_due_currency",
"type": "amount_currency",
"width": 14,
},
11: {
"header": _("Cur. Residual"),
"field": "amount_residual_currency",
"field_final_balance": "amount_currency",
"field_final_balance": "final_amount_residual_currency",
"type": "amount_currency",
"width": 14,
},
@ -71,11 +66,11 @@ class OpenItemsXslx(models.AbstractModel):
def _get_report_filters(self, report):
return [
[_("Date at filter"), report.date_at.strftime("%d/%m/%Y")],
[_("Date at filter"), report.date_at],
[
_("Target moves filter"),
_("All posted entries")
if report.target_move == "posted"
if report.only_posted_moves
else _("All entries"),
],
[
@ -100,102 +95,43 @@ class OpenItemsXslx(models.AbstractModel):
def _get_col_pos_final_balance_label(self):
return 5
def _generate_report_content(self, workbook, report, data):
res_data = self.env[
"report.account_financial_report.open_items"
]._get_report_values(report, data)
def _generate_report_content(self, workbook, report):
# For each account
Open_items = res_data["Open_Items"]
accounts_data = res_data["accounts_data"]
partners_data = res_data["partners_data"]
journals_data = res_data["journals_data"]
total_amount = res_data["total_amount"]
show_partner_details = res_data["show_partner_details"]
for account_id in Open_items.keys():
for account in report.account_ids:
# Write account title
self.write_array_title(
accounts_data[account_id]["code"]
+ " - "
+ accounts_data[account_id]["name"]
)
self.write_array_title(account.code + " - " + account.name)
# For each partner
if Open_items[account_id]:
if show_partner_details:
for partner_id in Open_items[account_id]:
type_object = "partner"
# Write partner title
self.write_array_title(partners_data[partner_id]["name"])
# Display array header for move lines
self.write_array_header()
# Display account move lines
for line in Open_items[account_id][partner_id]:
line.update(
{
"account": accounts_data[account_id]["code"],
"journal": journals_data[line["journal_id"]][
"code"
],
}
)
self.write_line_from_dict(line)
# Display ending balance line for partner
partners_data[partner_id].update(
{
"currency_id": accounts_data[account_id]["currency_id"],
"currency_name": accounts_data[account_id][
"currency_name"
],
}
)
self.write_ending_balance_from_dict(
partners_data[partner_id],
type_object,
total_amount,
account_id,
partner_id,
)
# Line break
self.row_pos += 1
else:
# Display array header for move lines
self.write_array_header()
# Display account move lines
for line in Open_items[account_id]:
line.update(
{
"account": accounts_data[account_id]["code"],
"journal": journals_data[line["journal_id"]]["code"],
}
)
self.write_line_from_dict(line)
# Display ending balance line for account
type_object = "account"
self.write_ending_balance_from_dict(
accounts_data[account_id], type_object, total_amount, account_id
)
# 2 lines break
self.row_pos += 2
def write_ending_balance_from_dict(
self, my_object, type_object, total_amount, account_id=False, partner_id=False
):
for partner in account.partner_ids:
# Write partner title
self.write_array_title(partner.name)
# Display array header for move lines
self.write_array_header()
# Display account move lines
for line in partner.move_line_ids:
self.write_line(line)
# Display ending balance line for partner
self.write_ending_balance(partner, "partner")
# Line break
self.row_pos += 1
# Display ending balance line for account
self.write_ending_balance(account, "account")
# 2 lines break
self.row_pos += 2
def write_ending_balance(self, my_object, type_object):
"""Specific function to write ending balance for Open Items"""
if type_object == "partner":
name = my_object["name"]
my_object["residual"] = total_amount[account_id][partner_id]["residual"]
name = my_object.name
label = _("Partner ending balance")
my_object.currency_id = my_object.report_account_id.currency_id
elif type_object == "account":
name = my_object["code"] + " - " + my_object["name"]
my_object["residual"] = total_amount[account_id]["residual"]
name = my_object.code + " - " + my_object.name
label = _("Ending balance")
super(OpenItemsXslx, self).write_ending_balance_from_dict(
my_object, name, label
)
super(OpenItemsXslx, self).write_ending_balance(my_object, name, label)

595
account_financial_report/report/templates/aged_partner_balance.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="aged_partner_balance">
<template id="report_aged_partner_balance_qweb">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="account_financial_report.internal_layout">
@ -13,11 +13,12 @@
</template>
<template id="report_aged_partner_balance_base">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="show_move_line_details" t-value="show_move_line_details" />
<t t-set="show_move_line_details" t-value="o.show_move_line_details" />
<!-- Defines global variables used by internal layout -->
<t t-set="title">Aged Partner Balance - <t t-raw="company_name" /> - <t
t-raw="currency_name"
<t t-set="title">Aged Partner Balance - <t t-raw="o.company_id.name" /> - <t
t-raw="o.company_id.currency_id.name"
/></t>
<t t-set="company_name" t-value="o.company_id.name" />
<div class="page">
<div class="row">
<h4
@ -28,14 +29,14 @@
</div>
<!-- Display filters -->
<t t-call="account_financial_report.report_aged_partner_balance_filters" />
<t t-foreach="aged_partner_balance" t-as="account">
<t t-foreach="o.account_ids" t-as="account">
<div class="page_break">
<!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="act_as_caption account_title" style="width: 100%;">
<span t-esc="account['code']" />
<span t-field="account.code" />
-
<span t-esc="account['name']" />
<span t-field="account.name" />
</div>
<!-- Display account lines -->
<t t-if="not show_move_line_details">
@ -44,7 +45,7 @@
<t
t-call="account_financial_report.report_aged_partner_balance_lines_header"
/>
<t t-foreach="account['partners']" t-as="partner">
<t t-foreach="account.partner_ids" t-as="partner">
<!-- Display one line per partner -->
<t
t-call="account_financial_report.report_aged_partner_balance_lines"
@ -59,11 +60,11 @@
<!-- Display account move lines -->
<t t-if="show_move_line_details">
<!-- Display account partners -->
<t t-foreach="account['partners']" t-as="partner">
<t t-foreach="account.partner_ids" t-as="partner">
<div class="page_break">
<!-- Display partner header -->
<div class="act_as_caption account_title">
<span t-esc="partner['name']" />
<span t-field="partner.name" />
</div>
<!-- Display partner move lines -->
<t
@ -73,7 +74,10 @@
<t
t-call="account_financial_report.report_aged_partner_balance_partner_ending_cumul"
>
<t t-set="partner_cumul_line" t-value="partner" />
<t
t-set="partner_cumul_line"
t-value="partner.line_ids"
/>
</t>
</div>
</t>
@ -94,11 +98,11 @@
</div>
<div class="act_as_row">
<div class="act_as_cell">
<span t-esc="date_at" />
<span t-field="o.date_at" />
</div>
<div class="act_as_cell">
<t t-if="only_posted_moves">All posted entries</t>
<t t-if="not only_posted_moves">All entries</t>
<t t-if="o.only_posted_moves">All posted entries</t>
<t t-if="not o.only_posted_moves">All entries</t>
</div>
</div>
</div>
@ -127,62 +131,65 @@
</div>
</template>
<template id="report_aged_partner_balance_lines">
<!-- Display each partner lines -->
<div class="act_as_row lines">
<!--## partner-->
<div class="act_as_cell left">
<span t-esc="partner['name']" />
</div>
<!--## amount_residual-->
<div class="act_as_cell amount">
<span
t-esc="partner['residual']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## current-->
<div class="act_as_cell amount">
<span
t-esc="partner['current']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_30_days-->
<div class="act_as_cell amount">
<span
t-esc="partner['30_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_60_days-->
<div class="act_as_cell amount">
<span
t-esc="partner['60_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_90_days-->
<div class="act_as_cell amount">
<span
t-esc="partner['90_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_120_days-->
<div class="act_as_cell amount">
<span
t-esc="partner['120_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## older-->
<div class="act_as_cell amount">
<span
t-esc="partner['older']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
<!-- Display each lines -->
<t t-foreach="partner.line_ids" t-as="line">
<!-- # lines -->
<div class="act_as_row lines">
<!--## partner-->
<div class="act_as_cell left">
<span t-field="line.partner" />
</div>
<!--## amount_residual-->
<div class="act_as_cell amount">
<span
t-field="line.amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## current-->
<div class="act_as_cell amount">
<span
t-field="line.current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_30_days-->
<div class="act_as_cell amount">
<span
t-field="line.age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_60_days-->
<div class="act_as_cell amount">
<span
t-field="line.age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_90_days-->
<div class="act_as_cell amount">
<span
t-field="line.age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_120_days-->
<div class="act_as_cell amount">
<span
t-field="line.age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## older-->
<div class="act_as_cell amount">
<span
t-field="line.older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
</div>
</div>
</t>
</template>
<template id="report_aged_partner_balance_move_lines">
<div class="act_as_table data_table" style="width: 100%;">
@ -229,215 +236,264 @@
</div>
</div>
<!-- Display each move lines -->
<t t-foreach="partner['move_lines']" t-as="line">
<t t-foreach="partner.move_line_ids" t-as="line">
<!-- # lines or centralized lines -->
<div class="act_as_row lines">
<!--## date-->
<div class="act_as_cell left">
<!-- <span>-->
<!-- <a t-att-data-active-id="line.move_line_id.id"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- style="color: black;">-->
<!--## We don't use t-field because it throws an error on click -->
<t t-esc="line['date']" t-options="{'widget': 'date'}" />
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<!--## We don't use t-field because it throws an error on click -->
<t t-esc="line.date" t-options="{'widget': 'date'}" />
</a>
</span>
</div>
<!--## move-->
<div class="act_as_cell left">
<!-- <span>-->
<!-- <a t-att-data-active-id="line.move_line_id.move_id.id"-->
<!-- t-att-data-res-model="'account.move'"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- style="color: black;">-->
<t t-raw="line['entry']" />
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-active-id="line.move_line_id.move_id.id"
t-att-data-res-model="'account.move'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.entry" />
</a>
</span>
</div>
<!--## journal-->
<div class="act_as_cell left">
<!-- <span>-->
<!-- <a t-att-data-active-id="line.move_line_id.move_id.journal_id.id"-->
<!-- t-att-data-res-model="'account.journal'"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- style="color: black;">-->
<t t-raw="line['journal']" />
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-active-id="line.move_line_id.move_id.journal_id.id"
t-att-data-res-model="'account.journal'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.journal" />
</a>
</span>
</div>
<!--## account code-->
<div class="act_as_cell left">
<!-- <span>-->
<!-- <a t-att-data-active-id="line.move_line_id.account_id.id"-->
<!-- t-att-data-res-model="'account.account'"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- style="color: black;">-->
<t t-raw="line['account']" />
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-active-id="line.move_line_id.account_id.id"
t-att-data-res-model="'account.account'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.account" />
</a>
</span>
</div>
<!--## partner-->
<div class="act_as_cell left">
<!-- <span>-->
<!-- <a t-att-data-active-id="line.move_line_id.partner_id.id"-->
<!-- t-att-data-res-model="'res.partner'"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- style="color: black;">-->
<t t-raw="line['partner']" />
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-active-id="line.move_line_id.partner_id.id"
t-att-data-res-model="'res.partner'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.partner" />
</a>
</span>
</div>
<!--## ref - label-->
<div class="act_as_cell left">
<!-- <span>-->
<!-- <a t-att-data-active-id="line.move_line_id.id"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- style="color: black;">-->
<t t-raw="line['ref_label']" />
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.label" />
</a>
</span>
</div>
<!--## date_due-->
<div class="act_as_cell left">
<!-- <span>-->
<!-- <a t-att-data-active-id="line.move_line_id.id"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- style="color: black;">-->
<!--## We don't use t-field because it throws an error on click -->
<t t-esc="line['due_date']" t-options="{'widget': 'date'}" />
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<!--## We don't use t-field because it throws an error on click -->
<t
t-esc="line.date_due"
t-options="{'widget': 'date'}"
/>
</a>
</span>
</div>
<!--## amount_residual-->
<div class="act_as_cell amount">
<!-- <span>-->
<!-- <a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_multi"-->
<!-- style="color: black;">-->
<t
t-raw="line['residual']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
<!--## current-->
<div class="act_as_cell amount">
<!-- <t t-if="line.current != 0">-->
<!-- <span>-->
<!-- <a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_multi"-->
<!-- style="color: black;">-->
<t
t-raw="line['current']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
<!-- </a>-->
<!-- </span>-->
<!-- </t>-->
<!-- <t t-if="line.current == 0">-->
<!-- <span t-field="line.current" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>-->
<!-- </t>-->
<t t-if="line.current != 0">
<span>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.current == 0">
<span
t-field="line.current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
<!--## age_30_days-->
<div class="act_as_cell amount">
<!-- <t t-if="line.age_30_days != 0">-->
<!-- <span>-->
<!-- <a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_multi"-->
<!-- style="color: black;">-->
<t
t-raw="line['30_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
<!-- </a>-->
<!-- </span>-->
<!-- </t>-->
<!-- <t t-if="line.age_30_days == 0">-->
<!-- <span t-field="line.age_30_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>-->
<!-- </t>-->
<t t-if="line.age_30_days != 0">
<span>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.age_30_days == 0">
<span
t-field="line.age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
<!--## age_60_days-->
<div class="act_as_cell amount">
<!-- <t t-if="line.age_60_days != 0">-->
<!-- <span>-->
<!-- <a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_multi"-->
<!-- style="color: black;">-->
<t
t-raw="line['60_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
<!-- </a>-->
<!-- </span>-->
<!-- </t>-->
<!-- <t t-if="line.age_60_days == 0">-->
<!-- <span t-field="line.age_60_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>-->
<!-- </t>-->
<t t-if="line.age_60_days != 0">
<span>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.age_60_days == 0">
<span
t-field="line.age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
<!--## age_90_days-->
<div class="act_as_cell amount">
<!-- <t t-if="line.age_90_days != 0">-->
<!-- <span>-->
<!-- <a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_multi"-->
<!-- style="color: black;">-->
<t
t-raw="line['90_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
<!-- </a>-->
<!-- </span>-->
<!-- </t>-->
<!-- <t t-if="line.age_90_days == 0">-->
<!-- <span t-field="line.age_90_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>-->
<!-- </t>-->
<t t-if="line.age_90_days != 0">
<span>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.age_90_days == 0">
<span
t-field="line.age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
<!--## age_120_days-->
<div class="act_as_cell amount">
<!-- <t t-if="line.age_120_days != 0">-->
<!-- <span>-->
<!-- <a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_multi"-->
<!-- style="color: black;">-->
<t
t-raw="line['120_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
<!-- </a>-->
<!-- </span>-->
<!-- </t>-->
<!-- <t t-if="line.age_120_days == 0">-->
<!-- <span t-field="line.age_120_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>-->
<!-- </t>-->
<t t-if="line.age_120_days != 0">
<span>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.age_120_days == 0">
<span
t-field="line.age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
<!--## older-->
<div class="act_as_cell amount">
<!-- <t t-if="line.older != 0">-->
<!-- <span>-->
<!-- <a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_multi"-->
<!-- style="color: black;">-->
<t
t-raw="line['older']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
<!-- </a>-->
<!-- </span>-->
<!-- </t>-->
<!-- <t t-if="line.older == 0">-->
<!-- <span t-field="line.older" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>-->
<!-- </t>-->
<t t-if="line.older != 0">
<span>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.older == 0">
<span
t-field="line.older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
</div>
</t>
@ -455,49 +511,49 @@
<!--## amount_residual-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span
t-esc="partner_cumul_line['residual']"
t-field="partner_cumul_line.amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## current-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span
t-esc="partner_cumul_line['current']"
t-field="partner_cumul_line.current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_30_days-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span
t-esc="partner_cumul_line['30_days']"
t-field="partner_cumul_line.age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_60_days-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span
t-esc="partner_cumul_line['60_days']"
t-field="partner_cumul_line.age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_90_days-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span
t-esc="partner_cumul_line['90_days']"
t-field="partner_cumul_line.age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_120_days-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span
t-esc="partner_cumul_line['120_days']"
t-field="partner_cumul_line.age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## older-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span
t-esc="partner_cumul_line['older']"
t-field="partner_cumul_line.older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
@ -514,49 +570,49 @@
<!--## amount_residual-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span
t-esc="account['residual']"
t-field="account.cumul_amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## current-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span
t-esc="account['current']"
t-field="account.cumul_current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_30_days-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span
t-esc="account['30_days']"
t-field="account.cumul_age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_60_days-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span
t-esc="account['60_days']"
t-field="account.cumul_age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_90_days-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span
t-esc="account['90_days']"
t-field="account.cumul_age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_120_days-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span
t-esc="account['120_days']"
t-field="account.cumul_age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## older-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span
t-esc="account['older']"
t-field="account.cumul_older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
@ -569,49 +625,49 @@
<!--## amount_residual-->
<div class="act_as_cell amount" style="width: 6.00%">
<span
t-esc="account['residual']"
t-field="account.cumul_amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## current-->
<div class="act_as_cell amount" style="width: 6.00%">
<span
t-esc="account['current']"
t-field="account.cumul_current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_30_days-->
<div class="act_as_cell amount" style="width: 6.00%">
<span
t-esc="account['30_days']"
t-field="account.cumul_age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_60_days-->
<div class="act_as_cell amount" style="width: 6.00%">
<span
t-esc="account['60_days']"
t-field="account.cumul_age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_90_days-->
<div class="act_as_cell amount" style="width: 6.00%">
<span
t-esc="account['90_days']"
t-field="account.cumul_age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_120_days-->
<div class="act_as_cell amount" style="width: 6.00%">
<span
t-esc="account['120_days']"
t-field="account.cumul_age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## older-->
<div class="act_as_cell amount" style="width: 6.00%">
<span
t-esc="account['older']"
t-field="account.cumul_older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
@ -626,32 +682,33 @@
<div class="act_as_cell amount" style="width: 9.64%;" />
<!--## current-->
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-esc="account['percent_current']"
t-field="account.percent_current"
/>%
</div>
<!--## age_30_days-->
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-esc="account['percent_30_days']"
t-field="account.percent_age_30_days"
/>%
</div>
<!--## age_60_days-->
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-esc="account['percent_60_days']"
t-field="account.percent_age_60_days"
/>%
</div>
<!--## age_90_days-->
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-esc="account['percent_90_days']"
t-field="account.percent_age_90_days"
/>%
</div>
<!--## age_120_days-->
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-esc="account['percent_120_days']"
/>%
t-field="account.percent_age_120_days"
/>
%
</div>
<!--## older-->
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-esc="account['percent_older']"
t-field="account.percent_older"
/>%
</div>
</t>
@ -665,32 +722,32 @@
<div class="act_as_cell amount" style="width: 6.00%" />
<!--## current-->
<div class="act_as_cell amount" style="width: 6.00%"><span
t-esc="account['percent_current']"
t-field="account.percent_current"
/>%
</div>
<!--## age_30_days-->
<div class="act_as_cell amount" style="width: 6.00%"><span
t-esc="account['percent_30_days']"
t-field="account.percent_age_30_days"
/>%
</div>
<!--## age_60_days-->
<div class="act_as_cell amount" style="width: 6.00%"><span
t-esc="account['percent_60_days']"
t-field="account.percent_age_60_days"
/>%
</div>
<!--## age_90_days-->
<div class="act_as_cell amount" style="width: 6.00%"><span
t-esc="account['percent_90_days']"
t-field="account.percent_age_90_days"
/>%
</div>
<!--## age_120_days-->
<div class="act_as_cell amount" style="width: 6.00%"><span
t-esc="account['percent_120_days']"
t-field="account.percent_age_120_days"
/>%
</div>
<!--## older-->
<div class="act_as_cell amount" style="width: 6.00%"><span
t-esc="account['percent_older']"
t-field="account.percent_older"
/>%
</div>
</t>

481
account_financial_report/report/templates/general_ledger.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="general_ledger">
<template id="report_general_ledger_qweb">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="account_financial_report.internal_layout">
@ -11,12 +11,14 @@
</template>
<template id="report_general_ledger_base">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="foreign_currency" t-value="foreign_currency" />
<t t-set="filter_partner_ids" t-value="filter_partner_ids" />
<t t-set="show_analytic_tags" t-value="o.show_analytic_tags" />
<t t-set="show_cost_center" t-value="o.show_cost_center" />
<t t-set="foreign_currency" t-value="o.foreign_currency" />
<!-- Defines global variables used by internal layout -->
<t t-set="title">General Ledger - <t t-raw="company_name" /> - <t
t-raw="currency_name"
<t t-set="title">General Ledger - <t t-raw="o.company_id.name" /> - <t
t-raw="o.company_id.currency_id.name"
/></t>
<t t-set="company_name" t-value="o.company_id.name" />
<div class="page">
<div class="row">
<h4
@ -27,19 +29,16 @@
</div>
<!-- Display filters -->
<t t-call="account_financial_report.report_general_ledger_filters" />
<t t-foreach="general_ledger" t-as="account">
<t t-foreach="o.account_ids" t-as="account">
<div class="page_break">
<!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="act_as_caption account_title" style="width: 100%">
<span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'code')"
/> -
<span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'name')"
<span t-field="account.code" /> - <span
t-field="account.name"
/>
</div>
<t t-if="not account['partners']">
<t t-if="not account.partner_ids">
<!-- Display account move lines without partner regroup -->
<t t-set="type" t-value='"account_type"' />
<t
@ -47,24 +46,15 @@
>
<t t-set="account_or_partner_object" t-value="account" />
</t>
<!-- Display account footer -->
<t
t-call="account_financial_report.report_general_ledger_ending_cumul"
>
<t t-set="account_or_partner_object" t-value="account" />
<t t-set="type" t-value='"account_type"' />
</t>
</t>
<t t-if="account['partners']">
<t t-if="account.partner_ids">
<!-- Display account partners -->
<t t-foreach="account['list_partner']" t-as="partner">
<t t-foreach="account.partner_ids" t-as="partner">
<t t-set="type" t-value='"partner_type"' />
<div class="page_break">
<!-- Display partner header -->
<div class="act_as_caption account_title">
<span
t-esc="o._get_atr_from_dict(partner['id'], partners_data, 'name')"
/>
<span t-field="partner.name" />
</div>
<!-- Display partner move lines -->
<t
@ -87,18 +77,14 @@
</t>
</div>
</t>
<!-- Display account footer -->
<t t-if="not filter_partner_ids">
<t
t-call="account_financial_report.report_general_ledger_ending_cumul"
>
<t
t-set="account_or_partner_object"
t-value="account"
/>
<t t-set="type" t-value='"account_type"' />
</t>
</t>
</t>
<!-- Display account footer -->
<t
t-if="not o.filter_partner_ids"
t-call="account_financial_report.report_general_ledger_ending_cumul"
>
<t t-set="account_or_partner_object" t-value="account" />
<t t-set="type" t-value='"account_type"' />
</t>
</div>
</t>
@ -115,23 +101,25 @@
</div>
<div class="act_as_row">
<div class="act_as_cell">
From: <span t-esc="date_from" /> To: <span t-esc="date_to" />
From: <span t-field="o.date_from" /> To: <span
t-field="o.date_to"
/>
</div>
<div class="act_as_cell">
<t t-if="only_posted_moves">All posted entries</t>
<t t-if="not only_posted_moves">All entries</t>
<t t-if="o.only_posted_moves">All posted entries</t>
<t t-if="not o.only_posted_moves">All entries</t>
</div>
<div class="act_as_cell">
<t t-if="hide_account_at_0">Hide</t>
<t t-if="not hide_account_at_0">Show</t>
<t t-if="o.hide_account_at_0">Hide</t>
<t t-if="not o.hide_account_at_0">Show</t>
</div>
<div class="act_as_cell">
<t t-if="centralize">Yes</t>
<t t-if="not centralize">No</t>
<t t-if="o.centralize">Yes</t>
<t t-if="not o.centralize">No</t>
</div>
<div class="act_as_cell">
<t t-if="show_analytic_tags">Yes</t>
<t t-if="not show_analytic_tags">No</t>
<t t-if="o.show_analytic_tags">Yes</t>
<t t-if="not o.show_analytic_tags">No</t>
</div>
</div>
</div>
@ -156,14 +144,12 @@
<div class="act_as_cell" style="width: 12.01%;">Partner
</div>
<!--## ref - label-->
<div class="act_as_cell" style="width: 16.9%;">Ref -
<div class="act_as_cell" style="width: 22.9%;">Ref -
Label</div>
<t t-if="show_cost_center">
<!--## cost_center-->
<div
class="act_as_cell"
style="width: 8.03%;"
>Analytic Account</div>
<div class="act_as_cell" style="width: 8.03%;">Cost
center</div>
</t>
<t t-if="show_analytic_tags">
<!--## analytic tags-->
@ -172,13 +158,13 @@
<!--## matching_number-->
<div class="act_as_cell" style="width: 2.41%;">Rec.</div>
<!--## debit-->
<div class="act_as_cell amount" style="width: 8.02%;">Debit</div>
<div class="act_as_cell amount" style="width: 6.02%;">Debit</div>
<!--## credit-->
<div class="act_as_cell amount" style="width: 8.02%;">Credit</div>
<div class="act_as_cell amount" style="width: 6.02%;">Credit</div>
<!--## balance cumulated-->
<div
class="act_as_cell amount"
style="width: 8.02%;"
style="width: 6.02%;"
>Cumul. Bal.</div>
<t t-if="foreign_currency">
<!--## currency_name-->
@ -222,8 +208,8 @@
<t t-if="type == 'account_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('date', '&lt;', date_from),
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"
/>
<span>
@ -234,7 +220,7 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['init_bal']['debit']"
t-raw="account_or_partner_object.initial_debit"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
@ -243,9 +229,9 @@
<t t-if="type == 'partner_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']),
('date', '&lt;', date_from),
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"
/>
<span>
@ -256,7 +242,7 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['init_bal']['debit']"
t-raw="account_or_partner_object.initial_debit"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
@ -268,8 +254,8 @@
<t t-if="type == 'account_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('date', '&lt;', date_from),
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"
/>
<span>
@ -280,7 +266,7 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['init_bal']['credit']"
t-raw="account_or_partner_object.initial_credit"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
@ -289,9 +275,9 @@
<t t-if="type == 'partner_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']),
('date', '&lt;', date_from),
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"
/>
<span>
@ -302,7 +288,7 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['init_bal']['credit']"
t-raw="account_or_partner_object.initial_credit"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
@ -314,8 +300,8 @@
<t t-if="type == 'account_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('date', '&lt;', date_from)]"
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"
/>
<span>
<a
@ -325,7 +311,7 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['init_bal']['balance']"
t-raw="account_or_partner_object.initial_balance"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
@ -334,9 +320,9 @@
<t t-if="type == 'partner_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']),
('date', '&lt;', date_from)]"
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"
/>
<span>
<a
@ -346,7 +332,7 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['init_bal']['balance']"
t-raw="account_or_partner_object.initial_balance"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
@ -354,19 +340,17 @@
</t>
</div>
<t t-if="foreign_currency">
<t
t-if="o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<t t-if="account.account_id.currency_id.id">
<div class="act_as_cell amount" style="width: 2.08%;">
<span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'currency_name')"
t-field="account.account_id.currency_id.display_name"
/>
</div>
<div class="act_as_cell amount" style="width: 5.19%;">
<t t-if="type == 'account_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from)]"
/>
<span>
@ -377,8 +361,8 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
t-raw="account_or_partner_object.initial_balance_foreign_currency"
t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"
/>
</a>
</span>
@ -386,8 +370,8 @@
<t t-if="type == 'partner_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']),
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from)]"
/>
<span>
@ -398,87 +382,64 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
t-raw="account_or_partner_object.initial_balance_foreign_currency"
t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"
/>
</a>
</span>
</t>
</div>
</t>
<t
t-if="not o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<t t-if="not account.account_id.currency_id.id">
<div class="act_as_cell" style="width: 2.08%;" />
<div class="act_as_cell" style="width: 5.19%;" />
</t>
</t>
</div>
<!-- Display each lines -->
<t t-foreach="account_or_partner_object['move_lines']" t-as="line">
<t t-foreach="account_or_partner_object.move_line_ids" t-as="line">
<!-- # lines or centralized lines -->
<div class="act_as_row lines">
<!--## date-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.move.line'" />
<span>
<t t-if="line['id']">
<a
t-att-data-active-id="line['id']"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<!--## We don't use t-field because it throws an error on click -->
<t
t-esc="line['date']"
t-options="{'widget': 'date'}"
/>
</a>
</t>
<t t-if="not line['id']">
<a
class="o_account_financial_reports_web_action"
style="color: black;"
>
<!--## We don't use t-field because it throws an error on click -->
<t
t-esc="line['date']"
t-options="{'widget': 'date'}"
/>
</a>
</t>
<a
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<!--## We don't use t-field because it throws an error on click -->
<t t-esc="line.date" t-options="{'widget': 'date'}" />
</a>
</span>
</div>
<!--## move-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.move'" />
<t t-if="line['entry_id']">
<span>
<a
t-att-data-active-id="line['entry_id']"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line['entry']" />
</a>
</span>
</t>
<span>
<a
t-att-data-active-id="line.move_line_id.move_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.entry" />
</a>
</span>
</div>
<!--## journal-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.journal'" />
<span>
<a
t-att-data-active-id="line['journal_id']"
t-att-data-active-id="line.move_line_id.move_id.journal_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t
t-raw="o._get_atr_from_dict(line['journal_id'], journals_data, 'code')"
/>
<t t-raw="line.journal" />
</a>
</span>
</div>
@ -487,79 +448,59 @@
<t t-set="res_model" t-value="'account.account'" />
<span>
<a
t-att-data-active-id="account['id']"
t-att-data-active-id="line.move_line_id.account_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t
t-raw="o._get_atr_from_dict(account['id'], accounts_data, 'code')"
/>
<t t-raw="line.account" />
</a>
</span>
</div>
<!--## taxes-->
<div class="act_as_cell left">
<t t-if="taxes_data and line['tax_ids']">
<t t-foreach="line['tax_ids']" t-as="tax_id">
<span
t-esc="o._get_atr_from_dict(tax_id, taxes_data, 'tax_name')"
/>
</t>
</t>
<span t-field="line.taxes_description" />
</div>
<!--## partner-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'res.partner'" />
<span t-if="line['partner_id']">
<span t-if="line.partner">
<a
t-att-data-active-id="line['partner_id']"
t-att-data-active-id="line.move_line_id.partner_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line['partner_name']" />
<t t-raw="line.partner" />
</a>
</span>
</div>
<!--## ref - label-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.move.line'" />
<t t-if="line['id']">
<span>
<a
t-att-data-active-id="line['id']"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line['ref_label']" />
</a>
</span>
</t>
<t t-if="not line['id']">
<span>
<a
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line['ref_label']" />
</a>
</span>
</t>
<span>
<a
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.label" />
</a>
</span>
</div>
<!--## cost_center-->
<t t-if="show_cost_center">
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.analytic.account'" />
<span t-if="line['analytic_account_id']">
<span t-if="line.cost_center">
<a
t-att-data-active-id="line['analytic_account_id']"
t-att-data-active-id="line.move_line_id.analytic_account_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line['analytic_account']" />
<t t-raw="line.cost_center" />
</a>
</span>
</div>
@ -567,147 +508,99 @@
<t t-if="show_analytic_tags">
<!--## analytic tags-->
<div class="act_as_cell left">
<t t-if="line['tag_ids']">
<t t-foreach="line['tag_ids']" t-as="tag_id">
<span
t-esc="o._get_atr_from_dict(tag_id, tags_data, 'name')"
/>
</t>
</t>
<span t-field="line.tags" />
</div>
</t>
<!--## matching_number-->
<div class="act_as_cell">
<t t-set="res_model" t-value="'account.full.reconcile'" />
<span t-if="line['rec_id']">
<span t-if="line.matching_number">
<a
t-att-data-active-id="line['rec_id']"
t-att-data-active-id="line.move_line_id.full_reconcile_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line['rec_name']" />
<t t-raw="line.matching_number" />
</a>
</span>
</div>
<!--## debit-->
<div class="act_as_cell amount">
<t t-set="res_model" t-value="'account.move.line'" />
<t t-if="line['id']">
<span>
<a
t-att-data-active-id="line['id']"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action_monetary"
style="color: black;"
>
<t
t-raw="line['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="not line['id']">
<span>
<a
class="o_account_financial_reports_web_action_monetary"
style="color: black;"
>
<t
t-raw="line['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<span>
<a
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action_monetary"
style="color: black;"
>
<t
t-raw="line.debit"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
<!--## credit-->
<div class="act_as_cell amount">
<t t-set="res_model" t-value="'account.move.line'" />
<t t-if="line['id']">
<span>
<a
t-att-data-active-id="line['id']"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action_monetary"
style="color: black;"
>
<t
t-raw="line['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="not line['id']">
<span>
<a
class="o_account_financial_reports_web_action_monetary"
style="color: black;"
>
<t
t-raw="line['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<span>
<a
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action_monetary"
style="color: black;"
>
<t
t-raw="line.credit"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
<!--## balance cumulated-->
<div class="act_as_cell amount">
<t t-set="res_model" t-value="'account.move.line'" />
<t t-if="line['id']">
<span>
<a
t-att-data-active-id="line['id']"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action_monetary"
style="color: black;"
>
<t
t-raw="line['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="not line['id']">
<span>
<a
class="o_account_financial_reports_web_action_monetary"
style="color: black;"
>
<t
t-raw="line['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<span>
<a
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action_monetary"
style="color: black;"
>
<t
t-raw="line.cumul_balance"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
<t t-if="foreign_currency">
<t t-if="line['currency_id']">
<t t-if="line.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell amount" style="width: 2.08%;">
<span t-esc="line['currency_id'][1]" />
<span t-field="line.currency_id.display_name" />
</div>
<!--## amount_currency-->
<div class="act_as_cell amount" style="width: 5.19%;">
<t t-set="res_model" t-value="'account.move.line'" />
<span>
<a
t-att-data-active-id="line['id']"
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line['bal_curr']" />
<t
t-raw="line.amount_currency"
t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"
/>
</a>
</span>
</div>
</t>
<t t-if="not line['currency_id']">
<t t-if="not line.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell amount" style="width: 2.08%;" />
<!--## amount_currency-->
@ -725,20 +618,18 @@
<!--## date-->
<t t-if='type == "account_type"'>
<div class="act_as_cell first_column" style="width: 41.32%;"><span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'code')"
/> - <span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'name')"
/></div>
t-field="account_or_partner_object.code"
/> - <span t-field="account_or_partner_object.name" /></div>
<div
class="act_as_cell right"
style="width: 16.9%;"
style="width: 22.9%;"
>Ending balance</div>
</t>
<t t-if='type == "partner_type"'>
<div class="act_as_cell first_column" style="width: 41.32%;" />
<div
class="act_as_cell right"
style="width: 16.9%;"
style="width: 22.9%;"
>Partner ending balance</div>
</t>
<t t-if="show_cost_center">
@ -752,42 +643,40 @@
<!--## matching_number-->
<div class="act_as_cell" style="width: 2.41%;" />
<!--## debit-->
<div class="act_as_cell amount" style="width: 8.02%;">
<div class="act_as_cell amount" style="width: 6.02%;">
<span
t-esc="account_or_partner_object['fin_bal']['debit']"
t-field="account_or_partner_object.final_debit"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## credit-->
<div class="act_as_cell amount" style="width: 8.02%;">
<div class="act_as_cell amount" style="width: 6.02%;">
<span
t-esc="account_or_partner_object['fin_bal']['credit']"
t-field="account_or_partner_object.final_credit"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## balance cumulated-->
<div class="act_as_cell amount" style="width: 8.02%;">
<div class="act_as_cell amount" style="width: 6.02%;">
<span
t-esc="account_or_partner_object['fin_bal']['balance']"
t-field="account_or_partner_object.final_balance"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## currency_name + amount_currency-->
<t t-if="foreign_currency">
<t
t-if="o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<t t-if="account.account_id.currency_id.id">
<div class="act_as_cell amount" style="width: 2.08%;">
<span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'currency_name')"
t-field="account.account_id.currency_id.display_name"
/>
</div>
<div class="act_as_cell amount" style="width: 5.19%;">
<t t-if="type == 'account_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('date', '&lt;', date_from)]"
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from)]"
/>
<span>
<a
@ -797,8 +686,8 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
t-raw="account_or_partner_object.final_balance_foreign_currency"
t-options="{'widget': 'monetary', 'display_currency': account_or_partner_object.account_id.currency_id}"
/>
</a>
</span>
@ -806,9 +695,9 @@
<t t-if="type == 'partner_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']),
('date', '&lt;', date_from)]"
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from)]"
/>
<span>
<a
@ -818,17 +707,15 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
t-raw="account_or_partner_object.final_balance_foreign_currency"
t-options="{'widget': 'monetary', 'display_currency': account_or_partner_object.report_account_id.currency_id}"
/>
</a>
</span>
</t>
</div>
</t>
<t
t-if="not o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<t t-if="not account.account_id.currency_id ">
<div class="act_as_cell amount" style="width: 2.08%;" />
<div class="act_as_cell amount" style="width: 5.19%;" />
</t>

200
account_financial_report/report/templates/journal_ledger.xml

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2018 ForgeFlow S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<template id="journal_ledger">
<template id="report_journal_ledger_qweb">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="account_financial_report.internal_layout">
@ -12,12 +10,12 @@
</t>
</template>
<template id="report_journal_ledger_base">
<t t-set="display_currency" t-value="foreign_currency" />
<t t-set="display_account_name" t-value="with_account_name" />
<t t-set="title">Journal Ledger - <t t-raw="company_name" /> - <t
t-raw="currency_name"
<t t-set="display_currency" t-value="o.foreign_currency" />
<t t-set="display_account_name" t-value="o.with_account_name" />
<t t-set="title">Journal Ledger - <t t-raw="o.company_id.name" /> - <t
t-raw="o.company_id.currency_id.name"
/></t>
<t t-set="company_name" t-value="Company_Name" />
<t t-set="company_name" t-value="o.company_id.name" />
<div class="page">
<div class="row">
<h4
@ -26,15 +24,15 @@
style="text-align: center;"
/>
</div>
<t t-if="group_option == 'none'">
<t t-if="o.group_option == 'none'">
<div class="page_break">
<t t-call="account_financial_report.report_journal_all" />
<br />
<t t-call="account_financial_report.report_journal_all_taxes" />
</div>
</t>
<t t-if="group_option == 'journal'">
<t t-foreach="Journal_Ledgers" t-as="journal">
<t t-if="o.group_option == 'journal'">
<t t-foreach="o.report_journal_ledger_ids" t-as="journal">
<div class="page_break">
<t
t-call="account_financial_report.report_journal_ledger_journal"
@ -55,7 +53,7 @@
<t
t-call="account_financial_report.report_journal_ledger_journal_table_header"
/>
<t t-foreach="Moves" t-as="move">
<t t-foreach="o.report_move_ids" t-as="move">
<t t-call="account_financial_report.report_journal_move" />
</t>
</div>
@ -63,12 +61,11 @@
<template id="account_financial_report.report_journal_ledger_journal">
<div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="act_as_caption account_title" style="width: 100%;">
<span t-esc="journal['name']" /> (<span
t-esc="journal['currency_name']"
/>) - <span t-esc="date_from" t-options="{'widget': 'date'}" /> to <span
t-esc="date_to"
t-options="{'widget': 'date'}"
/> - <span t-esc="move_target" /> Moves
<span t-field="journal.name" /> (<span
t-field="journal.currency_id.display_name"
/>) - <span t-field="o.date_from" /> to <span t-field="o.date_to" /> - <span
t-field="o.move_target"
/> Moves
</div>
<div class="act_as_table data_table" style="width: 100%;">
<t
@ -77,7 +74,7 @@
<t
t-call="account_financial_report.report_journal_ledger_journal_first_line"
/>
<t t-foreach="journal['report_moves']" t-as="move">
<t t-foreach="journal.report_move_ids" t-as="move">
<t t-call="account_financial_report.report_journal_move" />
</t>
</div>
@ -158,18 +155,12 @@
<div class="act_as_cell" name="taxes" />
<div class="act_as_cell amount" name="debit">
<b>
<span
t-esc="journal['debit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="journal.debit" />
</b>
</div>
<div class="act_as_cell amount" name="credit">
<b>
<span
t-esc="journal['credit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="journal.credit" />
</b>
</div>
<t t-if="display_currency">
@ -185,12 +176,9 @@
<t t-set="display_move_info" t-value="True" />
<t t-set="last_partner" t-eval="None" />
<t t-set="display_partner" t-eval="True" />
<t t-foreach="move['report_move_lines']" t-as="move_line">
<t t-foreach="move.report_move_line_ids" t-as="move_line">
<div class="act_as_row lines">
<t
t-set="current_partner"
t-value="o._get_partner_name(move_line['partner_id'], partner_ids_data)"
/>
<t t-set="current_partner" t-value="move_line.partner_id" />
<t t-set="display_partner" t-value="current_partner != last_partner" />
<t t-call="account_financial_report.report_journal_move_line" />
<t t-set="last_partner" t-value="current_partner" />
@ -200,91 +188,45 @@
</template>
<template id="account_financial_report.report_journal_move_line">
<div class="act_as_cell left" name="entry">
<t t-set="res_model" t-value="'account.move'" />
<span t-if="display_move_info">
<a
t-att-data-active-id="move_line['move_id']"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t
t-esc="o._get_atr_from_dict(move_line['move_id'], move_ids_data, 'entry')"
/>
</a>
</span>
<span t-if="display_move_info" t-field="move_line.entry" />
</div>
<div class="act_as_cell left" name="date">
<span
t-if="display_move_info"
t-esc="move_line['date']"
t-options="{'widget': 'date'}"
/>
<span t-if="display_move_info" t-field="move_line.date" />
</div>
<div class="act_as_cell left" name="account">
<span
t-esc="o._get_atr_from_dict(move_line['account_id'], account_ids_data, 'code')"
/>
<span t-field="move_line.account_code" />
<span t-if="display_account_name">
- <span
t-esc="o._get_atr_from_dict(move_line['account_id'], account_ids_data, 'name')"
/>
- <span t-field="move_line.account" />
</span>
</div>
<div class="act_as_cell left" name="partner">
<span
t-if="display_partner"
t-esc="o._get_partner_name(move_line['partner_id'], partner_ids_data)"
/>
<span t-if="display_partner" t-field="move_line.partner" />
</div>
<div class="act_as_cell left" name="label">
<span t-if="move_line['label']" t-esc="move_line['label']" />
<span t-if="not move_line['label']">/</span>
<span t-field="move_line.label" />
</div>
<div class="act_as_cell left" name="taxes">
<t
t-set="tax_line_dat"
t-value="o._get_data_from_dict(move_line['tax_line_id'], tax_line_data)"
/>
<t
t-set="move_line_ids_taxes_dat"
t-value="o._get_data_from_dict(move_line['move_line_id'], move_line_ids_taxes_data)"
/>
<span
t-esc="o._get_ml_tax_description(move_line, tax_line_dat, move_line_ids_taxes_dat)"
/>
<span t-field="move_line.taxes_description" />
</div>
<div class="act_as_cell amount" name="debit">
<t t-if="move_line['debit']">
<span
t-esc="move_line['debit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<t t-if="move_line.debit">
<span t-field="move_line.debit" />
</t>
</div>
<div class="act_as_cell amount" name="credit">
<t t-if="move_line['credit']">
<span
t-esc="move_line['credit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<t t-if="move_line.credit">
<span t-field="move_line.credit" />
</t>
</div>
<t t-if="display_currency">
<div class="act_as_cell" name="currency_name">
<t t-if="move_line['currency_id']">
<span t-esc="currency_ids_data.get(move_line['currency_id'], '')" />
<t t-if="move_line.currency_name">
<span t-field="move_line.currency_name" />
</t>
</div>
<div class="act_as_cell amount" name="amount_currency">
<t
t-if="move_line['amount_currency']"
t-options="{'widget': 'float', 'precision': 2}"
>
<span
t-esc="move_line['amount_currency']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<t t-if="move_line.amount_currency">
<span t-field="move_line.amount_currency" />
</t>
</div>
</t>
@ -340,49 +282,31 @@
Balance
</div>
</div>
<t t-foreach="journal['tax_lines']" t-as="tax_line">
<t t-foreach="journal.report_tax_line_ids" t-as="tax_line">
<div class="act_as_row lines">
<div class="act_as_cell left" name="tax_name">
<span t-esc="tax_line['tax_name']" />
<span t-field="tax_line.tax_name" />
</div>
<div class="act_as_cell left" name="tax_code">
<span t-esc="tax_line['tax_code']" />
<span t-field="tax_line.tax_code" />
</div>
<div class="act_as_cell amount" name="base_debit">
<span
t-esc="tax_line['base_debit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.base_debit" />
</div>
<div class="act_as_cell amount" name="base_credit">
<span
t-esc="tax_line['base_credit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.base_credit" />
</div>
<div class="act_as_cell amount" name="base_balance">
<span
t-esc="tax_line['base_balance']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.base_balance" />
</div>
<div class="act_as_cell amount" name="tax_debit">
<span
t-esc="tax_line['tax_debit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.tax_debit" />
</div>
<div class="act_as_cell amount" name="tax_credit">
<span
t-esc="tax_line['tax_credit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.tax_credit" />
</div>
<div class="act_as_cell amount" name="tax_balance">
<span
t-esc="tax_line['tax_balance']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.tax_balance" />
</div>
</div>
</t>
@ -440,49 +364,31 @@
</div>
</div>
<t t-foreach="ReportTaxLines" t-as="tax_line">
<t t-foreach="o.report_tax_line_ids" t-as="tax_line">
<div class="act_as_row lines">
<div class="act_as_cell left" name="tax_name">
<span t-esc="tax_line['tax_name']" />
<span t-field="tax_line.tax_name" />
</div>
<div class="act_as_cell left" name="tax_code">
<span t-esc="tax_line['tax_code']" />
<span t-field="tax_line.tax_code" />
</div>
<div class="act_as_cell amount" name="base_debit">
<span
t-esc="tax_line['base_debit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.base_debit" />
</div>
<div class="act_as_cell amount" name="base_credit">
<span
t-esc="tax_line['base_credit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.base_credit" />
</div>
<div class="act_as_cell amount" name="base_balance">
<span
t-esc="tax_line['base_balance']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.base_balance" />
</div>
<div class="act_as_cell amount" name="tax_debit">
<span
t-esc="tax_line['tax_debit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.tax_debit" />
</div>
<div class="act_as_cell amount" name="tax_credit">
<span
t-esc="tax_line['tax_credit']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.tax_credit" />
</div>
<div class="act_as_cell amount" name="tax_balance">
<span
t-esc="tax_line['tax_balance']"
t-options="{'widget': 'float', 'precision': 2}"
/>
<span t-field="tax_line.tax_balance" />
</div>
</div>
</t>

412
account_financial_report/report/templates/open_items.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="open_items">
<template id="account_financial_report.report_open_items_qweb">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="account_financial_report.internal_layout">
@ -11,12 +11,12 @@
</template>
<template id="account_financial_report.report_open_items_base">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="foreign_currency" t-value="foreign_currency" />
<t t-set="foreign_currency" t-value="o.foreign_currency" />
<!-- Defines global variables used by internal layout -->
<t t-set="title">Open Items - <t t-raw="company_name" /> - <t
t-raw="currency_name"
<t t-set="title">Open Items - <t t-raw="o.company_id.name" /> - <t
t-raw="o.company_id.currency_id.name"
/></t>
<t t-set="company_name" t-value="Company_Name" />
<t t-set="company_name" t-value="o.company_id.name" />
<div class="page">
<div class="row">
<h4
@ -27,77 +27,44 @@
</div>
<!-- Display filters -->
<t t-call="account_financial_report.report_open_items_filters" />
<t t-foreach="Open_Items.keys()" t-as="account_id">
<!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="account_title" style="width: 100%;">
<span t-esc="accounts_data[account_id]['code']" />
<t t-foreach="o.account_ids" t-as="account">
<div class="page_break">
<!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="account_title" style="width: 100%;">
<span t-field="account.code" />
-
<span t-esc="accounts_data[account_id]['name']" />
<span t-field="account.name" />
</div>
<t t-if="not show_partner_details">
<div class="act_as_table data_table" style="width: 100%;">
<t
t-call="account_financial_report.report_open_items_lines_header"
/>
<!-- Display account move lines -->
<t t-foreach="Open_Items[account_id]" t-as="line">
<!-- Display account partners -->
<t t-foreach="account.partner_ids" t-as="partner">
<div class="page_break">
<!-- Display partner header -->
<div class="account_title">
<span t-field="partner.name" />
</div>
<!-- Display partner move lines -->
<t
t-call="account_financial_report.report_open_items_lines"
/>
</t>
</div>
</t>
<t t-if="show_partner_details">
<div class="page_break">
<!-- Display account partners -->
<t t-foreach="Open_Items[account_id]" t-as="partner_id">
<div class="act_as_caption account_title">
<span t-esc="partners_data[partner_id]['name']" />
</div>
<div class="act_as_table data_table" style="width: 100%;">
<!-- Display partner header -->
<t
t-call="account_financial_report.report_open_items_lines_header"
/>
<!-- Display partner move lines -->
<t
t-foreach="Open_Items[account_id][partner_id]"
t-as="line"
>
<t
t-call="account_financial_report.report_open_items_lines"
/>
</t>
</div>
<!-- Display partner footer -->
<t
t-call="account_financial_report.report_open_items_ending_cumul"
>
<t
t-set="account_or_partner_id"
t-value="partners_data[partner_id]"
/>
<t
t-set="currency_id"
t-value="accounts_data[account_id]['currency_name']"
t-set="account_or_partner_object"
t-value="partner"
/>
<t t-set="type" t-value='"partner_type"' />
</t>
</t>
</div>
</t>
<!-- Display account footer -->
<t t-call="account_financial_report.report_open_items_ending_cumul">
<t
t-set="account_or_partner_id"
t-value="accounts_data[account_id]"
/>
<t
t-set="currency_id"
t-value="accounts_data[account_id]['currency_name']"
/>
<t t-set="type" t-value='"account_type"' />
</t>
</div>
</t>
<!-- Display account footer -->
<t t-call="account_financial_report.report_open_items_ending_cumul">
<t t-set="account_or_partner_object" t-value="account" />
<t t-set="type" t-value='"account_type"' />
</t>
</div>
</t>
</div>
</template>
@ -110,143 +77,160 @@
</div>
<div class="act_as_row">
<div class="act_as_cell">
<span t-esc="date_at" />
<span t-field="o.date_at" />
</div>
<div class="act_as_cell">
<t t-if="target_move == 'posted'">All posted entries</t>
<t t-if="target_move == 'all'">All entries</t>
<t t-if="o.only_posted_moves">All posted entries</t>
<t t-if="not o.only_posted_moves">All entries</t>
</div>
<div class="act_as_cell">
<t t-if="hide_account_at_0">Hide</t>
<t t-if="not hide_account_at_0">Show</t>
<t t-if="o.hide_account_at_0">Hide</t>
<t t-if="not o.hide_account_at_0">Show</t>
</div>
</div>
</div>
</template>
<template id="account_financial_report.report_open_items_lines_header">
<!-- Display table headers for lines -->
<div class="act_as_thead">
<div class="act_as_row labels">
<!--## date-->
<div class="act_as_cell first_column" style="width: 5.51%;">
Date</div>
<!--## move-->
<div class="act_as_cell" style="width: 9.76%;">Entry</div>
<!--## journal-->
<div class="act_as_cell" style="width: 4.78%;">Journal</div>
<!--## account code-->
<div class="act_as_cell" style="width: 5.38%;">Account</div>
<!--## partner-->
<div class="act_as_cell" style="width: 15.07%;">Partner
</div>
<!--## ref - label-->
<div class="act_as_cell" style="width: 24.5%;">Ref -
Label</div>
<!--## date_due-->
<div class="act_as_cell" style="width: 6.47%;">Due
date</div>
<!--## amount_total_due-->
<div class="act_as_cell" style="width: 6.57%;">Original
</div>
<!--## amount_residual-->
<div class="act_as_cell" style="width: 6.57%;">Residual</div>
<t t-if="foreign_currency">
<!--## currency_name-->
<div class="act_as_cell" style="width: 2.25%;">Cur.</div>
<!--## amount_total_due_currency-->
<div
class="act_as_cell amount"
style="width: 6.57%;"
>Cur. Original</div>
<!--## amount_residual_currency-->
<div
class="act_as_cell amount"
style="width: 6.57%;"
>Cur. Residual</div>
</t>
</div>
</div>
</template>
<template id="account_financial_report.report_open_items_lines">
<!-- # lines or centralized lines -->
<div class="act_as_row lines">
<!--## date-->
<div class="act_as_cell left">
<span t-raw="line['date'].strftime('%d/%m/%Y')" />
</div>
<!--## move-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.move'" />
<span>
<a
t-att-data-active-id="line['move_id']"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-esc="line['move_name']" />
</a>
</span>
</div>
<!--## journal-->
<div class="act_as_cell left">
<span t-esc="journals_data[line['journal_id']]['code']" />
</div>
<!--## account code-->
<div class="act_as_cell left">
<span t-esc="accounts_data[account_id]['code']" />
</div>
<!--## partner-->
<div class="act_as_cell left">
<!-- <span t-if="line.get('partner_id', False)" t-esc="line['partner_id']"/>-->
<span t-esc="line['partner_name']" />
</div>
<!--## ref - label-->
<div class="act_as_cell left">
<span t-esc="line['ref_label']" />
</div>
<!--## date_due-->
<div class="act_as_cell left">
<span t-esc="line['date_maturity']" />
</div>
<!--## amount_total_due-->
<div class="act_as_cell amount">
<span
t-if="line.get('original', False)"
t-esc="line['original']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## amount_residual-->
<div class="act_as_cell amount">
<span
t-esc="line['amount_residual']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
<div class="act_as_table data_table" style="width: 100%;">
<!-- Display table headers for lines -->
<div class="act_as_thead">
<div class="act_as_row labels">
<!--## date-->
<div class="act_as_cell first_column" style="width: 5.51%;">
Date</div>
<!--## move-->
<div class="act_as_cell" style="width: 9.76%;">Entry</div>
<!--## journal-->
<div class="act_as_cell" style="width: 4.78%;">Journal</div>
<!--## account code-->
<div class="act_as_cell" style="width: 5.38%;">Account</div>
<!--## partner-->
<div class="act_as_cell" style="width: 15.07%;">Partner
</div>
<!--## ref - label-->
<div class="act_as_cell" style="width: 24.5%;">Ref -
Label</div>
<!--## date_due-->
<div class="act_as_cell" style="width: 6.47%;">Due
date</div>
<!--## amount_total_due-->
<div class="act_as_cell" style="width: 6.57%;">Original
</div>
<!--## amount_residual-->
<div class="act_as_cell" style="width: 6.57%;">Residual</div>
<t t-if="foreign_currency">
<!--## currency_name-->
<div class="act_as_cell" style="width: 2.25%;">Cur.</div>
<!--## amount_total_due_currency-->
<div
class="act_as_cell amount"
style="width: 6.57%;"
>Cur. Original</div>
<!--## amount_residual_currency-->
<div
class="act_as_cell amount"
style="width: 6.57%;"
>Cur. Residual</div>
</t>
</div>
</div>
<t t-if="foreign_currency">
<t t-if="line['currency_id']">
<!--## currency_name-->
<div class="act_as_cell amount">
<span t-esc="line['currency_name']" />
<!-- Display each lines -->
<t t-foreach="partner.move_line_ids" t-as="line">
<!-- # lines or centralized lines -->
<div class="act_as_row lines">
<!--## date-->
<div class="act_as_cell left">
<span t-field="line.date" />
</div>
<!--## move-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.move'" />
<span>
<a
t-att-data-active-id="line.move_line_id.move_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.entry" />
</a>
</span>
</div>
<!--## journal-->
<div class="act_as_cell left">
<span t-field="line.journal" />
</div>
<!--## account code-->
<div class="act_as_cell left">
<span t-field="line.account" />
</div>
<!--## partner-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'res.partner'" />
<span t-if="line.partner">
<a
t-att-data-active-id="line.move_line_id.partner_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.partner" />
</a>
</span>
</div>
<!--## amount_total_due_currency-->
<!--## ref - label-->
<div class="act_as_cell left">
<span t-field="line.label" />
</div>
<!--## date_due-->
<div class="act_as_cell left">
<span t-field="line.date_due" />
</div>
<!--## amount_total_due-->
<div class="act_as_cell amount">
<span t-esc="line['amount_currency']" />
<span
t-field="line.amount_total_due"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## amount_residual_currency-->
<!--## amount_residual-->
<div class="act_as_cell amount">
<span t-esc="line['amount_residual_currency']" />
<span
t-field="line.amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
</t>
<t t-if="not line['currency_id']">
<!--## currency_name-->
<div class="act_as_cell" />
<!--## amount_total_due_currency-->
<div class="act_as_cell" />
<!--## amount_residual_currency-->
<div class="act_as_cell" />
</t>
<t t-if="foreign_currency">
<t t-if="line.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell amount">
<span t-field="line.currency_id.display_name" />
</div>
<!--## amount_total_due_currency-->
<div class="act_as_cell amount">
<span
t-field="line.amount_total_due_currency"
t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"
/>
</div>
<!--## amount_residual_currency-->
<div class="act_as_cell amount">
<span
t-field="line.amount_residual_currency"
t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"
/>
</div>
</t>
<t t-if="not line.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell" />
<!--## amount_total_due_currency-->
<div class="act_as_cell" />
<!--## amount_residual_currency-->
<div class="act_as_cell" />
</t>
</t>
</div>
</t>
</div>
</template>
@ -257,9 +241,9 @@
<!--## date-->
<t t-if='type == "account_type"'>
<div class="act_as_cell first_column" style="width: 36.34%;">
<span t-esc="accounts_data[account_id]['code']" />
<span t-field="account_or_partner_object.code" />
-
<span t-esc="accounts_data[account_id]['name']" />
<span t-field="account_or_partner_object.name" />
</div>
<div class="act_as_cell right" style="width: 28.66%;">Ending
balance</div>
@ -277,27 +261,43 @@
<div class="act_as_cell amount" style="width: 6.57%;" />
<!--## amount_currency-->
<div class="act_as_cell amount" style="width: 6.57%;">
<t t-if='type == "account_type"'>
<span
t-esc="total_amount[account_id]['residual']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
<t t-if='type == "partner_type"'>
<span
t-esc="total_amount[account_id][partner_id]['residual']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
<span
t-field="account_or_partner_object.final_amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## amount_total_due_currency + amount_residual_currency -->
<t t-if="foreign_currency">
<!--## currency_name-->
<div class="act_as_cell" />
<!--## amount_total_due_currency-->
<div class="act_as_cell" />
<!--## amount_residual_currency-->
<div class="act_as_cell" />
<t t-if="account_or_partner_object.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell amount" style="width: 2.25%;">
<span
t-field="account_or_partner_object.currency_id.display_name"
/>
</div>
<!--## amount_total_due_currency-->
<div class="act_as_cell amount" style="width: 6.57%;">
<span
t-field="account_or_partner_object.final_amount_total_due_currency"
t-options="{'widget': 'monetary', 'display_currency': account_or_partner_object.currency_id}"
/>
</div>
<!--## amount_residual_currency-->
<div class="act_as_cell amount" style="width: 6.57%;">
<span
t-field="account_or_partner_object.final_amount_residual_currency"
t-options="{'widget': 'monetary', 'display_currency': account_or_partner_object.currency_id}"
/>
</div>
</t>
<t t-if="not account_or_partner_object.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell" />
<!--## amount_total_due_currency-->
<div class="act_as_cell" />
<!--## amount_residual_currency-->
<div class="act_as_cell" />
</t>
</t>
</div>
</div>

1125
account_financial_report/report/templates/trial_balance.xml
File diff suppressed because it is too large
View File

217
account_financial_report/report/templates/vat_report.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="vat_report">
<template id="account_financial_report.report_vat_report_qweb">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="account_financial_report.internal_layout">
@ -10,10 +10,10 @@
</t>
</template>
<template id="account_financial_report.report_vat_report_base">
<t t-set="title">VAT Report - <t t-raw="company_name" /> - <t
t-raw="currency_name"
<t t-set="title">VAT Report - <t t-raw="o.company_id.name" /> - <t
t-raw="o.company_id.currency_id.name"
/></t>
<t t-set="company_name" t-value="company_name" />
<t t-set="company_name" t-value="o.company_id.name" />
<div class="page">
<div class="row">
<h4
@ -42,126 +42,157 @@
<div class="act_as_cell" style="width: 15%;">Tax</div>
</div>
</div>
<t t-foreach="vat_report" t-as="tag_or_group">
<t t-foreach="o.taxtags_ids" t-as="tag">
<div class="act_as_row lines" style="font-weight: bold;">
<t t-if="tag.taxtag_id">
<t t-set="res_model" t-value="'account.account.tag'" />
<t t-set="res_id" t-value="tag.taxtag_id.id" />
</t>
<t t-if="tag.taxgroup_id">
<t t-set="res_model" t-value="'account.tax.group'" />
<t t-set="res_id" t-value="tag.taxgroup_id.id" />
</t>
<div
class="act_as_cell left oe_tooltip_string"
style="width: 5%;"
>
<!-- <span>-->
<!-- <a t-att-data-active-id="res_id"-->
<!-- t-att-data-res-model="res_model"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- t-att-style="style">-->
<t t-att-style="style" t-raw="tag_or_group['code']" />
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-active-id="res_id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
t-att-style="style"
>
<t t-att-style="style" t-raw="tag.code" />
</a>
</span>
</div>
<div
class="act_as_cell left oe_tooltip_string"
style="width: 65%;"
>
<!-- <span>-->
<!-- <a t-att-data-active-id="res_id"-->
<!-- t-att-data-res-model="res_model"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- t-att-style="style">-->
<t t-att-style="style" t-raw="tag_or_group['name']" />
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-active-id="res_id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
t-att-style="style"
>
<t t-att-style="style" t-raw="tag.name" />
</a>
</span>
</div>
<div class="act_as_cell amount" style="width: 15%;">
<!-- <t t-set="domain"-->
<!-- t-value="[('tax_ids', 'in', [tax.tax_id.id for tax in tag.tax_ids]),-->
<!-- ('date', '&gt;=', o.date_from),-->
<!-- ('date', '&lt;=', o.date_to)]"/>-->
<!-- <span>-->
<!-- <a t-att-data-domain="domain"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_multi"-->
<!-- t-att-style="style">-->
<t
t-att-style="style"
t-raw="tag_or_group['net']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-set="domain"
t-value="[('tax_ids', 'in', [tax.tax_id.id for tax in tag.tax_ids]),
('date', '&gt;=', o.date_from),
('date', '&lt;=', o.date_to)]"
/>
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
t-att-style="style"
>
<t
t-att-style="style"
t-raw="tag.net"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
<div class="act_as_cell amount" style="width: 15%;">
<!-- <t t-set="domain"-->
<!-- t-value="[('tax_line_id', 'in', [tax.tax_id.id for tax in tag.tax_ids]),-->
<!-- ('date', '&gt;=', o.date_from),-->
<!-- ('date', '&lt;=', o.date_to),-->
<!-- ('tax_exigible', '=', True)]"/>-->
<!-- <span>-->
<!-- <a t-att-data-domain="domain"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_multi"-->
<!-- t-att-style="style">-->
<t
t-att-style="style"
t-raw="tag_or_group['tax']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-set="domain"
t-value="[('tax_line_id', 'in', [tax.tax_id.id for tax in tag.tax_ids]),
('date', '&gt;=', o.date_from),
('date', '&lt;=', o.date_to),
('tax_exigible', '=', True)]"
/>
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
t-att-style="style"
>
<t
t-att-style="style"
t-raw="tag.tax"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
</div>
<t t-if="tax_detail">
<t t-foreach="tag_or_group['taxes']" t-as="tax">
<t t-if="o.tax_detail">
<t t-foreach="tag.tax_ids" t-as="tax">
<t t-set="res_model" t-value="'account.tax'" />
<div class="act_as_row lines">
<div class="act_as_cell" style="width: 5%;" />
<div
class="act_as_cell left oe_tooltip_string"
style="padding-left: 20px; width: 65%;"
>
<!-- <span>-->
<!-- <a t-att-data-active-id="tax.tax_id.id"-->
<!-- t-att-data-res-model="res_model"-->
<!-- class="o_account_financial_reports_web_action"-->
<!-- t-att-style="style">-->
<t t-att-style="style" t-raw="tax['name']" />
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-active-id="tax.tax_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
t-att-style="style"
>
<t t-att-style="style" t-raw="tax.name" />
</a>
</span>
</div>
<div class="act_as_cell amount" style="width: 15%;">
<!-- <t t-set="domain"-->
<!-- t-value="[('tax_ids', 'in', tax.tax_id.ids),-->
<!-- ('date', '&gt;=', o.date_from),-->
<!-- ('date', '&lt;=', o.date_to),-->
<!-- ('tax_exigible', '=', True)]"/>-->
<!-- <span>-->
<!-- <a t-att-data-domain="domain"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_multi"-->
<!-- t-att-style="style">-->
<t
t-att-style="style"
t-raw="tax['net']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-set="domain"
t-value="[('tax_ids', 'in', tax.tax_id.ids),
('date', '&gt;=', o.date_from),
('date', '&lt;=', o.date_to),
('tax_exigible', '=', True)]"
/>
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
t-att-style="style"
>
<t
t-att-style="style"
t-raw="tax.net"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
<div class="act_as_cell amount" style="width: 15%;">
<!-- <t t-set="domain"-->
<!-- t-value="[('tax_line_id', '=', tax.tax_id.id),-->
<!-- ('date', '&gt;=', o.date_from),-->
<!-- ('date', '&lt;=', o.date_to),-->
<!-- ('tax_exigible', '=', True)]"/>-->
<!-- <span>-->
<!-- <a t-att-data-domain="domain"-->
<!-- t-att-data-res-model="'account.move.line'"-->
<!-- class="o_account_financial_reports_web_action_multi"-->
<!-- t-att-style="style">-->
<t
t-att-style="style"
t-raw="tax['tax']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-set="domain"
t-value="[('tax_line_id', '=', tax.tax_id.id),
('date', '&gt;=', o.date_from),
('date', '&lt;=', o.date_to),
('tax_exigible', '=', True)]"
/>
<!-- </a>-->
<!-- </span>-->
<span>
<a
t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
t-att-style="style"
>
<t
t-att-style="style"
t-raw="tax.tax"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
</div>
</t>
@ -179,13 +210,13 @@
</div>
<div class="act_as_row">
<div class="act_as_cell">
<span t-esc="date_from" />
<span t-field="o.date_from" />
</div>
<div class="act_as_cell">
<span t-esc="date_to" />
<span t-field="o.date_to" />
</div>
<div class="act_as_cell">
<span t-esc="based_on" />
<span t-field="o.based_on" />
</div>
</div>
</div>

1288
account_financial_report/report/trial_balance.py
File diff suppressed because it is too large
View File

129
account_financial_report/report/trial_balance_xlsx.py

@ -8,17 +8,12 @@ from odoo import _, models
class TrialBalanceXslx(models.AbstractModel):
_name = "report.a_f_r.report_trial_balance_xlsx"
_description = "Trial Balance XLSX Report"
_description = "Trial Balance Report XLSX"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report, data=False):
company_id = data.get("company_id", False)
def _get_report_name(self, report):
report_name = _("Trial Balance")
if company_id:
company = self.env["res.company"].browse(company_id)
suffix = " - {} - {}".format(company.name, company.currency_id.name)
report_name = report_name + suffix
return report_name
return self._get_report_complete_name(report, report_name)
def _get_report_columns(self, report):
if not report.show_partner_details:
@ -45,13 +40,13 @@ class TrialBalanceXslx(models.AbstractModel):
},
5: {
"header": _("Period balance"),
"field": "balance",
"field": "period_balance",
"type": "amount",
"width": 14,
},
6: {
"header": _("Ending balance"),
"field": "ending_balance",
"field": "final_balance",
"type": "amount",
"width": 14,
},
@ -67,13 +62,13 @@ class TrialBalanceXslx(models.AbstractModel):
},
8: {
"header": _("Initial balance"),
"field": "initial_currency_balance",
"field": "initial_balance_foreign_currency",
"type": "amount_currency",
"width": 14,
},
9: {
"header": _("Ending balance"),
"field": "ending_currency_balance",
"field": "final_balance_foreign_currency",
"type": "amount_currency",
"width": 14,
},
@ -103,13 +98,13 @@ class TrialBalanceXslx(models.AbstractModel):
},
4: {
"header": _("Period balance"),
"field": "balance",
"field": "period_balance",
"type": "amount",
"width": 14,
},
5: {
"header": _("Ending balance"),
"field": "ending_balance",
"field": "final_balance",
"type": "amount",
"width": 14,
},
@ -125,13 +120,13 @@ class TrialBalanceXslx(models.AbstractModel):
},
7: {
"header": _("Initial balance"),
"field": "initial_currency_balance",
"field": "initial_balance_foreign_currency",
"type": "amount_currency",
"width": 14,
},
8: {
"header": _("Ending balance"),
"field": "ending_currency_balance",
"field": "final_balance_foreign_currency",
"type": "amount_currency",
"width": 14,
},
@ -148,7 +143,7 @@ class TrialBalanceXslx(models.AbstractModel):
[
_("Target moves filter"),
_("All posted entries")
if report.target_move == "all"
if report.only_posted_moves
else _("All entries"),
],
[
@ -173,98 +168,36 @@ class TrialBalanceXslx(models.AbstractModel):
def _get_col_count_filter_value(self):
return 3
def _generate_report_content(self, workbook, report, data):
res_data = self.env[
"report.account_financial_report.trial_balance"
]._get_report_values(report, data)
trial_balance = res_data["trial_balance"]
total_amount = res_data["total_amount"]
partners_data = res_data["partners_data"]
accounts_data = res_data["accounts_data"]
hierarchy_on = res_data["hierarchy_on"]
show_partner_details = res_data["show_partner_details"]
show_hierarchy_level = res_data["show_hierarchy_level"]
foreign_currency = res_data["foreign_currency"]
limit_hierarchy_level = res_data["limit_hierarchy_level"]
if not show_partner_details:
def _generate_report_content(self, workbook, report):
if not report.show_partner_details:
# Display array header for account lines
self.write_array_header()
# For each account
if not show_partner_details:
for balance in trial_balance:
if hierarchy_on == "relation":
if limit_hierarchy_level:
if show_hierarchy_level > balance["level"]:
# Display account lines
self.write_line_from_dict(balance)
else:
self.write_line_from_dict(balance)
elif hierarchy_on == "computed":
if balance["type"] == "account_type":
if limit_hierarchy_level:
if show_hierarchy_level > balance["level"]:
# Display account lines
self.write_line_from_dict(balance)
else:
self.write_line_from_dict(balance)
else:
self.write_line_from_dict(balance)
else:
for account_id in total_amount:
for account in report.account_ids.filtered(lambda a: not a.hide_line):
if not report.show_partner_details:
# Display account lines
self.write_line(account, "account")
else:
# Write account title
self.write_array_title(
accounts_data[account_id]["code"]
+ "- "
+ accounts_data[account_id]["name"]
)
self.write_array_title(account.code + " - " + account.name)
# Display array header for partner lines
self.write_array_header()
# For each partner
for partner_id in total_amount[account_id]:
if isinstance(partner_id, int):
# Display partner lines
self.write_line_from_dict_order(
total_amount[account_id][partner_id],
partners_data[partner_id],
)
for partner in account.partner_ids:
# Display partner lines
self.write_line(partner, "partner")
# Display account footer line
accounts_data[account_id].update(
{
"initial_balance": total_amount[account_id]["initial_balance"],
"credit": total_amount[account_id]["credit"],
"debit": total_amount[account_id]["debit"],
"balance": total_amount[account_id]["balance"],
"ending_balance": total_amount[account_id]["ending_balance"],
}
)
if foreign_currency:
accounts_data[account_id].update(
{
"initial_currency_balance": total_amount[account_id][
"initial_currency_balance"
],
"ending_currency_balance": total_amount[account_id][
"ending_currency_balance"
],
}
)
self.write_account_footer(
accounts_data[account_id],
accounts_data[account_id]["code"]
+ "- "
+ accounts_data[account_id]["name"],
)
self.write_account_footer(account, account.code + " - " + account.name)
# Line break
self.row_pos += 2
def write_line_from_dict_order(self, total_amount, partner_data):
total_amount.update({"name": str(partner_data["name"])})
self.write_line_from_dict(total_amount)
def write_line(self, line_object, type_object):
"""Write a line on current line using all defined columns field name.
Columns are defined with `_get_report_columns` method.
@ -277,12 +210,12 @@ class TrialBalanceXslx(models.AbstractModel):
def write_account_footer(self, account, name_value):
"""Specific function to write account footer for Trial Balance"""
format_amt = self._get_currency_amt_header_format_dict(account)
format_amt = self._get_currency_amt_header_format(account)
for col_pos, column in self.columns.items():
if column["field"] == "name":
value = name_value
else:
value = account[column["field"]]
value = getattr(account, column["field"])
cell_type = column.get("type", "string")
if cell_type == "string":
self.sheet.write_string(
@ -292,11 +225,11 @@ class TrialBalanceXslx(models.AbstractModel):
self.sheet.write_number(
self.row_pos, col_pos, float(value), self.format_header_amount
)
elif cell_type == "many2one" and account["currency_id"]:
elif cell_type == "many2one":
self.sheet.write_string(
self.row_pos, col_pos, value.name or "", self.format_header_right
)
elif cell_type == "amount_currency" and account["currency_id"]:
elif cell_type == "amount_currency" and account.currency_id:
self.sheet.write_number(self.row_pos, col_pos, float(value), format_amt)
else:
self.sheet.write_string(

573
account_financial_report/report/vat_report.py

@ -1,234 +1,361 @@
# Copyright 2018 Forest and Biomass Romania
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import operator
from odoo import api, models
class VATReport(models.AbstractModel):
_name = "report.account_financial_report.vat_report"
_description = "Vat Report Report"
def _get_tax_data(self, tax_ids):
taxes = self.env["account.tax"].browse(tax_ids)
tax_data = {}
for tax in taxes:
tax_data.update(
{
tax.id: {
"id": tax.id,
"name": tax.name,
"tax_group_id": tax.tax_group_id.id,
"type_tax_use": tax.type_tax_use,
"amount_type": tax.amount_type,
"tags_ids": tax.invoice_repartition_line_ids.tag_ids.ids,
}
}
)
return tax_data
from odoo import api, fields, models
@api.model
def _get_tax_report_domain(self, company_id, date_from, date_to, only_posted_moves):
domain = [
("company_id", "=", company_id),
("date", ">=", date_from),
("date", "<=", date_to),
("tax_line_id", "!=", False),
("tax_exigible", "=", True),
]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
return domain
class VATReport(models.TransientModel):
_name = "report_vat_report"
_description = "VAT Report"
_inherit = "account_financial_report_abstract"
""" Here, we just define class fields.
For methods, go more bottom at this file.
The class hierarchy is :
* VATReport
** VATReportTaxTags
*** VATReportTax
"""
# Filters fields, used for data computation
company_id = fields.Many2one(comodel_name="res.company")
date_from = fields.Date()
date_to = fields.Date()
based_on = fields.Selection(
[("taxtags", "Tax Tags"), ("taxgroups", "Tax Groups")],
string="Based On",
required=True,
default="taxtags",
)
tax_detail = fields.Boolean("Tax Detail")
# Data fields, used to browse report data
taxtags_ids = fields.One2many(
comodel_name="report_vat_report_taxtag", inverse_name="report_id"
)
class VATReportTaxTags(models.TransientModel):
_name = "report_vat_report_taxtag"
_inherit = "account_financial_report_abstract"
_order = "code ASC"
report_id = fields.Many2one(
comodel_name="report_vat_report", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
taxtag_id = fields.Many2one("account.account.tag", index=True)
taxgroup_id = fields.Many2one("account.tax.group", index=True)
# Data fields, used for report display
code = fields.Char()
name = fields.Char()
net = fields.Float(digits=(16, 2))
tax = fields.Float(digits=(16, 2))
# Data fields, used to browse report data
tax_ids = fields.One2many(
comodel_name="report_vat_report_tax",
inverse_name="report_tax_id",
string="Taxes",
)
class VATReportTax(models.TransientModel):
_name = "report_vat_report_tax"
_inherit = "account_financial_report_abstract"
_order = "name ASC"
report_tax_id = fields.Many2one(
comodel_name="report_vat_report_taxtag", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
tax_id = fields.Many2one("account.tax", index=True, string="Tax ID",)
# Data fields, used for report display
code = fields.Char()
name = fields.Char()
net = fields.Float(digits=(16, 2))
tax = fields.Float(digits=(16, 2))
class VATReportCompute(models.TransientModel):
""" Here, we just define methods.
For class fields, go more top at this file.
"""
_inherit = "report_vat_report"
def print_report(self, report_type="qweb"):
self.ensure_one()
if report_type == "xlsx":
report_name = "a_f_r.report_vat_report_xlsx"
else:
report_name = "account_financial_report.report_vat_report_qweb"
context = dict(self.env.context)
action = self.env["ir.actions.report"].search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
return action.with_context(context).report_action(self, config=False)
def _get_html(self):
result = {}
rcontext = {}
context = dict(self.env.context)
report = self.browse(context.get("active_id"))
if report:
rcontext["o"] = report
result["html"] = self.env.ref(
"account_financial_report.report_vat_report"
).render(rcontext)
return result
@api.model
def _get_net_report_domain(self, company_id, date_from, date_to, only_posted_moves):
domain = [
("company_id", "=", company_id),
("date", ">=", date_from),
("date", "<=", date_to),
("tax_exigible", "=", True),
]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
return domain
def _get_vat_report_data(self, company_id, date_from, date_to, only_posted_moves):
tax_domain = self._get_tax_report_domain(
company_id, date_from, date_to, only_posted_moves
def get_html(self, given_context=None):
return self.with_context(given_context)._get_html()
def compute_data_for_report(self):
self.ensure_one()
# Compute report data
if self.based_on == "taxtags":
self._inject_taxtags_values()
self._inject_tax_taxtags_values()
elif self.based_on == "taxgroups":
self._inject_taxgroups_values()
self._inject_tax_taxgroups_values()
# Refresh cache because all data are computed with SQL requests
self.refresh()
def _inject_taxtags_values(self):
"""Inject report values for report_vat_report_taxtags."""
query_inject_taxtags = """
WITH
taxtags AS
(SELECT coalesce(regexp_replace(tag.name,
'[^0-9\\.]+', '', 'g'), ' ') AS code,
tag.name, tag.id,
coalesce(sum(movetax.tax_base_amount), 0.00) AS net,
coalesce(sum(movetax.balance), 0.00) AS tax
FROM
account_account_tag AS tag
INNER JOIN account_tax_account_tag AS taxtag
ON tag.id = taxtag.account_account_tag_id
INNER JOIN account_tax AS tax
ON tax.id = taxtag.account_tax_id
INNER JOIN account_move_line AS movetax
ON movetax.tax_line_id = tax.id
INNER JOIN account_move AS move
ON move.id = movetax.move_id
WHERE tag.id is not null AND movetax.tax_exigible
AND move.company_id = %s AND move.date >= %s
AND move.date <= %s AND move.state = 'posted'
GROUP BY tag.id
ORDER BY code, tag.name
)
ml_fields = [
"id",
"tax_base_amount",
"balance",
"tax_line_id",
"tax_ids",
"analytic_tag_ids",
"tag_ids",
]
tax_move_lines = self.env["account.move.line"].search_read(
domain=tax_domain, fields=ml_fields,
INSERT INTO
report_vat_report_taxtag
(
report_id,
create_uid,
create_date,
taxtag_id,
code,
name,
net, tax
)
SELECT
%s AS report_id,
%s AS create_uid,
NOW() AS create_date,
tag.id,
tag.code,
tag.name,
abs(tag.net),
abs(tag.tax)
FROM
taxtags tag
"""
query_inject_taxtags_params = (
self.company_id.id,
self.date_from,
self.date_to,
self.id,
self.env.uid,
)
net_domain = self._get_net_report_domain(
company_id, date_from, date_to, only_posted_moves
self.env.cr.execute(query_inject_taxtags, query_inject_taxtags_params)
def _inject_taxgroups_values(self):
"""Inject report values for report_vat_report_taxtags."""
query_inject_taxgroups = """
WITH
taxgroups AS
(SELECT coalesce(taxgroup.sequence, 0) AS code,
taxgroup.name, taxgroup.id,
coalesce(sum(movetax.tax_base_amount), 0.00) AS net,
coalesce(sum(movetax.balance), 0.00) AS tax
FROM
account_tax_group AS taxgroup
INNER JOIN account_tax AS tax
ON tax.tax_group_id = taxgroup.id
INNER JOIN account_move_line AS movetax
ON movetax.tax_line_id = tax.id
INNER JOIN account_move AS move
ON move.id = movetax.move_id
WHERE taxgroup.id is not null AND movetax.tax_exigible
AND move.company_id = %s AND move.date >= %s
AND move.date <= %s AND move.state = 'posted'
GROUP BY taxgroup.id
ORDER BY code, taxgroup.name
)
taxed_move_lines = self.env["account.move.line"].search_read(
domain=net_domain, fields=ml_fields,
INSERT INTO
report_vat_report_taxtag
(
report_id,
create_uid,
create_date,
taxgroup_id,
code,
name,
net, tax
)
SELECT
%s AS report_id,
%s AS create_uid,
NOW() AS create_date,
groups.id,
groups.code,
groups.name,
abs(groups.net),
abs(groups.tax)
FROM
taxgroups groups
"""
query_inject_taxgroups_params = (
self.company_id.id,
self.date_from,
self.date_to,
self.id,
self.env.uid,
)
taxed_move_lines = list(filter(lambda d: d["tax_ids"], taxed_move_lines))
vat_data = []
for tax_move_line in tax_move_lines:
vat_data.append(
{
"net": 0.0,
"tax": tax_move_line["balance"],
"tax_line_id": tax_move_line["tax_line_id"][0],
}
)
for taxed_move_line in taxed_move_lines:
for tax_id in taxed_move_line["tax_ids"]:
vat_data.append(
{
"net": taxed_move_line["balance"],
"tax": 0.0,
"tax_line_id": tax_id,
}
)
tax_ids = list(map(operator.itemgetter("tax_line_id"), vat_data))
tax_ids = list(set(tax_ids))
tax_data = self._get_tax_data(tax_ids)
return vat_data, tax_data
def _get_tax_group_data(self, tax_group_ids):
tax_groups = self.env["account.tax.group"].browse(tax_group_ids)
tax_group_data = {}
for tax_group in tax_groups:
tax_group_data.update(
{
tax_group.id: {
"id": tax_group.id,
"name": tax_group.name,
"code": str(tax_group.sequence),
}
}
)
return tax_group_data
def _get_vat_report_group_data(self, vat_report_data, tax_data, tax_detail):
vat_report = {}
for tax_move_line in vat_report_data:
tax_id = tax_move_line["tax_line_id"]
if tax_data[tax_id]["amount_type"] == "group":
pass
else:
tax_group_id = tax_data[tax_id]["tax_group_id"]
if tax_group_id not in vat_report.keys():
vat_report[tax_group_id] = {}
vat_report[tax_group_id]["net"] = 0.0
vat_report[tax_group_id]["tax"] = 0.0
vat_report[tax_group_id][tax_id] = dict(tax_data[tax_id])
vat_report[tax_group_id][tax_id].update({"net": 0.0, "tax": 0.0})
else:
if tax_id not in vat_report[tax_group_id].keys():
vat_report[tax_group_id][tax_id] = dict(tax_data[tax_id])
vat_report[tax_group_id][tax_id].update(
{"net": 0.0, "tax": 0.0}
)
vat_report[tax_group_id]["net"] += tax_move_line["net"]
vat_report[tax_group_id]["tax"] += tax_move_line["tax"]
vat_report[tax_group_id][tax_id]["net"] += tax_move_line["net"]
vat_report[tax_group_id][tax_id]["tax"] += tax_move_line["tax"]
tax_group_data = self._get_tax_group_data(vat_report.keys())
vat_report_list = []
for tax_group_id in vat_report.keys():
vat_report[tax_group_id]["name"] = tax_group_data[tax_group_id]["name"]
vat_report[tax_group_id]["code"] = tax_group_data[tax_group_id]["code"]
if tax_detail:
vat_report[tax_group_id]["taxes"] = []
for tax_id in vat_report[tax_group_id]:
if isinstance(tax_id, int):
vat_report[tax_group_id]["taxes"].append(
vat_report[tax_group_id][tax_id]
)
vat_report_list.append(vat_report[tax_group_id])
return vat_report_list
def _get_tags_data(self, tags_ids):
tags = self.env["account.account.tag"].browse(tags_ids)
tags_data = {}
for tag in tags:
tags_data.update({tag.id: {"code": "", "name": tag.name}})
return tags_data
def _get_vat_report_tag_data(self, vat_report_data, tax_data, tax_detail):
vat_report = {}
for tax_move_line in vat_report_data:
tax_id = tax_move_line["tax_line_id"]
tags_ids = tax_data[tax_id]["tags_ids"]
if tax_data[tax_id]["amount_type"] == "group":
continue
else:
if tags_ids:
for tag_id in tags_ids:
if tag_id not in vat_report.keys():
vat_report[tag_id] = {}
vat_report[tag_id]["net"] = 0.0
vat_report[tag_id]["tax"] = 0.0
vat_report[tag_id][tax_id] = dict(tax_data[tax_id])
vat_report[tag_id][tax_id].update({"net": 0.0, "tax": 0.0})
else:
if tax_id not in vat_report[tag_id].keys():
vat_report[tag_id][tax_id] = dict(tax_data[tax_id])
vat_report[tag_id][tax_id].update(
{"net": 0.0, "tax": 0.0}
)
vat_report[tag_id][tax_id]["net"] += tax_move_line["net"]
vat_report[tag_id][tax_id]["tax"] += tax_move_line["tax"]
vat_report[tag_id]["net"] += tax_move_line["net"]
vat_report[tag_id]["tax"] += tax_move_line["tax"]
tags_data = self._get_tags_data(vat_report.keys())
vat_report_list = []
for tag_id in vat_report.keys():
vat_report[tag_id]["name"] = tags_data[tag_id]["name"]
vat_report[tag_id]["code"] = tags_data[tag_id]["code"]
if tax_detail:
vat_report[tag_id]["taxes"] = []
for tax_id in vat_report[tag_id]:
if isinstance(tax_id, int):
vat_report[tag_id]["taxes"].append(vat_report[tag_id][tax_id])
vat_report_list.append(vat_report[tag_id])
return vat_report_list
def _get_report_values(self, docids, data):
wizard_id = data["wizard_id"]
company = self.env["res.company"].browse(data["company_id"])
company_id = data["company_id"]
date_from = data["date_from"]
date_to = data["date_to"]
based_on = data["based_on"]
tax_detail = data["tax_detail"]
only_posted_moves = data["only_posted_moves"]
vat_report_data, tax_data = self._get_vat_report_data(
company_id, date_from, date_to, only_posted_moves
self.env.cr.execute(query_inject_taxgroups, query_inject_taxgroups_params)
def _inject_tax_taxtags_values(self):
""" Inject report values for report_vat_report_tax. """
# pylint: disable=sql-injection
query_inject_tax = """
WITH
taxtags_tax AS
(
SELECT
tag.id AS report_tax_id, ' ' AS code,
tax.name, tax.id,
coalesce(sum(movetax.tax_base_amount), 0.00) AS net,
coalesce(sum(movetax.balance), 0.00) AS tax
FROM
report_vat_report_taxtag AS tag
INNER JOIN account_tax_account_tag AS taxtag
ON tag.taxtag_id = taxtag.account_account_tag_id
INNER JOIN account_tax AS tax
ON tax.id = taxtag.account_tax_id
INNER JOIN account_move_line AS movetax
ON movetax.tax_line_id = tax.id
INNER JOIN account_move AS move
ON move.id = movetax.move_id
WHERE tag.id is not null AND movetax.tax_exigible
AND tag.report_id = %s AND move.company_id = %s
AND move.date >= %s AND move.date <= %s
AND move.state = 'posted'
GROUP BY tag.id, tax.id
ORDER BY tax.name
)
if based_on == "taxgroups":
vat_report = self._get_vat_report_group_data(
vat_report_data, tax_data, tax_detail
)
else:
vat_report = self._get_vat_report_tag_data(
vat_report_data, tax_data, tax_detail
)
return {
"doc_ids": [wizard_id],
"doc_model": "open.items.report.wizard",
"docs": self.env["open.items.report.wizard"].browse(wizard_id),
"company_name": company.display_name,
"currency_name": company.currency_id.name,
"date_to": data["date_to"],
"date_from": data["date_from"],
"based_on": data["based_on"],
"tax_detail": data["tax_detail"],
"vat_report": vat_report,
}
INSERT INTO
report_vat_report_tax
(
report_tax_id,
create_uid,
create_date,
tax_id,
name,
net,
tax
)
SELECT
tt.report_tax_id,
%s AS create_uid,
NOW() AS create_date,
tt.id,
tt.name,
abs(tt.net),
abs(tt.tax)
FROM
taxtags_tax tt
"""
query_inject_tax_params = (
self.id,
self.company_id.id,
self.date_from,
self.date_to,
self.env.uid,
)
self.env.cr.execute(query_inject_tax, query_inject_tax_params)
def _inject_tax_taxgroups_values(self):
""" Inject report values for report_vat_report_tax. """
# pylint: disable=sql-injection
query_inject_tax = """
WITH
taxtags_tax AS
(
SELECT
taxtag.id AS report_tax_id, ' ' AS code,
tax.name, tax.id,
coalesce(sum(movetax.tax_base_amount), 0.00) AS net,
coalesce(sum(movetax.balance), 0.00) AS tax
FROM
report_vat_report_taxtag AS taxtag
INNER JOIN account_tax AS tax
ON tax.tax_group_id = taxtag.taxgroup_id
INNER JOIN account_move_line AS movetax
ON movetax.tax_line_id = tax.id
INNER JOIN account_move AS move
ON move.id = movetax.move_id
WHERE taxtag.id is not null AND movetax.tax_exigible
AND taxtag.report_id = %s AND move.company_id = %s
AND move.date >= %s AND move.date <= %s
AND move.state = 'posted'
GROUP BY taxtag.id, tax.id
ORDER BY tax.name
)
INSERT INTO
report_vat_report_tax
(
report_tax_id,
create_uid,
create_date,
tax_id,
name,
net,
tax
)
SELECT
tt.report_tax_id,
%s AS create_uid,
NOW() AS create_date,
tt.id,
tt.name,
abs(tt.net),
abs(tt.tax)
FROM
taxtags_tax tt
"""
query_inject_tax_params = (
self.id,
self.company_id.id,
self.date_from,
self.date_to,
self.env.uid,
)
self.env.cr.execute(query_inject_tax, query_inject_tax_params)

41
account_financial_report/report/vat_report_xlsx.py

@ -6,17 +6,12 @@ from odoo import _, models
class VATReportXslx(models.AbstractModel):
_name = "report.a_f_r.report_vat_report_xlsx"
_description = "Vat Report XLSX Report"
_description = "VAT Report XLSX"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report, data):
company_id = data.get("company_id", False)
report_name = _("Vat Report")
if company_id:
company = self.env["res.company"].browse(company_id)
suffix = " - {} - {}".format(company.name, company.currency_id.name)
report_name = report_name + suffix
return report_name
def _get_report_name(self, report):
report_name = _("VAT Report")
return self._get_report_complete_name(report, report_name)
def _get_report_columns(self, report):
return {
@ -28,12 +23,9 @@ class VATReportXslx(models.AbstractModel):
def _get_report_filters(self, report):
return [
[_("Date from"), report.date_from.strftime("%d/%m/%Y")],
[_("Date to"), report.date_to.strftime("%d/%m/%Y")],
[
_("Based on"),
_("Tax Tags") if report.based_on == "taxtags" else _("Tax Groups"),
],
[_("Date from"), report.date_from],
[_("Date to"), report.date_to],
[_("Based on"), report.based_on],
]
def _get_col_count_filter_name(self):
@ -42,19 +34,14 @@ class VATReportXslx(models.AbstractModel):
def _get_col_count_filter_value(self):
return 2
def _generate_report_content(self, workbook, report, data):
res_data = self.env[
"report.account_financial_report.vat_report"
]._get_report_values(report, data)
vat_report = res_data["vat_report"]
tax_detail = res_data["tax_detail"]
# For each tax_tag tax_group
def _generate_report_content(self, workbook, report):
# For each taxtag
self.write_array_header()
for tag_or_group in vat_report:
for taxtag in report.taxtags_ids:
# Write taxtag line
self.write_line_from_dict(tag_or_group)
self.write_line(taxtag)
# For each tax if detail taxes
if tax_detail:
for tax in tag_or_group["taxes"]:
self.write_line_from_dict(tax)
if report.tax_detail:
for tax in taxtag.tax_ids:
self.write_line(tax)

134
account_financial_report/reports.xml

@ -3,117 +3,105 @@
<!-- PDF/HMTL REPORTS -->
<!-- General Ledger -->
<report
id="action_print_report_general_ledger_qweb"
model="general.ledger.report.wizard"
id="action_report_general_ledger_qweb"
model="report_general_ledger"
string="General Ledger"
report_type="qweb-pdf"
menu="False"
name="account_financial_report.general_ledger"
file="account_financial_report.general_ledger"
name="account_financial_report.report_general_ledger_qweb"
file="account_financial_report.report_general_ledger_qweb"
/>
<report
id="action_print_report_general_ledger_html"
model="general.ledger.report.wizard"
id="action_report_general_ledger_html"
model="report_general_ledger"
string="General Ledger"
report_type="qweb-html"
menu="False"
name="account_financial_report.general_ledger"
file="account_financial_report.general_ledger"
name="account_financial_report.report_general_ledger_qweb"
file="account_financial_report.report_general_ledger_html"
/>
<!-- Journal Ledger -->
<report
id="action_print_journal_ledger_wizard_qweb"
model="journal.ledger.report.wizard"
report_type="qweb-pdf"
menu="False"
id="action_report_journal_ledger_qweb"
model="report_journal_ledger"
string="Journal Ledger"
name="account_financial_report.journal_ledger"
file="account_financial_report.journal_ledger"
report_type="qweb-pdf"
name="account_financial_report.report_journal_ledger_qweb"
file="account_financial_report.report_journal_ledger_qweb"
/>
<report
id="action_print_journal_ledger_wizard_html"
model="journal.ledger.report.wizard"
report_type="qweb-html"
menu="False"
id="action_report_journal_ledger_html"
model="report_journal_ledger"
string="Journal Ledger"
name="account_financial_report.journal_ledger"
file="account_financial_report.journal_ledger"
report_type="qweb-html"
name="account_financial_report.report_journal_ledger_qweb"
file="account_financial_report.report_journal_ledger_html"
/>
<!-- Trial Balance -->
<report
id="action_report_trial_balance_qweb"
model="trial.balance.report.wizard"
model="report_trial_balance"
string="Trial Balance"
menu="False"
report_type="qweb-pdf"
name="account_financial_report.trial_balance"
file="account_financial_report.trial_balance"
name="account_financial_report.report_trial_balance_qweb"
file="account_financial_report.report_trial_balance_qweb"
/>
<report
id="action_report_trial_balance_html"
model="trial.balance.report.wizard"
model="report_trial_balance"
string="Trial Balance"
menu="False"
report_type="qweb-html"
name="account_financial_report.trial_balance"
file="account_financial_report.trial_balance"
name="account_financial_report.report_trial_balance_qweb"
file="account_financial_report.report_trial_balance_html"
/>
<!-- Open Items -->
<report
id="action_print_report_open_items_qweb"
model="open.items.report.wizard"
id="action_report_open_items_qweb"
model="report_open_items"
string="Open Items"
menu="False"
report_type="qweb-pdf"
name="account_financial_report.open_items"
file="account_financial_report.open_items"
name="account_financial_report.report_open_items_qweb"
file="account_financial_report.report_open_items_qweb"
/>
<report
id="action_print_report_open_items_html"
model="open.items.report.wizard"
id="action_report_open_items_html"
model="report_open_items"
string="Open Items"
menu="False"
report_type="qweb-html"
name="account_financial_report.open_items"
file="account_financial_report.open_items"
name="account_financial_report.report_open_items_qweb"
file="account_financial_report.report_open_items_html"
/>
<!-- Aged Partner Balance -->
<report
id="action_print_report_aged_partner_balance_qweb"
model="aged.partner.balance.report.wizard"
id="action_report_aged_partner_balance_qweb"
model="report_aged_partner_balance"
string="Aged Partner Balance"
report_type="qweb-pdf"
menu="False"
name="account_financial_report.aged_partner_balance"
file="account_financial_report.aged_partner_balance"
name="account_financial_report.report_aged_partner_balance_qweb"
file="account_financial_report.report_aged_partner_balance_qweb"
/>
<report
id="action_print_report_aged_partner_balance_html"
model="aged.partner.balance.report.wizard"
id="action_report_aged_partner_balance_html"
model="report_aged_partner_balance"
string="Aged Partner Balance"
report_type="qweb-html"
menu="False"
name="account_financial_report.aged_partner_balance"
file="account_financial_report.aged_partner_balance"
name="account_financial_report.report_aged_partner_balance_qweb"
file="account_financial_report.report_aged_partner_balance_html"
/>
<!-- VAT Report -->
<report
id="action_print_report_vat_report_qweb"
model="vat.report.wizard"
id="action_report_vat_report_qweb"
model="report_vat_report"
string="VAT Report"
report_type="qweb-pdf"
menu="False"
name="account_financial_report.vat_report"
file="account_financial_report.vat_report"
name="account_financial_report.report_vat_report_qweb"
file="account_financial_report.report_vat_report_qweb"
/>
<report
id="action_print_report_vat_report_html"
model="vat.report.wizard"
id="action_report_vat_report_html"
model="report_vat_report"
string="VAT Report"
report_type="qweb-html"
menu="False"
name="account_financial_report.vat_report"
file="account_financial_report.vat_report"
name="account_financial_report.report_vat_report_qweb"
file="account_financial_report.report_vat_report_html"
/>
<!-- PDF REPORTS : paperformat -->
<record id="report_qweb_paperformat" model="report.paperformat">
@ -131,31 +119,25 @@
<field name="header_spacing">10</field>
<field name="dpi">110</field>
</record>
<record id="action_print_report_general_ledger_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat" />
</record>
<record id="action_print_journal_ledger_wizard_qweb" model="ir.actions.report">
<record id="action_report_general_ledger_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat" />
</record>
<record id="action_report_trial_balance_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat" />
</record>
<record id="action_print_report_open_items_qweb" model="ir.actions.report">
<record id="action_report_open_items_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat" />
</record>
<record
id="action_print_report_aged_partner_balance_qweb"
model="ir.actions.report"
>
<record id="action_report_aged_partner_balance_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat" />
</record>
<record id="action_print_report_vat_report_qweb" model="ir.actions.report">
<record id="action_report_vat_report_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat" />
</record>
<!-- XLSX REPORTS -->
<record id="action_report_general_ledger_xlsx" model="ir.actions.report">
<field name="name">General Ledger XLSX</field>
<field name="model">general.ledger.report.wizard</field>
<field name="model">report_general_ledger</field>
<field name="type">ir.actions.report</field>
<field name="report_name">a_f_r.report_general_ledger_xlsx</field>
<field name="report_type">xlsx</field>
@ -163,7 +145,7 @@
</record>
<record id="action_report_journal_ledger_xlsx" model="ir.actions.report">
<field name="name">Journal Ledger XLSX</field>
<field name="model">journal.ledger.report.wizard</field>
<field name="model">report_journal_ledger</field>
<field name="type">ir.actions.report</field>
<field name="report_name">a_f_r.report_journal_ledger_xlsx</field>
<field name="report_type">xlsx</field>
@ -171,7 +153,7 @@
</record>
<record id="action_report_trial_balance_xlsx" model="ir.actions.report">
<field name="name">Trial Balance XLSX</field>
<field name="model">trial.balance.report.wizard</field>
<field name="model">report_trial_balance</field>
<field name="type">ir.actions.report</field>
<field name="report_name">a_f_r.report_trial_balance_xlsx</field>
<field name="report_type">xlsx</field>
@ -179,7 +161,7 @@
</record>
<record id="action_report_open_items_xlsx" model="ir.actions.report">
<field name="name">Open Items XLSX</field>
<field name="model">open.items.report.wizard</field>
<field name="model">report_open_items</field>
<field name="type">ir.actions.report</field>
<field name="report_name">a_f_r.report_open_items_xlsx</field>
<field name="report_type">xlsx</field>
@ -187,7 +169,7 @@
</record>
<record id="action_report_aged_partner_balance_xlsx" model="ir.actions.report">
<field name="name">Aged Partner Balance XLSX</field>
<field name="model">aged.partner.balance.report.wizard</field>
<field name="model">report_aged_partner_balance</field>
<field name="type">ir.actions.report</field>
<field name="report_name">a_f_r.report_aged_partner_balance_xlsx</field>
<field name="report_type">xlsx</field>
@ -195,7 +177,7 @@
</record>
<record id="action_report_vat_report_xlsx" model="ir.actions.report">
<field name="name">VAT Report XLSX</field>
<field name="model">vat.report.wizard</field>
<field name="model">report_vat_report</field>
<field name="type">ir.actions.report</field>
<field name="report_name">a_f_r.report_vat_report_xlsx</field>
<field name="report_type">xlsx</field>

70
account_financial_report/static/description/index.html

@ -367,9 +367,9 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/account-financial-reporting/tree/13.0/account_financial_report"><img alt="OCA/account-financial-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-reporting-13-0/account-financial-reporting-13-0-account_financial_report"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/91/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" 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" 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" href="https://github.com/OCA/account-financial-reporting/tree/12.0/account_financial_report"><img alt="OCA/account-financial-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-reporting-12-0/account-financial-reporting-12-0-account_financial_report"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/91/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds a set of financial reports. They are accessible under
Invoicing / Reporting / OCA accounting reports.</p>
Accounting / Reporting / OCA Reports.</p>
<ul class="simple">
<li>General ledger</li>
<li>Trial Balance</li>
@ -386,44 +386,31 @@ currency balances are not available.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#known-issues-roadmap" id="id4">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#changelog" id="id5">Changelog</a><ul>
<li><a class="reference internal" href="#id1" id="id6">11.0.2.5.0 (2019-04-26)</a></li>
<li><a class="reference internal" href="#id2" id="id7">11.0.2.4.1 (2019-01-08)</a></li>
<li><a class="reference internal" href="#id3" id="id8">11.0.2.3.1 (2018-11-29)</a></li>
<li><a class="reference internal" href="#changelog" id="id4">Changelog</a><ul>
<li><a class="reference internal" href="#id1" id="id5">11.0.2.5.0 (2019-04-26)</a></li>
<li><a class="reference internal" href="#id2" id="id6">11.0.2.4.1 (2019-01-08)</a></li>
<li><a class="reference internal" href="#id3" id="id7">11.0.2.3.1 (2018-11-29)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="id9">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id10">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id11">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id12">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id13">Maintainers</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id8">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id9">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id10">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id11">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id12">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id4">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>‘VAT Report’ is valid only for cases where it’s met that for each
Tax defined: all the “Account tags” of all the
‘Repartition for Invoices’ or ‘Repartition for Credit Notes’
are different.</li>
<li>It would be nice to have in reports a column indicating the
state of the entries when the option “All Entries” is selected
in “Target Moves” field in a wizard</li>
</ul>
</div>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#id5">Changelog</a></h1>
<h1><a class="toc-backref" href="#id4">Changelog</a></h1>
<div class="section" id="id1">
<h2><a class="toc-backref" href="#id6">11.0.2.5.0 (2019-04-26)</a></h2>
<h2><a class="toc-backref" href="#id5">11.0.2.5.0 (2019-04-26)</a></h2>
<ul class="simple">
<li>In the Trial Balance you have an option to hide parent hierarchy levels</li>
</ul>
</div>
<div class="section" id="id2">
<h2><a class="toc-backref" href="#id7">11.0.2.4.1 (2019-01-08)</a></h2>
<h2><a class="toc-backref" href="#id6">11.0.2.4.1 (2019-01-08)</a></h2>
<ul class="simple">
<li>Handle better multicompany behaviour</li>
<li>Improve how title appears in the reports</li>
@ -431,7 +418,7 @@ in “Target Moves” field in a wizard</li>
</ul>
</div>
<div class="section" id="id3">
<h2><a class="toc-backref" href="#id8">11.0.2.3.1 (2018-11-29)</a></h2>
<h2><a class="toc-backref" href="#id7">11.0.2.3.1 (2018-11-29)</a></h2>
<ul class="simple">
<li>In the Trial Balance you can apply a filter by hierarchy levels</li>
<li>In the General Ledger you can apply a filter by Analytic Tag</li>
@ -440,28 +427,28 @@ in “Target Moves” field in a wizard</li>
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id9">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#id8">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_financial_report%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_financial_report%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id10">Credits</a></h1>
<h1><a class="toc-backref" href="#id9">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id11">Authors</a></h2>
<h2><a class="toc-backref" href="#id10">Authors</a></h2>
<ul class="simple">
<li>Camptocamp SA</li>
<li>initOS GmbH</li>
<li>redCOR AG</li>
<li>ForgeFlow</li>
<li>Eficent</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id12">Contributors</a></h2>
<h2><a class="toc-backref" href="#id11">Contributors</a></h2>
<ul class="simple">
<li>Jordi Ballester &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
<li>Jordi Ballester &lt;<a class="reference external" href="mailto:jordi.ballester&#64;eficient.com">jordi.ballester&#64;eficient.com</a>&gt;</li>
<li>Yannick Vaucher &lt;<a class="reference external" href="mailto:yannick.vaucher&#64;camptocamp.com">yannick.vaucher&#64;camptocamp.com</a>&gt;</li>
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simone.orsi&#64;abstract.com">simone.orsi&#64;abstract.com</a>&gt;</li>
<li>Leonardo Pistone &lt;<a class="reference external" href="mailto:leonardo.pistone&#64;camptocamp.com">leonardo.pistone&#64;camptocamp.com</a>&gt;</li>
@ -477,27 +464,28 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li>
<li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis&#64;via.ecp.fr">alexis&#64;via.ecp.fr</a>&gt;</li>
<li>Mihai Fekete &lt;<a class="reference external" href="mailto:feketemihai&#64;gmail.com">feketemihai&#64;gmail.com</a>&gt;</li>
<li>Miquel Raïch &lt;<a class="reference external" href="mailto:miquel.raich&#64;forgeflow.com">miquel.raich&#64;forgeflow.com</a>&gt;</li>
<li>Joan Sisquella &lt;<a class="reference external" href="mailto:joan.sisquella&#64;forgeflow.com">joan.sisquella&#64;forgeflow.com</a>&gt;</li>
<li>Miquel Raïch &lt;<a class="reference external" href="mailto:miquel.raich&#64;eficent.com">miquel.raich&#64;eficent.com</a>&gt;</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Pedro M. Baeza</li>
<li>Sergio Teruel</li>
<li>Ernesto Tejeda</li>
</ul>
</li>
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
<li><a class="reference external" href="https://www.druidoo.io">Druidoo</a>:<ul>
<li>Iván Todorovich</li>
</ul>
</li>
</ul>
<p>Much of the work in this module was done at a sprint in Sorrento, Italy in
April 2016.</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id13">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id12">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>
<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>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/13.0/account_financial_report">OCA/account-financial-reporting</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/12.0/account_financial_report">OCA/account-financial-reporting</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

33
account_financial_report/static/src/js/account_financial_report_backend.js

@ -4,17 +4,22 @@ odoo.define("account_financial_report.account_financial_report_backend", functio
"use strict";
var core = require("web.core");
var Widget = require("web.Widget");
var ControlPanelMixin = require("web.ControlPanelMixin");
var AbstractAction = require('web.AbstractAction');
var ReportWidget = require("account_financial_report.account_financial_report_widget");
var report_backend = Widget.extend(ControlPanelMixin, {
var report_backend = AbstractAction.extend({
// TODO: why isnt the controlpanel shown?
hasControlPanel: true,
withSearchBar: true,
withBreadcrumbs: true,
loadControlPanel: true,
// Stores all the parameters of the action.
events: {
"click .o_account_financial_reports_print": "print",
"click .o_account_financial_reports_export": "export",
},
init: function(parent, action) {
var ret = this._super.apply(this, arguments);
this.actionManager = parent;
this.given_context = {};
this.odoo_context = action.context;
@ -26,17 +31,18 @@ odoo.define("account_financial_report.account_financial_report_backend", functio
action.context.active_id || action.params.active_id;
this.given_context.model = action.context.active_model || false;
this.given_context.ttype = action.context.ttype || false;
return this._super.apply(this, arguments);
this.controlPanelParams.modelName = 'account.bank.statement.line';
return ret;
},
willStart: function() {
return $.when(this.get_html());
return Promise.resolve(this.get_html());
},
set_html: function() {
var self = this;
var def = $.when();
var def = Promise.resolve();
if (!this.report_widget) {
this.report_widget = new ReportWidget(this, this.given_context);
def = this.report_widget.appendTo(this.$el);
def = this.report_widget.appendTo(this.$('.o_content'));
}
def.then(function() {
self.report_widget.$el.html(self.html);
@ -44,6 +50,7 @@ odoo.define("account_financial_report.account_financial_report_backend", functio
},
start: function() {
this.set_html();
this.update_cp();
return this._super();
},
// Fetches the html and is previous report.context if any,
@ -59,19 +66,13 @@ odoo.define("account_financial_report.account_financial_report_backend", functio
}).then(function(result) {
self.html = result.html;
defs.push(self.update_cp());
return $.when.apply($, defs);
return Promise.all(defs);
});
},
// Updates the control panel and render the elements that have yet
// to be rendered
update_cp: function() {
if (this.$buttons) {
var status = {
breadcrumbs: this.actionManager.get_breadcrumbs(),
cp_content: {$buttons: this.$buttons},
};
return this.update_control_panel(status);
}
return this.updateControlPanel({});
},
do_show: function() {
this._super();
@ -100,7 +101,7 @@ odoo.define("account_financial_report.account_financial_report_backend", functio
});
},
canBeRemoved: function() {
return $.when();
return Promise.resolve();
},
});

4
account_financial_report/tests/__init__.py

@ -1,6 +1,10 @@
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
from . import abstract_test
from . import abstract_test_tax_report
from . import abstract_test_foreign_currency
from . import test_aged_partner_balance
from . import test_general_ledger
from . import test_journal_ledger
from . import test_open_items

444
account_financial_report/tests/abstract_test.py

@ -0,0 +1,444 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from odoo.tests import common
from odoo.tools import test_reports
_logger = logging.getLogger(__name__)
class AbstractTest(common.TransactionCase):
"""Common technical tests for all reports."""
at_install = False
post_install = True
accounts = {}
def with_context(self, *args, **kwargs):
context = dict(args[0] if args else self.env.context, **kwargs)
self.env = self.env(context=context)
return self
def _chart_template_create(self):
transfer_account_id = self.env["account.account.template"].create(
{
"code": "000",
"name": "Liquidity Transfers",
"reconcile": True,
"user_type_id": self.ref("account.data_account_type_current_assets"),
}
)
self.chart = self.env["account.chart.template"].create(
{
"name": "Test COA",
"code_digits": 4,
"bank_account_code_prefix": 1014,
"cash_account_code_prefix": 1014,
"currency_id": self.ref("base.USD"),
"transfer_account_code_prefix": "000",
}
)
transfer_account_id.update(
{"chart_template_id": self.chart.id,}
)
self.env["ir.model.data"].create(
{
"res_id": transfer_account_id.id,
"model": transfer_account_id._name,
"name": "Liquidity Transfers",
}
)
act = self.env["account.account.template"].create(
{
"code": "001",
"name": "Expenses",
"user_type_id": self.ref("account.data_account_type_expenses"),
"chart_template_id": self.chart.id,
"reconcile": True,
}
)
self.env["ir.model.data"].create(
{"res_id": act.id, "model": act._name, "name": "expenses",}
)
act = self.env["account.account.template"].create(
{
"code": "002",
"name": "Product Sales",
"user_type_id": self.ref("account.data_account_type_revenue"),
"chart_template_id": self.chart.id,
"reconcile": True,
}
)
self.env["ir.model.data"].create(
{"res_id": act.id, "model": act._name, "name": "sales",}
)
act = self.env["account.account.template"].create(
{
"code": "003",
"name": "Account Receivable",
"user_type_id": self.ref("account.data_account_type_receivable"),
"chart_template_id": self.chart.id,
"reconcile": True,
}
)
self.env["ir.model.data"].create(
{"res_id": act.id, "model": act._name, "name": "receivable",}
)
act = self.env["account.account.template"].create(
{
"code": "004",
"name": "Account Payable",
"user_type_id": self.ref("account.data_account_type_payable"),
"chart_template_id": self.chart.id,
"reconcile": True,
}
)
self.env["ir.model.data"].create(
{"res_id": act.id, "model": act._name, "name": "payable",}
)
def _add_chart_of_accounts(self):
self.company = self.env["res.company"].create({"name": "Spanish test company",})
self.env.ref("base.group_multi_company").write(
{"users": [(4, self.env.uid)],}
)
self.env.user.write(
{"company_ids": [(4, self.company.id)], "company_id": self.company.id,}
)
self.with_context(company_id=self.company.id, force_company=self.company.id)
self.chart.try_loading_for_current_company()
self.revenue = self.env["account.account"].search(
[("user_type_id", "=", self.ref("account.data_account_type_revenue"))],
limit=1,
)
self.expense = self.env["account.account"].search(
[("user_type_id", "=", self.ref("account.data_account_type_expenses"))],
limit=1,
)
self.receivable = self.env["account.account"].search(
[("user_type_id", "=", self.ref("account.data_account_type_receivable"))],
limit=1,
)
self.payable = self.env["account.account"].search(
[("user_type_id", "=", self.ref("account.data_account_type_payable"))],
limit=1,
)
return True
def _journals_create(self):
self.journal_sale = self.env["account.journal"].create(
{
"company_id": self.company.id,
"name": "Test journal for sale",
"type": "sale",
"code": "TSALE",
"default_debit_account_id": self.revenue.id,
"default_credit_account_id": self.revenue.id,
}
)
self.journal_purchase = self.env["account.journal"].create(
{
"company_id": self.company.id,
"name": "Test journal for purchase",
"type": "purchase",
"code": "TPUR",
"default_debit_account_id": self.expense.id,
"default_credit_account_id": self.expense.id,
}
)
return True
def _invoice_create(self):
self.partner = self.env["res.partner"].create(
{
"name": "Test partner",
"company_id": self.company.id,
"property_account_receivable_id": self.receivable.id,
"property_account_payable_id": self.payable.id,
}
)
# customer invoice
customer_invoice_lines = [
(
0,
False,
{
"name": "Test description #1",
"account_id": self.revenue.id,
"quantity": 1.0,
"price_unit": 100.0,
},
),
(
0,
False,
{
"name": "Test description #2",
"account_id": self.revenue.id,
"quantity": 2.0,
"price_unit": 25.0,
},
),
]
self.invoice_out = self.env["account.invoice"].create(
{
"partner_id": self.partner.id,
"type": "out_invoice",
"invoice_line_ids": customer_invoice_lines,
"account_id": self.partner.property_account_receivable_id.id,
"journal_id": self.journal_sale.id,
}
)
self.invoice_out.action_invoice_open()
# vendor bill
vendor_invoice_lines = [
(
0,
False,
{
"name": "Test description #1",
"account_id": self.revenue.id,
"quantity": 1.0,
"price_unit": 100.0,
},
),
(
0,
False,
{
"name": "Test description #2",
"account_id": self.revenue.id,
"quantity": 2.0,
"price_unit": 25.0,
},
),
]
self.invoice_in = self.env["account.invoice"].create(
{
"partner_id": self.partner.id,
"type": "in_invoice",
"invoice_line_ids": vendor_invoice_lines,
"account_id": self.partner.property_account_payable_id.id,
"journal_id": self.journal_purchase.id,
}
)
self.invoice_in.action_invoice_open()
def setUp(self):
super(AbstractTest, self).setUp()
self.with_context()
self._chart_template_create()
self._add_chart_of_accounts()
self._journals_create()
self._invoice_create()
self.model = self._getReportModel()
self.qweb_report_name = self._getQwebReportName()
self.xlsx_report_name = self._getXlsxReportName()
self.xlsx_action_name = self._getXlsxReportActionName()
self.report_title = self._getReportTitle()
self.base_filters = self._getBaseFilters()
self.additional_filters = self._getAdditionalFiltersToBeTested()
self.report = self.model.create(self.base_filters)
self.report.compute_data_for_report()
def test_html(self):
test_reports.try_report(
self.env.cr,
self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type="qweb-html",
)
def test_qweb(self):
test_reports.try_report(
self.env.cr,
self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type="qweb-pdf",
)
def test_xlsx(self):
test_reports.try_report(
self.env.cr,
self.env.uid,
self.xlsx_report_name,
[self.report.id],
report_type="xlsx",
)
def test_print(self):
self.report.print_report("qweb")
self.report.print_report("xlsx")
def test_02_generation_report_html(self):
"""Check if report HTML is correctly generated"""
# Check if returned report action is correct
report_type = "qweb-html"
report_action = self.report.print_report(report_type)
self.assertDictContainsSubset(
{
"type": "ir.actions.report",
"report_name": self.qweb_report_name,
"report_type": "qweb-html",
},
report_action,
)
# Check if report template is correct
report = self.env["ir.actions.report"].search(
[
("report_name", "=", self.qweb_report_name),
("report_type", "=", report_type),
],
limit=1,
)
self.assertEqual(report.report_type, "qweb-html")
rep = report.render(self.report.ids, {})
self.assertTrue(self.report_title.encode("utf8") in rep[0])
self.assertTrue(self.report.account_ids[0].name.encode("utf8") in rep[0])
def test_04_compute_data(self):
"""Check that the SQL queries work with all filters options"""
for filters in [{}] + self.additional_filters:
current_filter = self.base_filters.copy()
current_filter.update(filters)
report = self.model.create(current_filter)
report.compute_data_for_report()
self.assertGreaterEqual(len(report.account_ids), 1)
# Same filters with only one account
current_filter = self.base_filters.copy()
current_filter.update(filters)
report_accounts = report.account_ids.filtered("account_id")
current_filter.update(
{"filter_account_ids": [(6, 0, report_accounts[0].account_id.ids)],}
)
report2 = self.model.create(current_filter)
report2.compute_data_for_report()
self.assertEqual(len(report2.account_ids), 1)
self.assertEqual(report2.account_ids.name, report_accounts[0].name)
if self._partner_test_is_possible(filters):
# Same filters with only one partner
report_partner_ids = report.account_ids.mapped("partner_ids")
partner_ids = report_partner_ids.mapped("partner_id")
current_filter = self.base_filters.copy()
current_filter.update(filters)
current_filter.update(
{"filter_partner_ids": [(6, 0, partner_ids[0].ids)],}
)
report3 = self.model.create(current_filter)
report3.compute_data_for_report()
self.assertGreaterEqual(len(report3.account_ids), 1)
report_partner_ids3 = report3.account_ids.mapped("partner_ids")
partner_ids3 = report_partner_ids3.mapped("partner_id")
self.assertEqual(len(partner_ids3), 1)
self.assertEqual(partner_ids3.name, partner_ids[0].name)
# Same filters with only one partner and one account
report_partner_ids = report3.account_ids.mapped("partner_ids")
report_account_id = report_partner_ids.filtered(lambda p: p.partner_id)[
0
].report_account_id
current_filter = self.base_filters.copy()
current_filter.update(filters)
current_filter.update(
{
"filter_account_ids": [
(6, 0, report_account_id.account_id.ids)
],
"filter_partner_ids": [(6, 0, partner_ids[0].ids)],
}
)
report4 = self.model.create(current_filter)
report4.compute_data_for_report()
self.assertEqual(len(report4.account_ids), 1)
self.assertEqual(
report4.account_ids.name, report_account_id.account_id.name
)
report_partner_ids4 = report4.account_ids.mapped("partner_ids")
partner_ids4 = report_partner_ids4.mapped("partner_id")
self.assertEqual(len(partner_ids4), 1)
self.assertEqual(partner_ids4.name, partner_ids[0].name)
def _partner_test_is_possible(self, filters):
"""
:return:
a boolean to indicate if partner test is possible
with current filters
"""
return True
def _getReportModel(self):
"""
:return: the report model name
"""
raise NotImplementedError()
def _getQwebReportName(self):
"""
:return: the qweb report name
"""
raise NotImplementedError()
def _getXlsxReportName(self):
"""
:return: the xlsx report name
"""
raise NotImplementedError()
def _getXlsxReportActionName(self):
"""
:return: the xlsx report action name
"""
raise NotImplementedError()
def _getReportTitle(self):
"""
:return: the report title displayed into the report
"""
raise NotImplementedError()
def _getBaseFilters(self):
"""
:return: the minimum required filters to generate report
"""
raise NotImplementedError()
def _getAdditionalFiltersToBeTested(self):
"""
:return: the additional filters to generate report variants
"""
raise NotImplementedError()

94
account_financial_report/tests/abstract_test_foreign_currency.py

@ -0,0 +1,94 @@
# Copyright 2018 Forest and Biomass Romania
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from . import abstract_test
_logger = logging.getLogger(__name__)
class AbstractTestForeignCurrency(abstract_test.AbstractTest):
"""Common technical tests for all reports."""
def _chart_template_create(self):
super(AbstractTestForeignCurrency, self)._chart_template_create()
# Account for foreign payments
self.account_type_other = self.env["account.account.type"].create(
{"name": "foreign expenses", "type": "other",}
)
act = self.env["account.account.template"].create(
{
"code": "0012",
"name": "Foreign Expenses",
"user_type_id": self.account_type_other.id,
"chart_template_id": self.chart.id,
"currency_id": self.env.ref("base.EUR").id,
}
)
self.env["ir.model.data"].create(
{"res_id": act.id, "model": act._name, "name": "foreign expenses",}
)
return True
def _add_chart_of_accounts(self):
super(AbstractTestForeignCurrency, self)._add_chart_of_accounts()
self.foreign_expense = self.env["account.account"].search(
[("currency_id", "=", self.env.ref("base.EUR").id)], limit=1
)
self.foreign_currency_id = self.foreign_expense.currency_id
return True
def _journals_create(self):
super(AbstractTestForeignCurrency, self)._journals_create()
self.journal_foreign_purchases = self.env["account.journal"].create(
{
"company_id": self.company.id,
"name": "Test journal for purchase",
"type": "purchase",
"code": "TFORPUR",
"default_debit_account_id": self.foreign_expense.id,
"default_credit_account_id": self.foreign_expense.id,
"currency_id": self.foreign_currency_id.id,
}
)
return True
def _invoice_create(self):
super(AbstractTestForeignCurrency, self)._invoice_create()
# vendor bill foreign currency
foreign_vendor_invoice_lines = [
(
0,
False,
{
"name": "Test description #1",
"account_id": self.revenue.id,
"quantity": 1.0,
"price_unit": 100.0,
"currency_id": self.foreign_currency_id.id,
},
),
(
0,
False,
{
"name": "Test description #2",
"account_id": self.revenue.id,
"quantity": 2.0,
"price_unit": 25.0,
"currency_id": self.foreign_currency_id.id,
},
),
]
self.foreign_invoice_in = self.env["account.invoice"].create(
{
"partner_id": self.partner.id,
"type": "in_invoice",
"invoice_line_ids": foreign_vendor_invoice_lines,
"account_id": self.partner.property_account_payable_id.id,
"journal_id": self.journal_foreign_purchases.id,
}
)
self.foreign_invoice_in.action_invoice_open()
return True

89
account_financial_report/tests/abstract_test_tax_report.py

@ -0,0 +1,89 @@
# Copyright 2018 Forest and Biomass Romania
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from odoo.tests.common import TransactionCase
from odoo.tools import test_reports
_logger = logging.getLogger(__name__)
class AbstractTest(TransactionCase):
"""Common technical tests for all reports."""
def setUp(cls):
super(AbstractTest, cls).setUp()
cls.model = cls._getReportModel()
cls.qweb_report_name = cls._getQwebReportName()
cls.xlsx_report_name = cls._getXlsxReportName()
cls.xlsx_action_name = cls._getXlsxReportActionName()
cls.report_title = cls._getReportTitle()
cls.base_filters = cls._getBaseFilters()
cls.report = cls.model.create(cls.base_filters)
cls.report.compute_data_for_report()
def test_html(self):
test_reports.try_report(
self.env.cr,
self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type="qweb-html",
)
def test_qweb(self):
test_reports.try_report(
self.env.cr,
self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type="qweb-pdf",
)
def test_xlsx(self):
test_reports.try_report(
self.env.cr,
self.env.uid,
self.xlsx_report_name,
[self.report.id],
report_type="xlsx",
)
def test_print(self):
self.report.print_report("qweb")
self.report.print_report("xlsx")
def test_generation_report_html(self):
"""Check if report HTML is correctly generated"""
# Check if returned report action is correct
report_type = "qweb-html"
report_action = self.report.print_report(report_type)
self.assertDictContainsSubset(
{
"type": "ir.actions.report",
"report_name": self.qweb_report_name,
"report_type": "qweb-html",
},
report_action,
)
# Check if report template is correct
report = self.env["ir.actions.report"].search(
[
("report_name", "=", self.qweb_report_name),
("report_type", "=", report_type),
],
limit=1,
)
self.assertEqual(report.report_type, "qweb-html")
rep = report.render(self.report.ids, {})
self.assertTrue(self.report_title.encode("utf8") in rep[0])

41
account_financial_report/tests/test_aged_partner_balance.py

@ -0,0 +1,41 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import date
from . import abstract_test
class TestAgedPartnerBalance(abstract_test.AbstractTest):
"""
Technical tests for Aged Partner Balance Report.
"""
def _getReportModel(self):
return self.env["report_aged_partner_balance"]
def _getQwebReportName(self):
return "account_financial_report.report_aged_partner_balance_qweb"
def _getXlsxReportName(self):
return "a_f_r.report_aged_partner_balance_xlsx"
def _getXlsxReportActionName(self):
return "account_financial_report." "action_report_aged_partner_balance_xlsx"
def _getReportTitle(self):
return "Odoo"
def _getBaseFilters(self):
return {
"date_at": date(date.today().year, 12, 31),
"company_id": self.company.id,
}
def _getAdditionalFiltersToBeTested(self):
return [
{"only_posted_moves": True},
{"show_move_line_details": True},
{"only_posted_moves": True, "show_move_line_details": True},
]

608
account_financial_report/tests/test_general_ledger.py

@ -1,14 +1,79 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
from datetime import date
from odoo import api, fields
from odoo import fields
from odoo.tests import common
from . import abstract_test_foreign_currency as a_t_f_c
class TestGeneralLedger(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for General Ledger Report.
"""
def _getReportModel(self):
return self.env["report_general_ledger"]
def _getQwebReportName(self):
return "account_financial_report.report_general_ledger_qweb"
def _getXlsxReportName(self):
return "a_f_r.report_general_ledger_xlsx"
def _getXlsxReportActionName(self):
return "account_financial_report." "action_report_general_ledger_xlsx"
def _getReportTitle(self):
return "Odoo"
def _getBaseFilters(self):
return {
"date_from": date(date.today().year, 1, 1),
"date_to": date(date.today().year, 12, 31),
"company_id": self.company.id,
"fy_start_date": date(date.today().year, 1, 1),
"foreign_currency": True,
}
def _getAdditionalFiltersToBeTested(self):
additional_filters = [
{"only_posted_moves": True},
{"hide_account_at_0": True},
{"centralize": True},
{"only_posted_moves": True, "hide_account_at_0": True},
{"only_posted_moves": True, "centralize": True},
{"hide_account_at_0": True, "centralize": True},
{"only_posted_moves": True, "hide_account_at_0": True, "centralize": True},
]
# Add `show_analytic_tags` filter on each cases
additional_filters_with_show_tags = []
for additional_filter in additional_filters:
additional_filter["show_analytic_tags"] = True
additional_filters_with_show_tags.append(additional_filter)
additional_filters += additional_filters_with_show_tags
# Add `filter_analytic_tag_ids` filter on each cases
analytic_tag = self.env["account.analytic.tag"].create({"name": "TEST tag"})
# Define all move lines on this tag
# (this test just check with the all filters, all works technically)
move_lines = self.env["account.move.line"].search([])
move_lines.write(
{"analytic_tag_ids": [(6, False, analytic_tag.ids)],}
)
additional_filters_with_filter_tags = []
for additional_filter in additional_filters:
additional_filter["filter_analytic_tag_ids"] = [
(6, False, analytic_tag.ids)
]
additional_filters_with_filter_tags.append(additional_filter)
additional_filters += additional_filters_with_filter_tags
return additional_filters
class TestGeneralLedgerReport(common.TransactionCase):
def setUp(self):
@ -18,7 +83,6 @@ class TestGeneralLedgerReport(common.TransactionCase):
self.previous_fy_date_end = fields.Date.from_string("2015-12-31")
self.fy_date_start = fields.Date.from_string("2016-01-01")
self.fy_date_end = fields.Date.from_string("2016-12-31")
self.receivable_account = self.env["account.account"].search(
[("user_type_id.name", "=", "Receivable")], limit=1
)
@ -35,7 +99,6 @@ class TestGeneralLedgerReport(common.TransactionCase):
],
limit=1,
)
self.partner = self.env.ref("base.res_partner_12")
def _add_move(
self,
@ -47,16 +110,19 @@ class TestGeneralLedgerReport(common.TransactionCase):
unaffected_debit=0,
unaffected_credit=0,
):
move_name = "expense accrual"
journal = self.env["account.journal"].search([], limit=1)
partner = self.env.ref("base.res_partner_12")
move_vals = {
"journal_id": journal.id,
"name": move_name,
"date": date,
"line_ids": [
(
0,
0,
{
"name": move_name,
"debit": receivable_debit,
"credit": receivable_credit,
"account_id": self.receivable_account.id,
@ -67,6 +133,7 @@ class TestGeneralLedgerReport(common.TransactionCase):
0,
0,
{
"name": move_name,
"debit": income_debit,
"credit": income_credit,
"account_id": self.income_account.id,
@ -77,6 +144,7 @@ class TestGeneralLedgerReport(common.TransactionCase):
0,
0,
{
"name": move_name,
"debit": unaffected_debit,
"credit": unaffected_credit,
"account_id": self.unaffected_account.id,
@ -89,94 +157,55 @@ class TestGeneralLedgerReport(common.TransactionCase):
move.post()
def _get_report_lines(self, with_partners=False):
centralize = True
if with_partners:
centralize = False
company = self.env.ref("base.main_company")
general_ledger = self.env["general.ledger.report.wizard"].create(
general_ledger = self.env["report_general_ledger"].create(
{
"date_from": self.fy_date_start,
"date_to": self.fy_date_end,
"target_move": "posted",
"only_posted_moves": True,
"hide_account_at_0": False,
"company_id": company.id,
"fy_start_date": self.fy_date_start,
"centralize": centralize,
}
)
data = general_ledger._prepare_report_general_ledger()
res_data = self.env[
"report.account_financial_report.general_ledger"
]._get_report_values(general_ledger, data)
return res_data
@api.model
def check_account_in_report(self, account_id, general_ledger):
account_in_report = False
for account in general_ledger:
if account["id"] == account_id:
account_in_report = True
break
return account_in_report
@api.model
def check_partner_in_report(self, account_id, partner_id, general_ledger):
partner_in_report = False
for account in general_ledger:
if account["id"] == account_id and account["partners"]:
for partner in account["list_partner"]:
if partner["id"] == partner_id:
partner_in_report = True
return partner_in_report
@api.model
def _get_initial_balance(self, account_id, general_ledger):
initial_balance = False
for account in general_ledger:
if account["id"] == account_id:
initial_balance = account["init_bal"]
return initial_balance
@api.model
def _get_partner_initial_balance(self, account_id, partner_id, general_ledger):
initial_balance = False
for account in general_ledger:
if account["id"] == account_id and account["partners"]:
for partner in account["list_partner"]:
if partner["id"] == partner_id:
initial_balance = partner["init_bal"]
return initial_balance
@api.model
def _get_final_balance(self, account_id, general_ledger):
final_balance = False
for account in general_ledger:
if account["id"] == account_id:
final_balance = account["fin_bal"]
return final_balance
@api.model
def _get_partner_final_balance(self, account_id, partner_id, general_ledger):
final_balance = False
for account in general_ledger:
if account["id"] == account_id and account["partners"]:
for partner in account["list_partner"]:
if partner["id"] == partner_id:
final_balance = partner["fin_bal"]
return final_balance
general_ledger.compute_data_for_report(
with_line_details=True, with_partners=with_partners
)
lines = {}
report_account_model = self.env["report_general_ledger_account"]
lines["receivable"] = report_account_model.search(
[
("report_id", "=", general_ledger.id),
("account_id", "=", self.receivable_account.id),
]
)
lines["income"] = report_account_model.search(
[
("report_id", "=", general_ledger.id),
("account_id", "=", self.income_account.id),
]
)
lines["unaffected"] = report_account_model.search(
[
("report_id", "=", general_ledger.id),
("account_id", "=", self.unaffected_account.id),
]
)
if with_partners:
report_partner_model = self.env["report_general_ledger_partner"]
lines["partner_receivable"] = report_partner_model.search(
[
("report_account_id", "=", lines["receivable"].id),
("partner_id", "=", self.env.ref("base.res_partner_12").id),
]
)
return lines
def test_01_account_balance(self):
# Generate the general ledger line
res_data = self._get_report_lines()
general_ledger = res_data["general_ledger"]
check_receivable_account = self.check_account_in_report(
self.receivable_account.id, general_ledger
)
self.assertFalse(check_receivable_account)
check_income_account = self.check_account_in_report(
self.income_account.id, general_ledger
)
self.assertFalse(check_income_account)
lines = self._get_report_lines()
self.assertEqual(len(lines["receivable"]), 0)
self.assertEqual(len(lines["income"]), 0)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@ -189,31 +218,17 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
res_data = self._get_report_lines()
general_ledger = res_data["general_ledger"]
check_receivable_account = self.check_account_in_report(
self.receivable_account.id, general_ledger
)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.income_account.id, general_ledger
)
self.assertFalse(check_income_account)
lines = self._get_report_lines()
self.assertEqual(len(lines["receivable"]), 1)
self.assertEqual(len(lines["income"]), 0)
# Check the initial and final balance
receivable_init_balance = self._get_initial_balance(
self.receivable_account.id, general_ledger
)
receivable_fin_balance = self._get_final_balance(
self.receivable_account.id, general_ledger
)
self.assertEqual(receivable_init_balance["debit"], 1000)
self.assertEqual(receivable_init_balance["credit"], 0)
self.assertEqual(receivable_init_balance["balance"], 1000)
self.assertEqual(receivable_fin_balance["debit"], 1000)
self.assertEqual(receivable_fin_balance["credit"], 0)
self.assertEqual(receivable_fin_balance["balance"], 1000)
self.assertEqual(lines["receivable"].initial_debit, 1000)
self.assertEqual(lines["receivable"].initial_credit, 0)
self.assertEqual(lines["receivable"].initial_balance, 1000)
self.assertEqual(lines["receivable"].final_debit, 1000)
self.assertEqual(lines["receivable"].final_credit, 0)
self.assertEqual(lines["receivable"].final_balance, 1000)
# Add reversale move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@ -227,44 +242,24 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
res_data = self._get_report_lines()
general_ledger = res_data["general_ledger"]
check_receivable_account = self.check_account_in_report(
self.receivable_account.id, general_ledger
)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.income_account.id, general_ledger
)
self.assertTrue(check_income_account)
lines = self._get_report_lines()
self.assertEqual(len(lines["receivable"]), 1)
self.assertEqual(len(lines["income"]), 1)
# Check the initial and final balance
receivable_init_balance = self._get_initial_balance(
self.receivable_account.id, general_ledger
)
receivable_fin_balance = self._get_final_balance(
self.receivable_account.id, general_ledger
)
income_init_balance = self._get_initial_balance(
self.income_account.id, general_ledger
)
income_fin_balance = self._get_final_balance(
self.income_account.id, general_ledger
)
self.assertEqual(receivable_init_balance["debit"], 1000)
self.assertEqual(receivable_init_balance["credit"], 0)
self.assertEqual(receivable_init_balance["balance"], 1000)
self.assertEqual(receivable_fin_balance["debit"], 1000)
self.assertEqual(receivable_fin_balance["credit"], 1000)
self.assertEqual(receivable_fin_balance["balance"], 0)
self.assertEqual(income_init_balance["debit"], 0)
self.assertEqual(income_init_balance["credit"], 0)
self.assertEqual(income_init_balance["balance"], 0)
self.assertEqual(income_fin_balance["debit"], 1000)
self.assertEqual(income_fin_balance["credit"], 0)
self.assertEqual(income_fin_balance["balance"], 1000)
self.assertEqual(lines["receivable"].initial_debit, 1000)
self.assertEqual(lines["receivable"].initial_credit, 0)
self.assertEqual(lines["receivable"].initial_balance, 1000)
self.assertEqual(lines["receivable"].final_debit, 1000)
self.assertEqual(lines["receivable"].final_credit, 1000)
self.assertEqual(lines["receivable"].final_balance, 0)
self.assertEqual(lines["income"].initial_debit, 0)
self.assertEqual(lines["income"].initial_credit, 0)
self.assertEqual(lines["income"].initial_balance, 0)
self.assertEqual(lines["income"].final_debit, 1000)
self.assertEqual(lines["income"].final_credit, 0)
self.assertEqual(lines["income"].final_balance, 1000)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@ -277,53 +272,29 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
res_data = self._get_report_lines()
general_ledger = res_data["general_ledger"]
check_receivable_account = self.check_account_in_report(
self.receivable_account.id, general_ledger
)
self.assertTrue(check_receivable_account)
check_income_account = self.check_account_in_report(
self.income_account.id, general_ledger
)
self.assertTrue(check_income_account)
lines = self._get_report_lines()
self.assertEqual(len(lines["receivable"]), 1)
self.assertEqual(len(lines["income"]), 1)
# Check the initial and final balance
receivable_init_balance = self._get_initial_balance(
self.receivable_account.id, general_ledger
)
receivable_fin_balance = self._get_final_balance(
self.receivable_account.id, general_ledger
)
income_init_balance = self._get_initial_balance(
self.income_account.id, general_ledger
)
income_fin_balance = self._get_final_balance(
self.income_account.id, general_ledger
)
self.assertEqual(receivable_init_balance["debit"], 1000)
self.assertEqual(receivable_init_balance["credit"], 0)
self.assertEqual(receivable_init_balance["balance"], 1000)
self.assertEqual(receivable_fin_balance["debit"], 1000)
self.assertEqual(receivable_fin_balance["credit"], 2000)
self.assertEqual(receivable_fin_balance["balance"], -1000)
self.assertEqual(income_init_balance["debit"], 0)
self.assertEqual(income_init_balance["credit"], 0)
self.assertEqual(income_init_balance["balance"], 0)
self.assertEqual(income_fin_balance["debit"], 2000)
self.assertEqual(income_fin_balance["credit"], 0)
self.assertEqual(income_fin_balance["balance"], 2000)
self.assertEqual(lines["receivable"].initial_debit, 1000)
self.assertEqual(lines["receivable"].initial_credit, 0)
self.assertEqual(lines["receivable"].initial_balance, 1000)
self.assertEqual(lines["receivable"].final_debit, 1000)
self.assertEqual(lines["receivable"].final_credit, 2000)
self.assertEqual(lines["receivable"].final_balance, -1000)
self.assertEqual(lines["income"].initial_debit, 0)
self.assertEqual(lines["income"].initial_credit, 0)
self.assertEqual(lines["income"].initial_balance, 0)
self.assertEqual(lines["income"].final_debit, 2000)
self.assertEqual(lines["income"].final_credit, 0)
self.assertEqual(lines["income"].final_balance, 2000)
def test_02_partner_balance(self):
# Generate the general ledger line
res_data = self._get_report_lines(with_partners=True)
general_ledger = res_data["general_ledger"]
check_partner = self.check_partner_in_report(
self.receivable_account.id, self.partner.id, general_ledger
)
self.assertFalse(check_partner)
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines["partner_receivable"]), 0)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@ -336,27 +307,16 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
res_data = self._get_report_lines(with_partners=True)
general_ledger = res_data["general_ledger"]
check_partner = self.check_partner_in_report(
self.receivable_account.id, self.partner.id, general_ledger
)
self.assertTrue(check_partner)
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines["partner_receivable"]), 1)
# Check the initial and final balance
partner_initial_balance = self._get_partner_initial_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
partner_final_balance = self._get_partner_final_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
self.assertEqual(partner_initial_balance["debit"], 1000)
self.assertEqual(partner_initial_balance["credit"], 0)
self.assertEqual(partner_initial_balance["balance"], 1000)
self.assertEqual(partner_final_balance["debit"], 1000)
self.assertEqual(partner_final_balance["credit"], 0)
self.assertEqual(partner_final_balance["balance"], 1000)
self.assertEqual(lines["partner_receivable"].initial_debit, 1000)
self.assertEqual(lines["partner_receivable"].initial_credit, 0)
self.assertEqual(lines["partner_receivable"].initial_balance, 1000)
self.assertEqual(lines["partner_receivable"].final_debit, 1000)
self.assertEqual(lines["partner_receivable"].final_credit, 0)
self.assertEqual(lines["partner_receivable"].final_balance, 1000)
# Add reversale move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@ -370,27 +330,16 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
res_data = self._get_report_lines(with_partners=True)
general_ledger = res_data["general_ledger"]
check_partner = self.check_partner_in_report(
self.receivable_account.id, self.partner.id, general_ledger
)
self.assertTrue(check_partner)
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines["partner_receivable"]), 1)
# Check the initial and final balance
partner_initial_balance = self._get_partner_initial_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
partner_final_balance = self._get_partner_final_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
self.assertEqual(partner_initial_balance["debit"], 1000)
self.assertEqual(partner_initial_balance["credit"], 0)
self.assertEqual(partner_initial_balance["balance"], 1000)
self.assertEqual(partner_final_balance["debit"], 1000)
self.assertEqual(partner_final_balance["credit"], 1000)
self.assertEqual(partner_final_balance["balance"], 0)
self.assertEqual(lines["partner_receivable"].initial_debit, 1000)
self.assertEqual(lines["partner_receivable"].initial_credit, 0)
self.assertEqual(lines["partner_receivable"].initial_balance, 1000)
self.assertEqual(lines["partner_receivable"].final_debit, 1000)
self.assertEqual(lines["partner_receivable"].final_credit, 1000)
self.assertEqual(lines["partner_receivable"].final_balance, 0)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@ -403,51 +352,29 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
res_data = self._get_report_lines(with_partners=True)
general_ledger = res_data["general_ledger"]
check_partner = self.check_partner_in_report(
self.receivable_account.id, self.partner.id, general_ledger
)
self.assertTrue(check_partner)
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines["partner_receivable"]), 1)
# Check the initial and final balance
partner_initial_balance = self._get_partner_initial_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
partner_final_balance = self._get_partner_final_balance(
self.receivable_account.id, self.partner.id, general_ledger
)
self.assertEqual(partner_initial_balance["debit"], 1000)
self.assertEqual(partner_initial_balance["credit"], 0)
self.assertEqual(partner_initial_balance["balance"], 1000)
self.assertEqual(partner_final_balance["debit"], 1000)
self.assertEqual(partner_final_balance["credit"], 2000)
self.assertEqual(partner_final_balance["balance"], -1000)
self.assertEqual(lines["partner_receivable"].initial_debit, 1000)
self.assertEqual(lines["partner_receivable"].initial_credit, 0)
self.assertEqual(lines["partner_receivable"].initial_balance, 1000)
self.assertEqual(lines["partner_receivable"].final_debit, 1000)
self.assertEqual(lines["partner_receivable"].final_credit, 2000)
self.assertEqual(lines["partner_receivable"].final_balance, -1000)
def test_03_unaffected_account_balance(self):
# Generate the general ledger line
res_data = self._get_report_lines()
general_ledger = res_data["general_ledger"]
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger
)
self.assertTrue(check_unaffected_account)
lines = self._get_report_lines()
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger
)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger
)
self.assertEqual(unaffected_init_balance["debit"], 0)
self.assertEqual(unaffected_init_balance["credit"], 0)
self.assertEqual(unaffected_init_balance["balance"], 0)
self.assertEqual(unaffected_fin_balance["debit"], 0)
self.assertEqual(unaffected_fin_balance["credit"], 0)
self.assertEqual(unaffected_fin_balance["balance"], 0)
self.assertEqual(lines["unaffected"].initial_debit, 0)
self.assertEqual(lines["unaffected"].initial_credit, 0)
self.assertEqual(lines["unaffected"].initial_balance, 0)
self.assertEqual(lines["unaffected"].final_debit, 0)
self.assertEqual(lines["unaffected"].final_credit, 0)
self.assertEqual(lines["unaffected"].final_balance, 0)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@ -460,27 +387,16 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
res_data = self._get_report_lines()
general_ledger = res_data["general_ledger"]
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger
)
self.assertTrue(check_unaffected_account)
lines = self._get_report_lines()
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger
)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger
)
self.assertEqual(unaffected_init_balance["debit"], 0)
self.assertEqual(unaffected_init_balance["credit"], 1000)
self.assertEqual(unaffected_init_balance["balance"], -1000)
self.assertEqual(unaffected_fin_balance["debit"], 0)
self.assertEqual(unaffected_fin_balance["credit"], 1000)
self.assertEqual(unaffected_fin_balance["balance"], -1000)
self.assertEqual(lines["unaffected"].initial_debit, 0)
self.assertEqual(lines["unaffected"].initial_credit, 1000)
self.assertEqual(lines["unaffected"].initial_balance, -1000)
self.assertEqual(lines["unaffected"].final_debit, 0)
self.assertEqual(lines["unaffected"].final_credit, 1000)
self.assertEqual(lines["unaffected"].final_balance, -1000)
# Add reversale move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@ -496,27 +412,16 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
res_data = self._get_report_lines()
general_ledger = res_data["general_ledger"]
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger
)
self.assertTrue(check_unaffected_account)
lines = self._get_report_lines()
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger
)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger
)
self.assertEqual(unaffected_init_balance["debit"], 0)
self.assertEqual(unaffected_init_balance["credit"], 1000)
self.assertEqual(unaffected_init_balance["balance"], -1000)
self.assertEqual(unaffected_fin_balance["debit"], 1000)
self.assertEqual(unaffected_fin_balance["credit"], 1000)
self.assertEqual(unaffected_fin_balance["balance"], 0)
self.assertEqual(lines["unaffected"].initial_debit, 0)
self.assertEqual(lines["unaffected"].initial_credit, 1000)
self.assertEqual(lines["unaffected"].initial_balance, -1000)
self.assertEqual(lines["unaffected"].final_debit, 1000)
self.assertEqual(lines["unaffected"].final_credit, 1000)
self.assertEqual(lines["unaffected"].final_balance, 0)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@ -531,51 +436,29 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
res_data = self._get_report_lines()
general_ledger = res_data["general_ledger"]
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger
)
self.assertTrue(check_unaffected_account)
lines = self._get_report_lines()
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger
)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger
)
self.assertEqual(unaffected_init_balance["debit"], 0)
self.assertEqual(unaffected_init_balance["credit"], 1000)
self.assertEqual(unaffected_init_balance["balance"], -1000)
self.assertEqual(unaffected_fin_balance["debit"], 1000)
self.assertEqual(unaffected_fin_balance["credit"], 4000)
self.assertEqual(unaffected_fin_balance["balance"], -3000)
self.assertEqual(lines["unaffected"].initial_debit, 0)
self.assertEqual(lines["unaffected"].initial_credit, 1000)
self.assertEqual(lines["unaffected"].initial_balance, -1000)
self.assertEqual(lines["unaffected"].final_debit, 1000)
self.assertEqual(lines["unaffected"].final_credit, 4000)
self.assertEqual(lines["unaffected"].final_balance, -3000)
def test_04_unaffected_account_balance_2_years(self):
# Generate the general ledger line
res_data = self._get_report_lines()
general_ledger = res_data["general_ledger"]
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger
)
self.assertTrue(check_unaffected_account)
lines = self._get_report_lines()
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger
)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger
)
self.assertEqual(unaffected_init_balance["debit"], 0)
self.assertEqual(unaffected_init_balance["credit"], 0)
self.assertEqual(unaffected_init_balance["balance"], 0)
self.assertEqual(unaffected_fin_balance["debit"], 0)
self.assertEqual(unaffected_fin_balance["credit"], 0)
self.assertEqual(unaffected_fin_balance["balance"], 0)
self.assertEqual(lines["unaffected"].initial_debit, 0)
self.assertEqual(lines["unaffected"].initial_credit, 0)
self.assertEqual(lines["unaffected"].initial_balance, 0)
self.assertEqual(lines["unaffected"].final_debit, 0)
self.assertEqual(lines["unaffected"].final_credit, 0)
self.assertEqual(lines["unaffected"].final_balance, 0)
# Add a move at any date 2 years before the balance
# (to create an historic)
@ -588,27 +471,16 @@ class TestGeneralLedgerReport(common.TransactionCase):
)
# Re Generate the general ledger line
res_data = self._get_report_lines()
general_ledger = res_data["general_ledger"]
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger
)
self.assertTrue(check_unaffected_account)
lines = self._get_report_lines()
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger
)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger
)
self.assertEqual(unaffected_init_balance["debit"], 1000)
self.assertEqual(unaffected_init_balance["credit"], 0)
self.assertEqual(unaffected_init_balance["balance"], 1000)
self.assertEqual(unaffected_fin_balance["debit"], 1000)
self.assertEqual(unaffected_fin_balance["credit"], 0)
self.assertEqual(unaffected_fin_balance["balance"], 1000)
self.assertEqual(lines["unaffected"].initial_debit, 1000)
self.assertEqual(lines["unaffected"].initial_credit, 0)
self.assertEqual(lines["unaffected"].initial_balance, 1000)
self.assertEqual(lines["unaffected"].final_debit, 1000)
self.assertEqual(lines["unaffected"].final_credit, 0)
self.assertEqual(lines["unaffected"].final_balance, 1000)
# Affect the company's result last year
self._add_move(
@ -631,29 +503,17 @@ class TestGeneralLedgerReport(common.TransactionCase):
unaffected_debit=0,
unaffected_credit=0,
)
# Re Generate the general ledger line
res_data = self._get_report_lines()
general_ledger = res_data["general_ledger"]
check_unaffected_account = self.check_account_in_report(
self.unaffected_account.id, general_ledger
)
self.assertTrue(check_unaffected_account)
lines = self._get_report_lines()
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
unaffected_init_balance = self._get_initial_balance(
self.unaffected_account.id, general_ledger
)
unaffected_fin_balance = self._get_final_balance(
self.unaffected_account.id, general_ledger
)
self.assertEqual(unaffected_init_balance["debit"], 1500)
self.assertEqual(unaffected_init_balance["credit"], 1000)
self.assertEqual(unaffected_init_balance["balance"], 500)
self.assertEqual(unaffected_fin_balance["debit"], 1500)
self.assertEqual(unaffected_fin_balance["credit"], 1000)
self.assertEqual(unaffected_fin_balance["balance"], 500)
self.assertEqual(lines["unaffected"].initial_debit, 500)
self.assertEqual(lines["unaffected"].initial_credit, 0)
self.assertEqual(lines["unaffected"].initial_balance, 500)
self.assertEqual(lines["unaffected"].final_debit, 500)
self.assertEqual(lines["unaffected"].final_credit, 0)
self.assertEqual(lines["unaffected"].final_balance, 500)
def test_partner_filter(self):
partner_1 = self.env.ref("base.res_partner_1")
@ -674,7 +534,9 @@ class TestGeneralLedgerReport(common.TransactionCase):
def test_validate_date(self):
company_id = self.env.ref("base.main_company")
company_id.write({"fiscalyear_last_day": 31, "fiscalyear_last_month": "12"})
company_id.write(
{"fiscalyear_last_day": 31, "fiscalyear_last_month": 12,}
)
user = self.env.ref("base.user_root").with_context(company_id=company_id.id)
wizard = self.env["general.ledger.report.wizard"].with_context(user=user.id)
self.assertEqual(wizard._init_date_from(), time.strftime("%Y") + "-01-01")

366
account_financial_report/tests/test_journal_ledger.py

@ -1,31 +1,101 @@
# Copyright 2017 ACSONE SA/NV
# Copyright 2019-20 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import datetime
from datetime import date, datetime
from dateutil.relativedelta import relativedelta
from odoo.fields import Date
from odoo.tests.common import Form, TransactionCase
from odoo.tests.common import TransactionCase
from . import abstract_test_foreign_currency as a_t_f_c
class TestJournalLedger(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for General Ledger Report.
"""
def _getReportModel(self):
return self.env["report_journal_ledger"]
def _getQwebReportName(self):
return "account_financial_report.report_journal_ledger_qweb"
def _getXlsxReportName(self):
return "a_f_r.report_journal_ledger_xlsx"
def _getXlsxReportActionName(self):
return "account_financial_report." "action_report_journal_ledger_xlsx"
def _getReportTitle(self):
return "Odoo"
def _getBaseFilters(self):
return {
"date_from": date(date.today().year, 1, 1),
"date_to": date(date.today().year, 12, 31),
"company_id": self.company.id,
"journal_ids": [(6, 0, self.journal_sale.ids)],
}
def _getAdditionalFiltersToBeTested(self):
return [
{
"move_target": "All",
"sort_option": "Date",
"group_option": "Journal",
"with_account_name": True,
"foreign_currency": True,
},
]
def test_02_generation_report_html(self):
"""Check if report HTML is correctly generated"""
# Check if returned report action is correct
report_type = "qweb-html"
report_action = self.report.print_report(report_type)
self.assertDictContainsSubset(
{
"type": "ir.actions.report",
"report_name": self.qweb_report_name,
"report_type": "qweb-html",
},
report_action,
)
# Check if report template is correct
report = self.env["ir.actions.report"].search(
[
("report_name", "=", self.qweb_report_name),
("report_type", "=", report_type),
],
limit=1,
)
self.assertEqual(report.report_type, "qweb-html")
rep = report.render(self.report.ids, {})
self.assertTrue(self.report_title.encode("utf8") in rep[0])
self.assertTrue(self.report.journal_ids[0].name.encode("utf8") in rep[0])
def test_04_compute_data(self):
return True
class TestJournalReport(TransactionCase):
def setUp(self):
super(TestJournalReport, self).setUp()
self.AccountObj = self.env["account.account"]
self.InvoiceObj = self.env["account.move"]
self.InvoiceObj = self.env["account.invoice"]
self.JournalObj = self.env["account.journal"]
self.JournalReportObj = self.env["journal.ledger.report.wizard"]
self.MoveObj = self.env["account.move"]
self.ReportJournalLedger = self.env["report_journal_ledger"]
self.TaxObj = self.env["account.tax"]
self.JournalLedgerReportWizard = self.env["journal.ledger.report.wizard"]
self.JournalLedgerReport = self.env[
"report.account_financial_report.journal_ledger"
]
self.company = self.env.ref("base.main_company")
self.company.account_sale_tax_id = False
self.company.account_purchase_tax_id = False
today = datetime.today()
last_year = today - relativedelta(years=1)
@ -41,9 +111,6 @@ class TestJournalReport(TransactionCase):
self.income_account = self.AccountObj.search(
[("user_type_id.name", "=", "Income")], limit=1
)
self.expense_account = self.AccountObj.search(
[("user_type_id.name", "=", "Expenses")], limit=1
)
self.payable_account = self.AccountObj.search(
[("user_type_id.name", "=", "Payable")], limit=1
)
@ -60,7 +127,7 @@ class TestJournalReport(TransactionCase):
{
"name": "Test journal purchase",
"code": "TST-JRNL-P",
"type": "purchase",
"type": "sale",
"company_id": self.company.id,
}
)
@ -150,41 +217,63 @@ class TestJournalReport(TransactionCase):
return self.MoveObj.create(move_vals)
def check_report_journal_debit_credit(
self, res_data, expected_debit, expected_credit
self, report, expected_debit, expected_credit
):
self.assertEqual(
expected_debit, sum([rec["debit"] for rec in res_data["Journal_Ledgers"]])
expected_debit,
sum([journal.debit for journal in report.report_journal_ledger_ids]),
)
self.assertEqual(
expected_credit, sum([rec["credit"] for rec in res_data["Journal_Ledgers"]])
expected_credit,
sum([journal.credit for journal in report.report_journal_ledger_ids]),
)
def check_report_journal_debit_credit_taxes(
self,
res_data,
report,
expected_base_debit,
expected_base_credit,
expected_tax_debit,
expected_tax_credit,
):
for rec in res_data["Journal_Ledgers"]:
self.assertEqual(
expected_base_debit,
sum([tax_line["base_debit"] for tax_line in rec["tax_lines"]]),
)
self.assertEqual(
expected_base_credit,
sum([tax_line["base_credit"] for tax_line in rec["tax_lines"]]),
)
self.assertEqual(
expected_tax_debit,
sum([tax_line["tax_debit"] for tax_line in rec["tax_lines"]]),
)
self.assertEqual(
expected_tax_credit,
sum([tax_line["tax_credit"] for tax_line in rec["tax_lines"]]),
)
self.assertEqual(
expected_base_debit,
sum(
[
journal.base_debit
for journal in report.report_journal_ledger_tax_line_ids
]
),
)
self.assertEqual(
expected_base_credit,
sum(
[
journal.base_credit
for journal in report.report_journal_ledger_tax_line_ids
]
),
)
self.assertEqual(
expected_tax_debit,
sum(
[
journal.tax_debit
for journal in report.report_journal_ledger_tax_line_ids
]
),
)
self.assertEqual(
expected_tax_credit,
sum(
[
journal.tax_credit
for journal in report.report_journal_ledger_tax_line_ids
]
),
)
def test_01_test_total(self):
today_date = Date.today()
@ -193,148 +282,135 @@ class TestJournalReport(TransactionCase):
move1 = self._add_move(today_date, self.journal_sale, 0, 100, 100, 0)
move2 = self._add_move(last_year_date, self.journal_sale, 0, 100, 100, 0)
wiz = self.JournalLedgerReportWizard.create(
report = self.ReportJournalLedger.create(
{
"date_from": self.fy_date_start,
"date_to": self.fy_date_end,
"company_id": self.company.id,
"journal_ids": [(6, 0, self.journal_sale.ids)],
"move_target": "all",
}
)
data = wiz._prepare_report_journal_ledger()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 100, 100)
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 100, 100)
move3 = self._add_move(today_date, self.journal_sale, 0, 100, 100, 0)
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 200, 200)
wiz.move_target = "posted"
data = wiz._prepare_report_journal_ledger()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 0, 0)
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 200, 200)
report.move_target = "posted"
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 0, 0)
move1.post()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 100, 100)
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 100, 100)
move2.post()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 100, 100)
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 100, 100)
move3.post()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 200, 200)
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 200, 200)
wiz.date_from = self.previous_fy_date_start
data = wiz._prepare_report_journal_ledger()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 300, 300)
report.date_from = self.previous_fy_date_start
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 300, 300)
def test_02_test_taxes_out_invoice(self):
move_form = Form(
self.env["account.move"].with_context(default_type="out_invoice")
)
move_form.partner_id = self.partner_2
move_form.journal_id = self.journal_sale
with move_form.invoice_line_ids.new() as line_form:
line_form.name = "test"
line_form.quantity = 1.0
line_form.price_unit = 100
line_form.account_id = self.income_account
line_form.tax_ids.add(self.tax_15_s)
with move_form.invoice_line_ids.new() as line_form:
line_form.name = "test"
line_form.quantity = 1.0
line_form.price_unit = 100
line_form.account_id = self.income_account
line_form.tax_ids.add(self.tax_15_s)
line_form.tax_ids.add(self.tax_20_s)
invoice = move_form.save()
invoice.post()
wiz = self.JournalLedgerReportWizard.create(
invoice_values = {
"journal_id": self.journal_sale.id,
"partner_id": self.partner_2.id,
"type": "out_invoice",
"invoice_line_ids": [
(
0,
0,
{
"quantity": 1.0,
"price_unit": 100,
"account_id": self.receivable_account.id,
"name": "Test",
"invoice_line_tax_ids": [(6, 0, [self.tax_15_s.id])],
},
),
(
0,
0,
{
"quantity": 1.0,
"price_unit": 100,
"account_id": self.receivable_account.id,
"name": "Test",
"invoice_line_tax_ids": [
(6, 0, [self.tax_15_s.id, self.tax_20_s.id])
],
},
),
],
}
invoice = self.InvoiceObj.create(invoice_values)
invoice.action_invoice_open()
report = self.ReportJournalLedger.create(
{
"date_from": self.fy_date_start,
"date_to": self.fy_date_end,
"company_id": self.company.id,
"journal_ids": [(6, 0, self.journal_sale.ids)],
"move_target": "all",
}
)
data = wiz._prepare_report_journal_ledger()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 250, 250)
self.check_report_journal_debit_credit_taxes(res_data, 0, 300, 0, 50)
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 250, 250)
self.check_report_journal_debit_credit_taxes(report, 0, 300, 0, 50)
def test_03_test_taxes_in_invoice(self):
# invoice_values = {
# "journal_id": self.journal_purchase.id,
# "partner_id": self.partner_2.id,
# "type": "in_invoice",
# "invoice_line_ids": [
# (
# 0,
# 0,
# {
# "quantity": 1.0,
# "price_unit": 100,
# "account_id": self.payable_account.id,
# "name": "Test",
# "tax_ids": [(6, 0, [self.tax_15_p.id])],
# },
# ),
# (
# 0,
# 0,
# {
# "quantity": 1.0,
# "price_unit": 100,
# "account_id": self.payable_account.id,
# "name": "Test",
# "tax_ids": [
# (6, 0, [self.tax_15_p.id, self.tax_20_p.id])
# ],
# },
# ),
# ],
# }
# invoice = self.InvoiceObj.create(invoice_values)
# invoice.post()
move_form = Form(
self.env["account.move"].with_context(default_type="in_invoice")
)
move_form.partner_id = self.partner_2
move_form.journal_id = self.journal_purchase
with move_form.invoice_line_ids.new() as line_form:
line_form.name = "test"
line_form.quantity = 1.0
line_form.price_unit = 100
line_form.account_id = self.expense_account
line_form.tax_ids.add(self.tax_15_p)
with move_form.invoice_line_ids.new() as line_form:
line_form.name = "test"
line_form.quantity = 1.0
line_form.price_unit = 100
line_form.account_id = self.expense_account
line_form.tax_ids.add(self.tax_15_p)
line_form.tax_ids.add(self.tax_20_p)
invoice = move_form.save()
invoice.post()
wiz = self.JournalLedgerReportWizard.create(
invoice_values = {
"journal_id": self.journal_sale.id,
"partner_id": self.partner_2.id,
"type": "in_invoice",
"invoice_line_ids": [
(
0,
0,
{
"quantity": 1.0,
"price_unit": 100,
"account_id": self.payable_account.id,
"name": "Test",
"invoice_line_tax_ids": [(6, 0, [self.tax_15_p.id])],
},
),
(
0,
0,
{
"quantity": 1.0,
"price_unit": 100,
"account_id": self.payable_account.id,
"name": "Test",
"invoice_line_tax_ids": [
(6, 0, [self.tax_15_p.id, self.tax_20_p.id])
],
},
),
],
}
invoice = self.InvoiceObj.create(invoice_values)
invoice.action_invoice_open()
report = self.ReportJournalLedger.create(
{
"date_from": self.fy_date_start,
"date_to": self.fy_date_end,
"company_id": self.company.id,
"journal_ids": [(6, 0, self.journal_purchase.ids)],
"move_target": "all",
"journal_ids": [(6, 0, self.journal_sale.ids)],
}
)
data = wiz._prepare_report_journal_ledger()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
report.compute_data_for_report()
self.check_report_journal_debit_credit(res_data, 250, 250)
self.check_report_journal_debit_credit_taxes(res_data, 300, 0, 50, 0)
self.check_report_journal_debit_credit(report, 250, 250)
self.check_report_journal_debit_credit_taxes(report, 300, 0, 50, 0)

39
account_financial_report/tests/test_open_items.py

@ -2,10 +2,45 @@
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
from datetime import date
from . import abstract_test_foreign_currency as a_t_f_c
class TestOpenItems(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for Open Items Report.
"""
def _getReportModel(self):
return self.env["report_open_items"]
def _getQwebReportName(self):
return "account_financial_report.report_open_items_qweb"
def _getXlsxReportName(self):
return "a_f_r.report_open_items_xlsx"
def _getXlsxReportActionName(self):
return "account_financial_report.action_report_open_items_xlsx"
def _getReportTitle(self):
return "Odoo"
def _getBaseFilters(self):
return {
"date_at": date(date.today().year, 12, 31),
"company_id": self.company.id,
"foreign_currency": True,
}
def _getAdditionalFiltersToBeTested(self):
return [
{"only_posted_moves": True},
{"hide_account_at_0": True},
{"only_posted_moves": True, "hide_account_at_0": True},
]
class TestOpenItems(TransactionCase):
def test_partner_filter(self):
partner_1 = self.env.ref("base.res_partner_1")
partner_2 = self.env.ref("base.res_partner_2")

770
account_financial_report/tests/test_trial_balance.py
File diff suppressed because it is too large
View File

410
account_financial_report/tests/test_vat_report.py

@ -1,5 +1,4 @@
# Copyright 2018 Forest and Biomass Romania
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
@ -7,6 +6,45 @@ from datetime import date
from odoo.tests import common
from . import abstract_test_tax_report
class TestVAT(abstract_test_tax_report.AbstractTest):
"""
Technical tests for VAT Report.
"""
def _getReportModel(self):
return self.env["report_vat_report"]
def _getQwebReportName(self):
return "account_financial_report.report_vat_report_qweb"
def _getXlsxReportName(self):
return "a_f_r.report_vat_report_xlsx"
def _getXlsxReportActionName(self):
return "account_financial_report.action_report_vat_report_xlsx"
def _getReportTitle(self):
return "Odoo"
def _getBaseFilters(self):
return {
"date_from": date(date.today().year, 1, 1),
"date_to": date(date.today().year, 12, 31),
"company_id": self.env.company.id,
}
def _getAdditionalFiltersToBeTested(self):
return [
{"based_on": "taxtags"},
{"based_on": "taxgroups"},
{"tax_details": True},
{"based_on": "taxtags", "tax_details": True},
{"based_on": "taxgroups", "tax_details": True},
]
class TestVATReport(common.TransactionCase):
def setUp(self):
@ -45,25 +83,13 @@ class TestVATReport(common.TransactionCase):
[("type", "=", "bank"), ("company_id", "=", self.company.id)], limit=1
)
self.tax_tag_01 = self.env["account.account.tag"].create(
{
"name": "Tag 01",
"applicability": "taxes",
"country_id": self.company.country_id.id,
}
{"name": "Tag 01", "applicability": "taxes"}
)
self.tax_tag_02 = self.env["account.account.tag"].create(
{
"name": "Tag 02",
"applicability": "taxes",
"country_id": self.company.country_id.id,
}
{"name": "Tag 02", "applicability": "taxes"}
)
self.tax_tag_03 = self.env["account.account.tag"].create(
{
"name": "Tag 03",
"applicability": "taxes",
"country_id": self.company.country_id.id,
}
{"name": "Tag 03", "applicability": "taxes"}
)
self.tax_group_10 = self.env["account.tax.group"].create(
{"name": "Tax 10%", "sequence": 1}
@ -77,35 +103,11 @@ class TestVATReport(common.TransactionCase):
"amount": 10.0,
"amount_type": "percent",
"type_tax_use": "sale",
"account_id": self.tax_account.id,
"company_id": self.company.id,
"refund_account_id": self.tax_account.id,
"tax_group_id": self.tax_group_10.id,
"invoice_repartition_line_ids": [
(0, 0, {"factor_percent": 100, "repartition_type": "base"}),
(
0,
0,
{
"factor_percent": 100,
"repartition_type": "tax",
"account_id": self.tax_account.id,
"tag_ids": [
(6, 0, [self.tax_tag_01.id, self.tax_tag_02.id])
],
},
),
],
"refund_repartition_line_ids": [
(0, 0, {"factor_percent": 100, "repartition_type": "base"}),
(
0,
0,
{
"factor_percent": 100,
"repartition_type": "tax",
"account_id": self.tax_account.id,
},
),
],
"tag_ids": [(6, 0, [self.tax_tag_01.id, self.tax_tag_02.id])],
}
)
self.tax_20 = self.env["account.tax"].create(
@ -115,203 +117,177 @@ class TestVATReport(common.TransactionCase):
"amount": 20.0,
"amount_type": "percent",
"type_tax_use": "sale",
"tax_exigibility": "on_payment",
"account_id": self.tax_account.id,
"company_id": self.company.id,
"cash_basis_transition_account_id": self.tax_account.id,
"refund_account_id": self.tax_account.id,
"cash_basis_account_id": self.tax_account.id,
"tax_group_id": self.tax_group_20.id,
"invoice_repartition_line_ids": [
(0, 0, {"factor_percent": 100, "repartition_type": "base"}),
(
0,
0,
{
"factor_percent": 100,
"repartition_type": "tax",
"account_id": self.tax_account.id,
"tag_ids": [
(6, 0, [self.tax_tag_02.id, self.tax_tag_03.id])
],
},
),
],
"refund_repartition_line_ids": [
(0, 0, {"factor_percent": 100, "repartition_type": "base"}),
(
0,
0,
{
"factor_percent": 100,
"repartition_type": "tax",
"account_id": self.tax_account.id,
},
),
],
"tag_ids": [(6, 0, [self.tax_tag_02.id, self.tax_tag_03.id])],
}
)
move_form = common.Form(
self.env["account.move"].with_context(default_type="out_invoice")
)
move_form.partner_id = self.env.ref("base.res_partner_2")
move_form.invoice_date = time.strftime("%Y-%m-03")
with move_form.invoice_line_ids.new() as line_form:
line_form.product_id = self.env.ref("product.product_product_4")
line_form.quantity = 1.0
line_form.price_unit = 100.0
line_form.account_id = self.income_account
line_form.tax_ids.add(self.tax_10)
invoice = move_form.save()
invoice.post()
invoice = self.env["account.invoice"].create(
{
"partner_id": self.env.ref("base.res_partner_2").id,
"account_id": self.receivable_account.id,
"company_id": self.company.id,
"date_invoice": time.strftime("%Y-%m-03"),
"type": "out_invoice",
}
)
self.env["account.invoice.line"].create(
{
"product_id": self.env.ref("product.product_product_4").id,
"quantity": 1.0,
"price_unit": 100.0,
"invoice_id": invoice.id,
"name": "product",
"account_id": self.income_account.id,
"invoice_line_tax_ids": [(6, 0, [self.tax_10.id])],
}
)
invoice.compute_taxes()
invoice.action_invoice_open()
self.cbinvoice = self.env["account.invoice"].create(
{
"partner_id": self.env.ref("base.res_partner_2").id,
"account_id": self.receivable_account.id,
"company_id": self.company.id,
"date_invoice": time.strftime("%Y-%m-05"),
"type": "out_invoice",
}
)
move_form = common.Form(
self.env["account.move"].with_context(default_type="out_invoice")
)
move_form.partner_id = self.env.ref("base.res_partner_2")
move_form.invoice_date = time.strftime("%Y-%m-04")
with move_form.invoice_line_ids.new() as line_form:
line_form.product_id = self.env.ref("product.product_product_4")
line_form.quantity = 1.0
line_form.price_unit = 250.0
line_form.account_id = self.income_account
line_form.tax_ids.add(self.tax_20)
invoice = move_form.save()
invoice.post()
self.env["account.invoice.line"].create(
{
"product_id": self.env.ref("product.product_product_4").id,
"quantity": 1.0,
"price_unit": 500.0,
"invoice_id": self.cbinvoice.id,
"name": "product",
"account_id": self.income_account.id,
"invoice_line_tax_ids": [(6, 0, [self.tax_20.id])],
}
)
self.cbinvoice.compute_taxes()
self.cbinvoice.action_invoice_open()
def _get_report_lines(self, taxgroups=False):
based_on = "taxtags"
if taxgroups:
based_on = "taxgroups"
vat_report = self.env["vat.report.wizard"].create(
def _get_report_lines(self):
self.cbinvoice.pay_and_reconcile(
self.bank_journal.id, 300, date(date.today().year, date.today().month, 10)
)
vat_report = self.env["report_vat_report"].create(
{
"date_from": self.date_from,
"date_to": self.date_to,
"company_id": self.company.id,
"based_on": based_on,
"based_on": "taxtags",
"tax_detail": True,
}
)
data = vat_report._prepare_vat_report()
res_data = self.env[
"report.account_financial_report.vat_report"
]._get_report_values(vat_report, data)
return res_data
def check_tag_or_group_in_report(self, tag_or_group_name, vat_report):
tag_or_group_in_report = False
for tag_or_group in vat_report:
if tag_or_group["name"] == tag_or_group_name:
tag_or_group_in_report = True
break
return tag_or_group_in_report
def check_tax_in_report(self, tax_name, vat_report):
tax_in_report = False
for tag_or_group in vat_report:
if tag_or_group["taxes"]:
for tax in tag_or_group["taxes"]:
if tax["name"] == tax_name:
tax_in_report = True
return tax_in_report
def _get_tag_or_group_line(self, tag_or_group_name, vat_report):
tag_or_group_net = False
tag_or_group_tax = False
for tag_or_group in vat_report:
if tag_or_group["name"] == tag_or_group_name:
tag_or_group_net = tag_or_group["net"]
tag_or_group_tax = tag_or_group["tax"]
return tag_or_group_net, tag_or_group_tax
def _get_tax_line(self, tax_name, vat_report):
tax_net = False
tax_tax = False
for tag_or_group in vat_report:
if tag_or_group["taxes"]:
for tax in tag_or_group["taxes"]:
if tax["name"] == tax_name:
tax_net = tax["net"]
tax_tax = tax["tax"]
return tax_net, tax_tax
vat_report.compute_data_for_report()
lines = {}
vat_taxtag_model = self.env["report_vat_report_taxtag"]
lines["tag_01"] = vat_taxtag_model.search(
[("report_id", "=", vat_report.id), ("taxtag_id", "=", self.tax_tag_01.id),]
)
lines["tag_02"] = vat_taxtag_model.search(
[("report_id", "=", vat_report.id), ("taxtag_id", "=", self.tax_tag_02.id),]
)
lines["tag_03"] = vat_taxtag_model.search(
[("report_id", "=", vat_report.id), ("taxtag_id", "=", self.tax_tag_03.id),]
)
vat_tax_model = self.env["report_vat_report_tax"]
lines["tax_10"] = vat_tax_model.search(
[
("report_tax_id", "=", lines["tag_02"].id),
("tax_id", "=", self.tax_10.id),
]
)
lines["tax_20"] = vat_tax_model.search(
[
("report_tax_id", "=", lines["tag_02"].id),
("tax_id", "=", self.tax_20.id),
]
)
vat_report["based_on"] = "taxgroups"
vat_report.compute_data_for_report()
lines["group_10"] = vat_taxtag_model.search(
[
("report_id", "=", vat_report.id),
("taxgroup_id", "=", self.tax_group_10.id),
]
)
lines["group_20"] = vat_taxtag_model.search(
[
("report_id", "=", vat_report.id),
("taxgroup_id", "=", self.tax_group_20.id),
]
)
vat_tax_model = self.env["report_vat_report_tax"]
lines["tax_group_10"] = vat_tax_model.search(
[
("report_tax_id", "=", lines["group_10"].id),
("tax_id", "=", self.tax_10.id),
]
)
lines["tax_group_20"] = vat_tax_model.search(
[
("report_tax_id", "=", lines["group_20"].id),
("tax_id", "=", self.tax_20.id),
]
)
return lines
def test_01_compute(self):
# Generate the vat lines
res_data = self._get_report_lines()
vat_report = res_data["vat_report"]
lines = self._get_report_lines()
# Check report based on taxtags
check_tax_tag_01 = self.check_tag_or_group_in_report(
self.tax_tag_01.name, vat_report
)
self.assertTrue(check_tax_tag_01)
check_tax_tag_02 = self.check_tag_or_group_in_report(
self.tax_tag_02.name, vat_report
)
self.assertTrue(check_tax_tag_02)
check_tax_tag_03 = self.check_tag_or_group_in_report(
self.tax_tag_03.name, vat_report
)
self.assertTrue(check_tax_tag_03)
check_tax_10 = self.check_tax_in_report(self.tax_10.name, vat_report)
self.assertTrue(check_tax_10)
check_tax_20 = self.check_tax_in_report(self.tax_20.name, vat_report)
self.assertTrue(check_tax_20)
tag_01_net, tag_01_tax = self._get_tag_or_group_line(
self.tax_tag_01.name, vat_report
)
tag_02_net, tag_02_tax = self._get_tag_or_group_line(
self.tax_tag_02.name, vat_report
)
tag_03_net, tag_03_tax = self._get_tag_or_group_line(
self.tax_tag_03.name, vat_report
)
tax_10_net, tax_10_tax = self._get_tax_line(self.tax_10.name, vat_report)
tax_20_net, tax_20_tax = self._get_tax_line(self.tax_20.name, vat_report)
self.assertEqual(tag_01_net, -100)
self.assertEqual(tag_01_tax, -10)
self.assertEqual(tag_02_net, -350)
self.assertEqual(tag_02_tax, -60)
self.assertEqual(tag_03_net, -250)
self.assertEqual(tag_03_tax, -50)
self.assertEqual(tax_10_net, -100)
self.assertEqual(tax_10_tax, -10)
self.assertEqual(tax_20_net, -250)
self.assertEqual(tax_20_tax, -50)
self.assertEqual(len(lines["tag_01"]), 1)
self.assertEqual(len(lines["tag_02"]), 1)
self.assertEqual(len(lines["tag_03"]), 1)
self.assertEqual(len(lines["tax_10"]), 1)
self.assertEqual(len(lines["tax_20"]), 1)
self.assertEqual(lines["tag_01"].net, 100)
self.assertEqual(lines["tag_01"].tax, 10)
self.assertEqual(lines["tag_02"].net, 350)
self.assertEqual(lines["tag_02"].tax, 60)
self.assertEqual(lines["tag_03"].net, 250)
self.assertEqual(lines["tag_03"].tax, 50)
self.assertEqual(lines["tax_10"].net, 100)
self.assertEqual(lines["tax_10"].tax, 10)
self.assertEqual(lines["tax_20"].net, 250)
self.assertEqual(lines["tax_20"].tax, 50)
# Check report based on taxgroups
res_data = self._get_report_lines(taxgroups=True)
vat_report = res_data["vat_report"]
check_group_10 = self.check_tag_or_group_in_report(
self.tax_group_10.name, vat_report
)
self.assertTrue(check_group_10)
check_group_20 = self.check_tag_or_group_in_report(
self.tax_group_20.name, vat_report
)
self.assertTrue(check_group_20)
check_tax_10 = self.check_tax_in_report(self.tax_10.name, vat_report)
self.assertTrue(check_tax_10)
check_tax_20 = self.check_tax_in_report(self.tax_20.name, vat_report)
self.assertTrue(check_tax_20)
self.assertEqual(len(lines["group_10"]), 1)
self.assertEqual(len(lines["group_20"]), 1)
self.assertEqual(len(lines["tax_group_10"]), 1)
self.assertEqual(len(lines["tax_group_20"]), 1)
self.assertEqual(lines["group_10"].net, 100)
self.assertEqual(lines["group_10"].tax, 10)
self.assertEqual(lines["group_20"].net, 250)
self.assertEqual(lines["group_20"].tax, 50)
self.assertEqual(lines["tax_group_10"].net, 100)
self.assertEqual(lines["tax_group_10"].tax, 10)
self.assertEqual(lines["tax_group_20"].net, 250)
self.assertEqual(lines["tax_group_20"].tax, 50)
group_10_net, group_10_tax = self._get_tag_or_group_line(
self.tax_group_10.name, vat_report
)
group_20_net, group_20_tax = self._get_tag_or_group_line(
self.tax_group_20.name, vat_report
def test_get_report_html(self):
vat_report = self.env["report_vat_report"].create(
{
"date_from": self.date_from,
"date_to": self.date_to,
"company_id": self.company.id,
"tax_detail": True,
}
)
tax_10_net, tax_10_tax = self._get_tax_line(self.tax_10.name, vat_report)
tax_20_net, tax_20_tax = self._get_tax_line(self.tax_20.name, vat_report)
self.assertEqual(group_10_net, -100)
self.assertEqual(group_10_tax, -10)
self.assertEqual(group_20_net, -250)
self.assertEqual(group_20_tax, -50)
self.assertEqual(tax_10_net, -100)
self.assertEqual(tax_10_tax, -10)
self.assertEqual(tax_20_net, -250)
self.assertEqual(tax_20_tax, -50)
vat_report.compute_data_for_report()
vat_report.get_html(given_context={})
def test_wizard_date_range(self):
vat_wizard = self.env["vat.report.wizard"]

30
account_financial_report/view/report_template.xml

@ -33,49 +33,31 @@
<record id="action_report_general_ledger" model="ir.actions.client">
<field name="name">General Ledger</field>
<field name="tag">account_financial_report_backend</field>
<field
name="context"
eval="{'model': 'report.account_financial_report.general_ledger'}"
/>
<field name="context" eval="{'active_model': 'report_general_ledger'}" />
</record>
<record id="action_report_journal_ledger" model="ir.actions.client">
<field name="name">Journal</field>
<field name="tag">account_financial_report_backend</field>
<field
name="context"
eval="{'model': 'report.account_financial_report.journal_ledger'}"
/>
<field name="context" eval="{'active_model': 'report_journal_ledger'}" />
</record>
<record id="action_report_open_items" model="ir.actions.client">
<field name="name">Open Items</field>
<field name="tag">account_financial_report_backend</field>
<field
name="context"
eval="{'model': 'report.account_financial_report.open_items'}"
/>
<field name="context" eval="{'active_model': 'report_open_items'}" />
</record>
<record id="action_report_trial_balance" model="ir.actions.client">
<field name="name">Trial Balance</field>
<field name="tag">account_financial_report_backend</field>
<field
name="context"
eval="{'model': 'report.account_financial_report.trial_balance'}"
/>
<field name="context" eval="{'active_model': 'report_trial_balance'}" />
</record>
<record id="action_report_aged_partner_balance" model="ir.actions.client">
<field name="name">Aged Partner Balance</field>
<field name="tag">account_financial_report_backend</field>
<field
name="context"
eval="{'model': 'report.account_financial_report.aged_partner_balance'}"
/>
<field name="context" eval="{'active_model': 'report_aged_partner_balance'}" />
</record>
<record id="action_report_vat_report" model="ir.actions.client">
<field name="name">VAT Report</field>
<field name="tag">account_financial_report_backend</field>
<field
name="context"
eval="{'model': 'report.account_financial_report.vat_report'}"
/>
<field name="context" eval="{'active_model': 'report_vat_report'}" />
</record>
</odoo>

0
account_financial_report/view/report_vat_report.xml

9
account_financial_report/wizard/abstract_wizard.py

@ -1,7 +1,7 @@
# Copyright 2019 Lorenzo Battistini @ TAKOBI
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
from odoo import models
class AbstractWizard(models.AbstractModel):
@ -27,10 +27,3 @@ class AbstractWizard(models.AbstractModel):
partners -= corp_partners
partners |= corp_partners.mapped("commercial_partner_id")
return partners.ids
company_id = fields.Many2one(
comodel_name="res.company",
default=lambda self: self.env.company.id,
required=False,
string="Company",
)

108
account_financial_report/wizard/aged_partner_balance_wizard.py

@ -4,17 +4,23 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
from odoo.tools.safe_eval import safe_eval
class AgedPartnerBalanceWizard(models.TransientModel):
"""Aged partner balance report wizard."""
_name = "aged.partner.balance.report.wizard"
_name = "aged.partner.balance.wizard"
_description = "Aged Partner Balance Wizard"
_inherit = "account_financial_report_abstract_wizard"
company_id = fields.Many2one(
comodel_name="res.company",
default=lambda self: self.env.company,
required=False,
string="Company",
)
date_at = fields.Date(required=True, default=fields.Date.context_today)
date_from = fields.Date(string="Date From")
target_move = fields.Selection(
[("posted", "All Posted Entries"), ("all", "All Entries")],
string="Target Moves",
@ -22,53 +28,14 @@ class AgedPartnerBalanceWizard(models.TransientModel):
default="posted",
)
account_ids = fields.Many2many(
comodel_name="account.account",
string="Filter accounts",
domain=[("reconcile", "=", True)],
required=True,
comodel_name="account.account", string="Filter accounts",
)
receivable_accounts_only = fields.Boolean()
payable_accounts_only = fields.Boolean()
partner_ids = fields.Many2many(comodel_name="res.partner", string="Filter partners")
show_move_line_details = fields.Boolean()
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
partner_ids = fields.Many2many(
comodel_name="res.partner", string="Filter partners",
)
@api.onchange("account_code_from", "account_code_to")
def on_change_account_range(self):
if (
self.account_code_from
and self.account_code_from.code.isdigit()
and self.account_code_to
and self.account_code_to.code.isdigit()
):
start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code)
self.account_ids = self.env["account.account"].search(
[
("code", "in", [x for x in range(start_range, end_range + 1)]),
("reconcile", "=", True),
]
)
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
)
return {
"domain": {
"account_code_from": [("reconcile", "=", True)],
"account_code_to": [("reconcile", "=", True)],
}
}
show_move_line_details = fields.Boolean()
@api.onchange("company_id")
def onchange_company_id(self):
@ -92,15 +59,11 @@ class AgedPartnerBalanceWizard(models.TransientModel):
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
return res
@api.onchange("account_ids")
def onchange_account_ids(self):
return {"domain": {"account_ids": [("reconcile", "=", True)]}}
@api.onchange("receivable_accounts_only", "payable_accounts_only")
def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change."""
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only or self.payable_accounts_only:
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [("internal_type", "in", ("receivable", "payable"))]
elif self.receivable_accounts_only:
@ -111,26 +74,23 @@ class AgedPartnerBalanceWizard(models.TransientModel):
else:
self.account_ids = None
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_report_aged_partner_balance()
if report_type == "xlsx":
report_name = "a_f_r.report_aged_partner_balance_xlsx"
else:
report_name = "account_financial_report.aged_partner_balance"
return (
self.env["ir.actions.report"]
.search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
.report_action(self, data=data)
)
def button_export_html(self):
self.ensure_one()
report_type = "qweb-html"
return self._export(report_type)
action = self.env.ref(
"account_financial_report.action_report_aged_partner_balance"
)
vals = action.read()[0]
context1 = vals.get("context", {})
if isinstance(context1, str):
context1 = safe_eval(context1)
model = self.env["report_aged_partner_balance"]
report = model.create(self._prepare_report_aged_partner_balance())
report.compute_data_for_report()
context1["active_id"] = report.id
context1["active_ids"] = report.ids
vals["context"] = context1
return vals
def button_export_pdf(self):
self.ensure_one()
@ -145,17 +105,17 @@ class AgedPartnerBalanceWizard(models.TransientModel):
def _prepare_report_aged_partner_balance(self):
self.ensure_one()
return {
"wizard_id": self.id,
"date_at": self.date_at,
"date_from": self.date_from or False,
"only_posted_moves": self.target_move == "posted",
"company_id": self.company_id.id,
"account_ids": self.account_ids.ids,
"partner_ids": self.partner_ids.ids,
"filter_account_ids": [(6, 0, self.account_ids.ids)],
"filter_partner_ids": [(6, 0, self.partner_ids.ids)],
"show_move_line_details": self.show_move_line_details,
"account_financial_report_lang": self.env.lang,
}
def _export(self, report_type):
"""Default export is PDF."""
return self._print_report(report_type)
model = self.env["report_aged_partner_balance"]
report = model.create(self._prepare_report_aged_partner_balance())
report.compute_data_for_report()
return report.print_report(report_type)

23
account_financial_report/wizard/aged_partner_balance_wizard_view.xml

@ -3,7 +3,7 @@
<!-- AGED PARTNER BALANCE -->
<record id="aged_partner_balance_wizard" model="ir.ui.view">
<field name="name">Aged Partner Balance</field>
<field name="model">aged.partner.balance.report.wizard</field>
<field name="model">aged.partner.balance.wizard</field>
<field name="arch" type="xml">
<form>
<group name="main_info">
@ -16,7 +16,6 @@
<group name="filters">
<group name="date_range">
<field name="date_at" />
<field name="date_from" />
</group>
<group name="other_filters">
<field name="target_move" widget="radio" />
@ -36,24 +35,6 @@
<label for="account_ids" colspan="4" />
<field name="receivable_accounts_only" />
<field name="payable_accounts_only" />
<label for="account_code_from" string="From Code" />
<div>
<div class="o_row">
<field
name="account_code_from"
class="oe_inline"
options="{'no_create': True}"
/>
<span class="oe_inline">
To
</span>
<field
name="account_code_to"
class="oe_inline"
options="{'no_create': True}"
/>
</div>
</div>
<field
name="account_ids"
nolabel="1"
@ -91,7 +72,7 @@
<act_window
id="action_aged_partner_balance_wizard"
name="Aged Partner Balance"
res_model="aged.partner.balance.report.wizard"
res_model="aged.partner.balance.wizard"
view_mode="form"
view_id="aged_partner_balance_wizard"
target="new"

174
account_financial_report/wizard/general_ledger_wizard.py

@ -3,15 +3,16 @@
# Author: Jordi Ballester
# Copyright 2016 Camptocamp SA
# Copyright 2017 Akretion - Alexis de Lattre
# Copyright 2017 ForgeFlow, S.L.
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# Copyright 2020 Druidoo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
from ast import literal_eval
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools.safe_eval import safe_eval
class GeneralLedgerReportWizard(models.TransientModel):
@ -21,6 +22,12 @@ class GeneralLedgerReportWizard(models.TransientModel):
_description = "General Ledger Report Wizard"
_inherit = "account_financial_report_abstract_wizard"
company_id = fields.Many2one(
comodel_name="res.company",
default=lambda self: self.env.company,
required=False,
string="Company",
)
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
date_from = fields.Date(required=True, default=lambda self: self._init_date_from())
date_to = fields.Date(required=True, default=fields.Date.context_today)
@ -32,7 +39,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
default="posted",
)
account_ids = fields.Many2many(
comodel_name="account.account", string="Filter accounts"
comodel_name="account.account", string="Filter accounts",
)
centralize = fields.Boolean(string="Activate centralization", default=True)
hide_account_at_0 = fields.Boolean(
@ -43,21 +50,20 @@ class GeneralLedgerReportWizard(models.TransientModel):
"debits and credits totals will not match the trial balance.",
)
show_analytic_tags = fields.Boolean(string="Show analytic tags",)
receivable_accounts_only = fields.Boolean()
payable_accounts_only = fields.Boolean()
account_type_ids = fields.Many2many("account.account.type", string="Account Types",)
partner_ids = fields.Many2many(
comodel_name="res.partner",
string="Filter partners",
default=lambda self: self._default_partners(),
)
analytic_tag_ids = fields.Many2many(
comodel_name="account.analytic.tag", string="Filter analytic tags"
comodel_name="account.analytic.tag", string="Filter analytic tags",
)
account_journal_ids = fields.Many2many(
comodel_name="account.journal", string="Filter journals"
comodel_name="account.journal", string="Filter journals",
)
cost_center_ids = fields.Many2many(
comodel_name="account.analytic.account", string="Filter cost centers"
comodel_name="account.analytic.account", string="Filter cost centers",
)
not_only_one_unaffected_earnings_account = fields.Boolean(
@ -70,52 +76,16 @@ class GeneralLedgerReportWizard(models.TransientModel):
"will display initial and final balance in that currency.",
default=lambda self: self._default_foreign_currency(),
)
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
partner_ungrouped = fields.Boolean(
string="Partner ungrouped",
help="If set moves are not grouped by partner in any case",
)
show_partner_details = fields.Boolean(string="Show Partner Details", default=True,)
show_cost_center = fields.Boolean(string="Show Analytic Account", default=True,)
domain = fields.Char(
string="Journal Items Domain",
default=[],
help="This domain will be used to select specific domain for Journal " "Items",
)
def _get_account_move_lines_domain(self):
domain = literal_eval(self.domain) if self.domain else []
return domain
@api.onchange("account_code_from", "account_code_to")
def on_change_account_range(self):
if (
self.account_code_from
and self.account_code_from.code.isdigit()
and self.account_code_to
and self.account_code_to.code.isdigit()
):
start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code)
self.account_ids = self.env["account.account"].search(
[("code", "in", [x for x in range(start_range, end_range + 1)])]
)
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
)
def _init_date_from(self):
"""set start date to begin of current year if fiscal year running"""
today = fields.Date.context_today(self)
company = self.company_id or self.env.company
last_fsc_month = company.fiscalyear_last_month
last_fsc_day = company.fiscalyear_last_day
last_fsc_month = self.env.company.fiscalyear_last_month
last_fsc_day = self.env.company.fiscalyear_last_day
if (
today.month < int(last_fsc_month)
@ -164,8 +134,8 @@ class GeneralLedgerReportWizard(models.TransientModel):
lambda p: p.company_id == self.company_id or not p.company_id
)
if self.company_id and self.account_ids:
if self.receivable_accounts_only or self.payable_accounts_only:
self.onchange_type_accounts_only()
if self.account_type_ids:
self._onchange_account_type_ids()
else:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
@ -223,18 +193,15 @@ class GeneralLedgerReportWizard(models.TransientModel):
)
)
@api.onchange("receivable_accounts_only", "payable_accounts_only")
def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change."""
if self.receivable_accounts_only or self.payable_accounts_only:
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [("internal_type", "in", ("receivable", "payable"))]
elif self.receivable_accounts_only:
domain += [("internal_type", "=", "receivable")]
elif self.payable_accounts_only:
domain += [("internal_type", "=", "payable")]
self.account_ids = self.env["account.account"].search(domain)
@api.onchange("account_type_ids")
def _onchange_account_type_ids(self):
if self.account_type_ids:
self.account_ids = self.env["account.account"].search(
[
("company_id", "=", self.company_id.id),
("user_type_id", "in", self.account_type_ids.ids),
]
)
else:
self.account_ids = None
@ -242,47 +209,28 @@ class GeneralLedgerReportWizard(models.TransientModel):
def onchange_partner_ids(self):
"""Handle partners change."""
if self.partner_ids:
self.receivable_accounts_only = self.payable_accounts_only = True
else:
self.receivable_accounts_only = self.payable_accounts_only = False
@api.depends("company_id")
def _compute_unaffected_earnings_account(self):
account_type = self.env.ref("account.data_unaffected_earnings")
for record in self:
record.unaffected_earnings_account = self.env["account.account"].search(
[
("user_type_id", "=", account_type.id),
("company_id", "=", record.company_id.id),
]
self.account_type_ids = self.env["account.account.type"].search(
[("type", "in", ["receivable", "payable"])]
)
unaffected_earnings_account = fields.Many2one(
comodel_name="account.account",
compute="_compute_unaffected_earnings_account",
store=True,
)
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_report_general_ledger()
if report_type == "xlsx":
report_name = "a_f_r.report_general_ledger_xlsx"
else:
report_name = "account_financial_report.general_ledger"
return (
self.env["ir.actions.report"]
.search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
.report_action(self, data=data)
)
self.account_type_ids = None
# Somehow this is required to force onchange on _default_partners()
self._onchange_account_type_ids()
def button_export_html(self):
self.ensure_one()
report_type = "qweb-html"
return self._export(report_type)
action = self.env.ref("account_financial_report.action_report_general_ledger")
action_data = action.read()[0]
context1 = action_data.get("context", {})
if isinstance(context1, str):
context1 = safe_eval(context1)
model = self.env["report_general_ledger"]
report = model.create(self._prepare_report_general_ledger())
report.compute_data_for_report()
context1["active_id"] = report.id
context1["active_ids"] = report.ids
action_data["context"] = context1
return action_data
def button_export_pdf(self):
self.ensure_one()
@ -297,7 +245,6 @@ class GeneralLedgerReportWizard(models.TransientModel):
def _prepare_report_general_ledger(self):
self.ensure_one()
return {
"wizard_id": self.id,
"date_from": self.date_from,
"date_to": self.date_to,
"only_posted_moves": self.target_move == "posted",
@ -305,26 +252,19 @@ class GeneralLedgerReportWizard(models.TransientModel):
"foreign_currency": self.foreign_currency,
"show_analytic_tags": self.show_analytic_tags,
"company_id": self.company_id.id,
"account_ids": self.account_ids.ids,
"partner_ids": self.partner_ids.ids,
"show_partner_details": self.show_partner_details,
"cost_center_ids": self.cost_center_ids.ids,
"show_cost_center": self.show_cost_center,
"analytic_tag_ids": self.analytic_tag_ids.ids,
"journal_ids": self.account_journal_ids.ids,
"filter_account_ids": [(6, 0, self.account_ids.ids)],
"filter_partner_ids": [(6, 0, self.partner_ids.ids)],
"filter_cost_center_ids": [(6, 0, self.cost_center_ids.ids)],
"filter_analytic_tag_ids": [(6, 0, self.analytic_tag_ids.ids)],
"filter_journal_ids": [(6, 0, self.account_journal_ids.ids)],
"centralize": self.centralize,
"fy_start_date": self.fy_start_date,
"unaffected_earnings_account": self.unaffected_earnings_account.id,
"account_financial_report_lang": self.env.lang,
"domain": self._get_account_move_lines_domain(),
"partner_ungrouped": self.partner_ungrouped,
}
def _export(self, report_type):
"""Default export is PDF."""
return self._print_report(report_type)
def _get_atr_from_dict(self, obj_id, data, key):
try:
return data[obj_id][key]
except KeyError:
return data[str(obj_id)][key]
model = self.env["report_general_ledger"]
report = model.create(self._prepare_report_general_ledger())
report.compute_data_for_report()
return report.print_report(report_type)

114
account_financial_report/wizard/general_ledger_wizard_view.xml

@ -25,45 +25,71 @@
</group>
<group name="other_filters">
<field name="target_move" widget="radio" />
<field name="centralize" />
<field name="show_partner_details" />
<field name="hide_account_at_0" />
<field name="foreign_currency" />
<field name="show_analytic_tags" />
<field name="show_cost_center" />
<label string="Other options" for="centralize" />
<div>
<field
name="centralize"
nolabel="1"
class="oe_inline"
/>
<label for="centralize" class="oe_inline" />
</div>
<label string=" " for="hide_account_at_0" />
<div>
<field
name="hide_account_at_0"
nolabel="1"
class="oe_inline"
/>
<label for="hide_account_at_0" class="oe_inline" />
</div>
<label string=" " for="foreign_currency" />
<div>
<field
name="foreign_currency"
nolabel="1"
class="oe_inline"
/>
<label for="foreign_currency" class="oe_inline" />
</div>
<label string=" " for="show_analytic_tags" />
<div>
<field
name="show_analytic_tags"
nolabel="1"
class="oe_inline"
/>
<label for="show_analytic_tags" class="oe_inline" />
</div>
<label string=" " for="partner_ungrouped" />
<div>
<field
name="partner_ungrouped"
nolabel="1"
class="oe_inline"
/>
<label for="partner_ungrouped" class="oe_inline" />
</div>
</group>
</group>
<notebook>
<page string="Filter accounts">
<group name="account_filter" col="4">
<label for="account_ids" colspan="4" />
<field name="receivable_accounts_only" />
<field name="payable_accounts_only" />
<label for="account_code_from" string="From Code" />
<div>
<div class="o_row">
<field
name="account_code_from"
class="oe_inline"
options="{'no_create': True}"
/>
<span class="oe_inline">
To
</span>
<field
name="account_code_to"
class="oe_inline"
options="{'no_create': True}"
/>
</div>
</div>
<field
name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
colspan="4"
/>
<group>
<group>
<field
name="account_type_ids"
widget="many2many_checkboxes"
nolabel="1"
/>
</group>
<group>
<field
name="account_ids"
widget="many2many_tags"
options="{'no_create': True}"
nolabel="1"
/>
</group>
</group>
</page>
<page string="Filter partners">
@ -75,14 +101,14 @@
/>
</page>
<page
string="Filter analytic accounts"
string="Filter cost centers"
groups="analytic.group_analytic_accounting"
>
<field
name="cost_center_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
groups="analytic.group_analytic_accounting"
/>
</page>
<page string="Filter analytic tags">
@ -93,16 +119,6 @@
options="{'no_create': True}"
/>
</page>
<page string="Additional Filtering">
<style
>.o_domain_show_selection_button {display: none}</style>
<field
name="domain"
widget="domain"
options="{'model': 'account.move.line', 'in_dialog': True}"
context="{'skip_search_count': 1}"
/>
</page>
</notebook>
</div>
<div
@ -167,10 +183,6 @@
res_model="general.ledger.report.wizard"
binding_model="res.partner"
view_mode="form"
context="{
'default_receivable_accounts_only':1,
'default_payable_accounts_only':1,
}"
groups="account.group_account_manager"
target="new"
/>

100
account_financial_report/wizard/journal_ledger_wizard.py

@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.tools.safe_eval import safe_eval
class JournalLedgerReportWizard(models.TransientModel):
@ -12,19 +13,19 @@ class JournalLedgerReportWizard(models.TransientModel):
company_id = fields.Many2one(
comodel_name="res.company",
default=lambda self: self.env.company.id,
default=lambda self: self.env.company,
string="Company",
required=False,
ondelete="cascade",
)
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range",)
date_from = fields.Date(string="Start date", required=True)
date_to = fields.Date(string="End date", required=True)
journal_ids = fields.Many2many(
comodel_name="account.journal", string="Journals", required=False
comodel_name="account.journal", string="Journals", required=False,
)
move_target = fields.Selection(
selection="_get_move_targets", default="posted", required=True
selection="_get_move_targets", default="all", required=True,
)
foreign_currency = fields.Boolean()
sort_option = fields.Selection(
@ -39,7 +40,7 @@ class JournalLedgerReportWizard(models.TransientModel):
default="journal",
required=True,
)
with_account_name = fields.Boolean(default=False)
with_account_name = fields.Boolean(default=False,)
@api.model
def _get_move_targets(self):
@ -47,11 +48,17 @@ class JournalLedgerReportWizard(models.TransientModel):
@api.model
def _get_sort_options(self):
return [("move_name", _("Entry number")), ("date", _("Date"))]
return [
("move_name", _("Entry number")),
("date", _("Date")),
]
@api.model
def _get_group_options(self):
return [("journal", _("Journal")), ("none", _("No group"))]
return [
("journal", _("Journal")),
("none", _("No group")),
]
@api.onchange("date_range_id")
def onchange_date_range_id(self):
@ -78,28 +85,23 @@ class JournalLedgerReportWizard(models.TransientModel):
res["domain"]["journal_ids"] += [("company_id", "=", self.company_id.id)]
return res
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_report_journal_ledger()
if report_type == "xlsx":
report_name = "a_f_r.report_journal_ledger_xlsx"
else:
report_name = "account_financial_report.journal_ledger"
return (
self.env["ir.actions.report"]
.search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
.report_action(self, data=data)
)
def button_export_html(self):
self.ensure_one()
report_type = "qweb-html"
return self._export(report_type)
action = self.env.ref("account_financial_report.action_report_journal_ledger")
vals = action.read()[0]
context1 = vals.get("context", {})
if isinstance(context1, str):
context1 = safe_eval(context1)
model = self.env["report_journal_ledger"]
report = model.create(self._prepare_report_journal_ledger())
report.compute_data_for_report()
context1["active_id"] = report.id
context1["active_ids"] = report.ids
vals["context"] = context1
return vals
def button_export_pdf(self):
self.ensure_one()
report_type = "qweb-pdf"
return self._export(report_type)
@ -117,59 +119,21 @@ class JournalLedgerReportWizard(models.TransientModel):
[("company_id", "=", self.company_id.id)]
)
return {
"wizard_id": self.id,
"date_from": self.date_from,
"date_to": self.date_to,
"move_target": self.move_target,
"foreign_currency": self.foreign_currency,
"company_id": self.company_id.id,
"journal_ids": journals.ids,
"journal_ids": [(6, 0, journals.ids)],
"sort_option": self.sort_option,
"group_option": self.group_option,
"with_account_name": self.with_account_name,
"account_financial_report_lang": self.env.lang,
}
def _export(self, report_type):
"""Default export is PDF."""
self.ensure_one()
return self._print_report(report_type)
@api.model
def _get_ml_tax_description(
self, move_line_data, tax_line_data, move_line_taxes_data
):
taxes_description = ""
if move_line_data["tax_line_id"]:
taxes_description = tax_line_data["description"] or tax_line_data["name"]
elif move_line_taxes_data:
tax_names = []
for tax_key in move_line_taxes_data:
tax = move_line_taxes_data[tax_key]
tax_names.append(tax["description"] or tax["name"])
taxes_description = ",".join(tax_names)
return taxes_description
@api.model
def _get_partner_name(self, partner_id, partner_data):
if str(partner_id) in partner_data.keys():
return partner_data[str(partner_id)]["name"]
else:
return ""
@api.model
def _get_atr_from_dict(self, obj_id, data, key):
try:
return data[obj_id][key]
except KeyError:
return data[str(obj_id)][key]
@api.model
def _get_data_from_dict(self, obj_id, data):
if data:
if isinstance(list(data.keys())[0], int):
return data.get(obj_id, False)
else:
return data.get(obj_id(obj_id), False)
else:
return False
model = self.env["report_journal_ledger"]
report = model.create(self._prepare_report_journal_ledger())
report.compute_data_for_report()
return report.print_report(report_type)

101
account_financial_report/wizard/open_items_wizard.py

@ -4,6 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
from odoo.tools.safe_eval import safe_eval
class OpenItemsReportWizard(models.TransientModel):
@ -13,8 +14,13 @@ class OpenItemsReportWizard(models.TransientModel):
_description = "Open Items Report Wizard"
_inherit = "account_financial_report_abstract_wizard"
company_id = fields.Many2one(
comodel_name="res.company",
default=lambda self: self.env.company,
required=False,
string="Company",
)
date_at = fields.Date(required=True, default=fields.Date.context_today)
date_from = fields.Date(string="Date From")
target_move = fields.Selection(
[("posted", "All Posted Entries"), ("all", "All Entries")],
string="Target Moves",
@ -25,7 +31,6 @@ class OpenItemsReportWizard(models.TransientModel):
comodel_name="account.account",
string="Filter accounts",
domain=[("reconcile", "=", True)],
required=True,
)
hide_account_at_0 = fields.Boolean(
string="Hide account ending balance at 0",
@ -49,44 +54,6 @@ class OpenItemsReportWizard(models.TransientModel):
"will display initial and final balance in that currency.",
default=lambda self: self._default_foreign_currency(),
)
show_partner_details = fields.Boolean(string="Show Partner Details", default=True,)
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
)
@api.onchange("account_code_from", "account_code_to")
def on_change_account_range(self):
if (
self.account_code_from
and self.account_code_from.code.isdigit()
and self.account_code_to
and self.account_code_to.code.isdigit()
):
start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code)
self.account_ids = self.env["account.account"].search(
[
("code", "in", [x for x in range(start_range, end_range + 1)]),
("reconcile", "=", True),
]
)
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
)
return {
"domain": {
"account_code_from": [("reconcile", "=", True)],
"account_code_to": [("reconcile", "=", True)],
}
}
def _default_foreign_currency(self):
return self.env.user.has_group("base.group_multi_currency")
@ -113,15 +80,11 @@ class OpenItemsReportWizard(models.TransientModel):
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
return res
@api.onchange("account_ids")
def onchange_account_ids(self):
return {"domain": {"account_ids": [("reconcile", "=", True)]}}
@api.onchange("receivable_accounts_only", "payable_accounts_only")
def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change."""
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only or self.payable_accounts_only:
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [("internal_type", "in", ("receivable", "payable"))]
elif self.receivable_accounts_only:
@ -132,26 +95,21 @@ class OpenItemsReportWizard(models.TransientModel):
else:
self.account_ids = None
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_report_open_items()
if report_type == "xlsx":
report_name = "a_f_r.report_open_items_xlsx"
else:
report_name = "account_financial_report.open_items"
return (
self.env["ir.actions.report"]
.search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
.report_action(self, data=data)
)
def button_export_html(self):
self.ensure_one()
report_type = "qweb-html"
return self._export(report_type)
action = self.env.ref("account_financial_report.action_report_open_items")
vals = action.read()[0]
context1 = vals.get("context", {})
if isinstance(context1, str):
context1 = safe_eval(context1)
model = self.env["report_open_items"]
report = model.create(self._prepare_report_open_items())
report.compute_data_for_report()
context1["active_id"] = report.id
context1["active_ids"] = report.ids
vals["context"] = context1
return vals
def button_export_pdf(self):
self.ensure_one()
@ -166,19 +124,18 @@ class OpenItemsReportWizard(models.TransientModel):
def _prepare_report_open_items(self):
self.ensure_one()
return {
"wizard_id": self.id,
"date_at": fields.Date.to_string(self.date_at),
"date_from": self.date_from or False,
"date_at": self.date_at,
"only_posted_moves": self.target_move == "posted",
"hide_account_at_0": self.hide_account_at_0,
"foreign_currency": self.foreign_currency,
"show_partner_details": self.show_partner_details,
"company_id": self.company_id.id,
"target_move": self.target_move,
"account_ids": self.account_ids.ids,
"partner_ids": self.partner_ids.ids or [],
"account_financial_report_lang": self.env.lang,
"filter_account_ids": [(6, 0, self.account_ids.ids)],
"filter_partner_ids": [(6, 0, self.partner_ids.ids)],
}
def _export(self, report_type):
return self._print_report(report_type)
"""Default export is PDF."""
model = self.env["report_open_items"]
report = model.create(self._prepare_report_open_items())
report.compute_data_for_report()
return report.print_report(report_type)

20
account_financial_report/wizard/open_items_wizard_view.xml

@ -16,11 +16,9 @@
<group name="filters">
<group name="date_range">
<field name="date_at" />
<field name="date_from" />
</group>
<group name="other_filters">
<field name="target_move" widget="radio" />
<field name="show_partner_details" />
<field name="hide_account_at_0" />
<field name="foreign_currency" />
</group>
@ -37,24 +35,6 @@
<group name="account_filter" col="4">
<field name="receivable_accounts_only" />
<field name="payable_accounts_only" />
<label for="account_code_from" string="From Code" />
<div>
<div class="o_row">
<field
name="account_code_from"
class="oe_inline"
options="{'no_create': True}"
/>
<span class="oe_inline">
To
</span>
<field
name="account_code_to"
class="oe_inline"
options="{'no_create': True}"
/>
</div>
</div>
<field
name="account_ids"
nolabel="1"

109
account_financial_report/wizard/trial_balance_wizard.py

@ -1,11 +1,12 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# Copyright 2017 Akretion - Alexis de Lattre
# Copyright 2018 ForgeFlow, S.L.
# Copyright 2018 Eficent Business and IT Consuting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.tools.safe_eval import safe_eval
class TrialBalanceReportWizard(models.TransientModel):
@ -15,6 +16,12 @@ class TrialBalanceReportWizard(models.TransientModel):
_description = "Trial Balance Report Wizard"
_inherit = "account_financial_report_abstract_wizard"
company_id = fields.Many2one(
comodel_name="res.company",
default=lambda self: self.env.company,
required=False,
string="Company",
)
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
date_from = fields.Date(required=True)
date_to = fields.Date(required=True)
@ -33,7 +40,7 @@ class TrialBalanceReportWizard(models.TransientModel):
],
string="Hierarchy On",
required=True,
default="none",
default="computed",
help="""Computed Accounts: Use when the account group have codes
that represent prefixes of the actual accounts.\n
Child Accounts: Use when your account groups are hierarchical.\n
@ -46,7 +53,7 @@ class TrialBalanceReportWizard(models.TransientModel):
"Do not display parent levels", default=False
)
account_ids = fields.Many2many(
comodel_name="account.account", string="Filter accounts"
comodel_name="account.account", string="Filter accounts",
)
hide_account_at_0 = fields.Boolean(
string="Hide accounts at 0",
@ -58,8 +65,10 @@ class TrialBalanceReportWizard(models.TransientModel):
receivable_accounts_only = fields.Boolean()
payable_accounts_only = fields.Boolean()
show_partner_details = fields.Boolean()
partner_ids = fields.Many2many(comodel_name="res.partner", string="Filter partners")
journal_ids = fields.Many2many(comodel_name="account.journal")
partner_ids = fields.Many2many(
comodel_name="res.partner", string="Filter partners",
)
journal_ids = fields.Many2many(comodel_name="account.journal",)
not_only_one_unaffected_earnings_account = fields.Boolean(
readonly=True, string="Not only one unaffected earnings account"
@ -71,34 +80,6 @@ class TrialBalanceReportWizard(models.TransientModel):
"account currency is not setup through chart of accounts "
"will display initial and final balance in that currency.",
)
account_code_from = fields.Many2one(
comodel_name="account.account",
string="Account Code From",
help="Starting account in a range",
)
account_code_to = fields.Many2one(
comodel_name="account.account",
string="Account Code To",
help="Ending account in a range",
)
@api.onchange("account_code_from", "account_code_to")
def on_change_account_range(self):
if (
self.account_code_from
and self.account_code_from.code.isdigit()
and self.account_code_to
and self.account_code_to.code.isdigit()
):
start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code)
self.account_ids = self.env["account.account"].search(
[("code", "in", [x for x in range(start_range, end_range + 1)])]
)
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
)
@api.constrains("hierarchy_on", "show_hierarchy_level")
def _check_show_hierarchy_level(self):
@ -214,43 +195,21 @@ class TrialBalanceReportWizard(models.TransientModel):
else:
self.receivable_accounts_only = self.payable_accounts_only = False
@api.depends("company_id")
def _compute_unaffected_earnings_account(self):
account_type = self.env.ref("account.data_unaffected_earnings")
for record in self:
record.unaffected_earnings_account = self.env["account.account"].search(
[
("user_type_id", "=", account_type.id),
("company_id", "=", record.company_id.id),
]
)
unaffected_earnings_account = fields.Many2one(
comodel_name="account.account",
compute="_compute_unaffected_earnings_account",
store=True,
)
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_report_trial_balance()
if report_type == "xlsx":
report_name = "a_f_r.report_trial_balance_xlsx"
else:
report_name = "account_financial_report.trial_balance"
return (
self.env["ir.actions.report"]
.search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
.report_action(self, data=data)
)
def button_export_html(self):
self.ensure_one()
report_type = "qweb-html"
return self._export(report_type)
action = self.env.ref("account_financial_report.action_report_trial_balance")
vals = action.read()[0]
context1 = vals.get("context", {})
if isinstance(context1, str):
context1 = safe_eval(context1)
model = self.env["report_trial_balance"]
report = model.create(self._prepare_report_trial_balance())
report.compute_data_for_report()
context1["active_id"] = report.id
context1["active_ids"] = report.ids
vals["context"] = context1
return vals
def button_export_pdf(self):
self.ensure_one()
@ -265,26 +224,26 @@ class TrialBalanceReportWizard(models.TransientModel):
def _prepare_report_trial_balance(self):
self.ensure_one()
return {
"wizard_id": self.id,
"date_from": self.date_from,
"date_to": self.date_to,
"only_posted_moves": self.target_move == "posted",
"hide_account_at_0": self.hide_account_at_0,
"foreign_currency": self.foreign_currency,
"company_id": self.company_id.id,
"account_ids": self.account_ids.ids or [],
"partner_ids": self.partner_ids.ids or [],
"journal_ids": self.journal_ids.ids or [],
"filter_account_ids": [(6, 0, self.account_ids.ids)],
"filter_partner_ids": [(6, 0, self.partner_ids.ids)],
"filter_journal_ids": [(6, 0, self.journal_ids.ids)],
"fy_start_date": self.fy_start_date,
"hierarchy_on": self.hierarchy_on,
"limit_hierarchy_level": self.limit_hierarchy_level,
"show_hierarchy_level": self.show_hierarchy_level,
"hide_parent_hierarchy_level": self.hide_parent_hierarchy_level,
"show_partner_details": self.show_partner_details,
"unaffected_earnings_account": self.unaffected_earnings_account.id,
"account_financial_report_lang": self.env.lang,
}
def _export(self, report_type):
"""Default export is PDF."""
return self._print_report(report_type)
model = self.env["report_trial_balance"]
report = model.create(self._prepare_report_trial_balance())
report.compute_data_for_report()
return report.print_report(report_type)

18
account_financial_report/wizard/trial_balance_wizard_view.xml

@ -34,7 +34,7 @@
/>
<field
name="limit_hierarchy_level"
attrs="{'invisible':['|', ('hierarchy_on','in',['none', 'computed']),('show_partner_details','=',True)]}"
attrs="{'invisible':['|', ('hierarchy_on','=','none'),('show_partner_details','=',True)]}"
/>
<field
name="show_hierarchy_level"
@ -73,22 +73,6 @@
<label for="account_ids" colspan="4" />
<field name="receivable_accounts_only" />
<field name="payable_accounts_only" />
<label for="account_code_from" string="From Code" />
<div>
<div class="o_row">
<field
name="account_code_from"
class="oe_inline"
options="{'no_create': True}"
/>
<span class="oe_inline">To</span>
<field
name="account_code_to"
class="oe_inline"
options="{'no_create': True}"
/>
</div>
</div>
<field
name="account_ids"
nolabel="1"

49
account_financial_report/wizard/vat_report_wizard.py

@ -3,6 +3,7 @@
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools.safe_eval import safe_eval
class VATReportWizard(models.TransientModel):
@ -11,7 +12,7 @@ class VATReportWizard(models.TransientModel):
company_id = fields.Many2one(
comodel_name="res.company",
default=lambda self: self.env.company.id,
default=lambda self: self.env.company,
required=False,
string="Company",
)
@ -25,12 +26,6 @@ class VATReportWizard(models.TransientModel):
default="taxtags",
)
tax_detail = fields.Boolean("Detail Taxes")
target_move = fields.Selection(
[("posted", "All Posted Entries"), ("all", "All Entries")],
string="Target Moves",
required=True,
default="posted",
)
@api.onchange("company_id")
def onchange_company_id(self):
@ -40,7 +35,7 @@ class VATReportWizard(models.TransientModel):
and self.date_range_id.company_id != self.company_id
):
self.date_range_id = False
res = {"domain": {"date_range_id": []}}
res = {"domain": {"date_range_id": [],}}
if not self.company_id:
return res
else:
@ -72,26 +67,20 @@ class VATReportWizard(models.TransientModel):
)
)
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_vat_report()
if report_type == "xlsx":
report_name = "a_f_r.report_vat_report_xlsx"
else:
report_name = "account_financial_report.vat_report"
return (
self.env["ir.actions.report"]
.search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
.report_action(self, data=data)
)
def button_export_html(self):
self.ensure_one()
report_type = "qweb-html"
return self._export(report_type)
action = self.env.ref("account_financial_report.action_report_vat_report")
vals = action.read()[0]
context1 = vals.get("context", {})
if isinstance(context1, str):
context1 = safe_eval(context1)
model = self.env["report_vat_report"]
report = model.create(self._prepare_vat_report())
report.compute_data_for_report()
context1["active_id"] = report.id
context1["active_ids"] = report.ids
vals["context"] = context1
return vals
def button_export_pdf(self):
self.ensure_one()
@ -106,16 +95,16 @@ class VATReportWizard(models.TransientModel):
def _prepare_vat_report(self):
self.ensure_one()
return {
"wizard_id": self.id,
"company_id": self.company_id.id,
"date_from": self.date_from,
"date_to": self.date_to,
"based_on": self.based_on,
"only_posted_moves": self.target_move == "posted",
"tax_detail": self.tax_detail,
"account_financial_report_lang": self.env.lang,
}
def _export(self, report_type):
"""Default export is PDF."""
return self._print_report(report_type)
model = self.env["report_vat_report"]
report = model.create(self._prepare_vat_report())
report.compute_data_for_report()
return report.print_report(report_type)

9
account_financial_report/wizard/vat_report_wizard_view.xml

@ -18,11 +18,10 @@
<field name="date_from" />
<field name="date_to" />
</group>
</group>
<group name="other_filters">
<field name="target_move" widget="radio" />
<field name="based_on" widget="radio" />
<field name="tax_detail" />
<group name="other_filters">
<field name="based_on" widget="radio" />
<field name="tax_detail" />
</group>
</group>
<footer>
<button

Loading…
Cancel
Save