Browse Source

[MIG] account_financial_report: Finalize migration to 12.0

* Move back to CSS and FIX

  NameError: variable @odoo-view-background-color is undefined in - on line 99, column 23:
  98 .o_account_financial_reports_page {
  99     background-color: @odoo-view-background-color;
  100     color: @odoo-main-text-color;

* Porting: parent_left does not exist anymore. Using parent_path + account code to sort report lines

* FIX js error with date object not converted to string while clicking on initial balance amount
  See https://user-images.githubusercontent.com/1033131/58337566-5d525c80-7e46-11e9-913a-3c3e0115fb3e.gif

* IMP style and metadata

* FIX tests about new date format and partner_id computed field of account.move

* FIX errors like

  2019-06-03 16:11:51,406 17857 ERROR dev_12_account_financial_report odoo.sql_db: bad query: b"\nDELETE FROM 'report_vat_report_tax'\nWHERE COALESCE(\n    write_date, create_date, (now() at time zone 'UTC'))::timestamp\n    < ((now() at time zone 'UTC') - interval '3600.0 seconds')\n"
  ERROR: syntax error at or near "'report_vat_report_tax'"
  LINE 2: DELETE FROM 'report_vat_report_tax'
                    ^
* IMP translation template and IMP Italian translation

* Remove useless comments
* Use AsIs to avoid SQL injection
* Use fields.Date methods
* Remove useless data from tests
* Improve comments
* Fix wizard.multi.charts.accounts
* Move _get_partner_ids_domain to abstract wizard
* Refactor default partners in wizard to use recordsets
* Improve js style
pull/749/head
eLBati 6 years ago
committed by João Marques
parent
commit
f3ab79a9e9
  1. 12
      account_financial_report/README.rst
  2. 1752
      account_financial_report/i18n/account_financial_report.pot
  3. 1778
      account_financial_report/i18n/ar.po
  4. 1754
      account_financial_report/i18n/ca.po
  5. 1784
      account_financial_report/i18n/de.po
  6. 1793
      account_financial_report/i18n/es.po
  7. 1757
      account_financial_report/i18n/fr.po
  8. 1757
      account_financial_report/i18n/hr_HR.po
  9. 2230
      account_financial_report/i18n/it.po
  10. 1786
      account_financial_report/i18n/nl.po
  11. 1756
      account_financial_report/i18n/nl_NL.po
  12. 1757
      account_financial_report/i18n/pt.po
  13. 1779
      account_financial_report/i18n/ro.po
  14. 49
      account_financial_report/menuitems.xml
  15. 2
      account_financial_report/readme/CONTRIBUTORS.rst
  16. 15
      account_financial_report/report/abstract_report.py
  17. 5
      account_financial_report/report/abstract_report_xlsx.py
  18. 3
      account_financial_report/report/general_ledger.py
  19. 3
      account_financial_report/report/journal_ledger.py
  20. 94
      account_financial_report/report/open_items.py
  21. 12
      account_financial_report/report/templates/general_ledger.xml
  22. 58
      account_financial_report/report/templates/trial_balance.xml
  23. 13
      account_financial_report/report/trial_balance.py
  24. 8
      account_financial_report/static/description/index.html
  25. 2
      account_financial_report/static/src/css/report.css
  26. 39
      account_financial_report/static/src/js/account_financial_report_backend.js
  27. 27
      account_financial_report/tests/test_general_ledger.py
  28. 2
      account_financial_report/tests/test_journal_ledger.py
  29. 7
      account_financial_report/tests/test_trial_balance.py
  30. 17
      account_financial_report/tests/test_vat_report.py
  31. 3
      account_financial_report/view/report_template.xml
  32. 1
      account_financial_report/wizard/__init__.py
  33. 32
      account_financial_report/wizard/abstract_wizard.py
  34. 7
      account_financial_report/wizard/aged_partner_balance_wizard.py
  35. 25
      account_financial_report/wizard/general_ledger_wizard.py
  36. 20
      account_financial_report/wizard/open_items_wizard.py
  37. 13
      account_financial_report/wizard/trial_balance_wizard.py

12
account_financial_report/README.rst

@ -14,13 +14,13 @@ Account Financial Reports
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github .. |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/11.0/account_financial_report
:target: https://github.com/OCA/account-financial-reporting/tree/12.0/account_financial_report
:alt: OCA/account-financial-reporting :alt: OCA/account-financial-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-reporting-11-0/account-financial-reporting-11-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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/91/11.0
:target: https://runbot.odoo-community.org/runbot/91/12.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -76,7 +76,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_. 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. 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 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:%2011.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. Do not contact contributors directly about support or help with technical issues.
@ -105,7 +105,7 @@ Contributors
* Robert Rottermann <robert@redcor.ch> * Robert Rottermann <robert@redcor.ch>
* Ciro Urselli <c.urselli@apuliasoftware.it> * Ciro Urselli <c.urselli@apuliasoftware.it>
* Francesco Apruzzese <opencode@e-ware.org> * Francesco Apruzzese <opencode@e-ware.org>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* Lorenzo Battistini <https://github.com/eLBati>
* Julien Coux <julien.coux@camptocamp.com> * Julien Coux <julien.coux@camptocamp.com>
* Akim Juillerat <akim.juillerat@camptocamp.com> * Akim Juillerat <akim.juillerat@camptocamp.com>
* Alexis de Lattre <alexis@via.ecp.fr> * Alexis de Lattre <alexis@via.ecp.fr>
@ -128,6 +128,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/11.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. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

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

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

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

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

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

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

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

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

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

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

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

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

49
account_financial_report/menuitems.xml

@ -50,53 +50,4 @@
sequence="50" sequence="50"
/> />
<!-- Hide odoo PDF reports menu -->
<menuitem
id="account.menu_finance_legal_statement"
name="PDF Reports"
parent="account.menu_finance_reports"
groups="base.group_erp_manager"
/>
<!--
<menuitem
id="account.menu_general_ledger"
name="General Ledger"
parent="account.menu_finance_legal_statement"
action="account.action_account_general_ledger_menu"
groups="base.group_erp_manager"
/>
<menuitem
id="account.menu_general_Balance_report"
name="Trial Balance"
parent="account.menu_finance_legal_statement"
action="account.action_account_balance_menu"
groups="base.group_erp_manager"
/>
<menuitem
id="account.menu_account_report_bs"
name="Balance Sheet"
action="account.action_account_report_bs"
parent="account.menu_finance_legal_statement"
groups="base.group_erp_manager"
/>
<menuitem
id="account.menu_account_report_pl"
name="Profit and Loss"
action="account.action_account_report_pl"
parent="account.menu_finance_legal_statement"
groups="base.group_erp_manager"
/>
<menuitem
id="account.menu_aged_trial_balance"
name="Aged Partner Balance"
action="account.action_account_aged_balance_view"
parent="account.menu_finance_legal_statement"
groups="base.group_erp_manager"
/>-->
</odoo> </odoo>

2
account_financial_report/readme/CONTRIBUTORS.rst

@ -9,7 +9,7 @@
* Robert Rottermann <robert@redcor.ch> * Robert Rottermann <robert@redcor.ch>
* Ciro Urselli <c.urselli@apuliasoftware.it> * Ciro Urselli <c.urselli@apuliasoftware.it>
* Francesco Apruzzese <opencode@e-ware.org> * Francesco Apruzzese <opencode@e-ware.org>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* Lorenzo Battistini <https://github.com/eLBati>
* Julien Coux <julien.coux@camptocamp.com> * Julien Coux <julien.coux@camptocamp.com>
* Akim Juillerat <akim.juillerat@camptocamp.com> * Akim Juillerat <akim.juillerat@camptocamp.com>
* Alexis de Lattre <alexis@via.ecp.fr> * Alexis de Lattre <alexis@via.ecp.fr>

15
account_financial_report/report/abstract_report.py

@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models from odoo import models
from psycopg2.extensions import AsIs
class AbstractReport(models.AbstractModel): class AbstractReport(models.AbstractModel):
@ -13,10 +14,10 @@ class AbstractReport(models.AbstractModel):
"Model %s is not transient, it cannot be vacuumed!" % self._name "Model %s is not transient, it cannot be vacuumed!" % self._name
# Never delete rows used in last 5 minutes # Never delete rows used in last 5 minutes
seconds = max(seconds, 300) 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, (self._table, "%s seconds" % seconds,))
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))

5
account_financial_report/report/abstract_report_xlsx.py

@ -2,8 +2,7 @@
# Author: Julien Coux # Author: Julien Coux
# Copyright 2016 Camptocamp SA # Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
from odoo import models, fields
import datetime import datetime
@ -191,7 +190,7 @@ class AbstractReportXslx(models.AbstractModel):
for col_pos, column in self.columns.items(): for col_pos, column in self.columns.items():
value = getattr(line_object, column['field']) value = getattr(line_object, column['field'])
if isinstance(value, datetime.date): if isinstance(value, datetime.date):
value = datetime.datetime.strftime(value, DEFAULT_SERVER_DATE_FORMAT)
value = fields.Date.to_string(value)
cell_type = column.get('type', 'string') cell_type = column.get('type', 'string')
if cell_type == 'many2one': if cell_type == 'many2one':
self.sheet.write_string( self.sheet.write_string(

3
account_financial_report/report/general_ledger.py

@ -224,7 +224,8 @@ class GeneralLedgerReportCompute(models.TransientModel):
'report_general_ledger_qweb' 'report_general_ledger_qweb'
return self.env['ir.actions.report'].search( return self.env['ir.actions.report'].search(
[('report_name', '=', report_name), [('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self, config=False)
('report_type', '=', report_type)],
limit=1).report_action(self, config=False)
def _get_html(self): def _get_html(self):
result = {} result = {}

3
account_financial_report/report/journal_ledger.py

@ -594,7 +594,8 @@ class ReportJournalLedger(models.TransientModel):
'report_journal_ledger_qweb' 'report_journal_ledger_qweb'
return self.env['ir.actions.report'].search( return self.env['ir.actions.report'].search(
[('report_name', '=', report_name), [('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self, config=False)
('report_type', '=', report_type)],
limit=1).report_action(self, config=False)
def _get_html(self): def _get_html(self):
result = {} result = {}

94
account_financial_report/report/open_items.py

@ -160,7 +160,8 @@ class OpenItemsReportCompute(models.TransientModel):
'report_open_items_qweb' 'report_open_items_qweb'
return self.env['ir.actions.report'].search( return self.env['ir.actions.report'].search(
[('report_name', '=', report_name), [('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self, config=False)
('report_type', '=', report_type)],
limit=1).report_action(self, config=False)
def _get_html(self): def _get_html(self):
result = {} result = {}
@ -638,21 +639,6 @@ ORDER BY
self._compute_account_cumul() self._compute_account_cumul()
def _compute_partner_cumul(self): def _compute_partner_cumul(self):
# pylint: disable=sql-injection
where_condition_partner_by_account = """
WHERE
id IN
(
SELECT
rp.id
FROM
report_open_items_account ra
INNER JOIN
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s
)"""
query_computer_partner_residual_cumul = """ query_computer_partner_residual_cumul = """
UPDATE UPDATE
report_open_items_partner report_open_items_partner
@ -666,7 +652,20 @@ SET
WHERE WHERE
rml.report_partner_id = report_open_items_partner.id rml.report_partner_id = report_open_items_partner.id
) )
""" + where_condition_partner_by_account
WHERE
id IN
(
SELECT
rp.id
FROM
report_open_items_account ra
INNER JOIN
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s
)
"""
params_compute_partners_residual_cumul = (self.id,) params_compute_partners_residual_cumul = (self.id,)
self.env.cr.execute(query_computer_partner_residual_cumul, self.env.cr.execute(query_computer_partner_residual_cumul,
params_compute_partners_residual_cumul) params_compute_partners_residual_cumul)
@ -684,13 +683,6 @@ SET
WHERE WHERE
rml.report_partner_id = report_open_items_partner.id rml.report_partner_id = report_open_items_partner.id
) )
""" + where_condition_partner_by_account
params_compute_partner_due_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_due_cumul,
params_compute_partner_due_cumul)
# Manage currency in partner
where_condition_partner_by_account_cur = """
WHERE WHERE
id IN id IN
( (
@ -702,9 +694,14 @@ WHERE
report_open_items_partner rp report_open_items_partner rp
ON ra.id = rp.report_account_id ON ra.id = rp.report_account_id
WHERE WHERE
ra.report_id = %s AND ra.currency_id IS NOT NULL
ra.report_id = %s
) )
"""
"""
params_compute_partner_due_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_due_cumul,
params_compute_partner_due_cumul)
# Manage currency in partner
query_compute_partners_cur_id_cumul = """ query_compute_partners_cur_id_cumul = """
UPDATE UPDATE
report_open_items_partner report_open_items_partner
@ -718,7 +715,20 @@ SET
WHERE WHERE
rml.report_partner_id = report_open_items_partner.id rml.report_partner_id = report_open_items_partner.id
) )
""" + where_condition_partner_by_account_cur
WHERE
id IN
(
SELECT
rp.id
FROM
report_open_items_account ra
INNER JOIN
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s AND ra.currency_id IS NOT NULL
)
"""
params_compute_partners_cur_id_cumul = (self.id,) params_compute_partners_cur_id_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_id_cumul, self.env.cr.execute(query_compute_partners_cur_id_cumul,
params_compute_partners_cur_id_cumul) params_compute_partners_cur_id_cumul)
@ -737,7 +747,20 @@ SET
WHERE WHERE
rml.report_partner_id = report_open_items_partner.id rml.report_partner_id = report_open_items_partner.id
) )
""" + where_condition_partner_by_account_cur
WHERE
id IN
(
SELECT
rp.id
FROM
report_open_items_account ra
INNER JOIN
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s AND ra.currency_id IS NOT NULL
)
"""
params_compute_partners_cur_residual_cumul = (self.id,) params_compute_partners_cur_residual_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_residual_cumul, self.env.cr.execute(query_compute_partners_cur_residual_cumul,
params_compute_partners_cur_residual_cumul) params_compute_partners_cur_residual_cumul)
@ -756,7 +779,20 @@ SET
WHERE WHERE
rml.report_partner_id = report_open_items_partner.id rml.report_partner_id = report_open_items_partner.id
) )
""" + where_condition_partner_by_account_cur
WHERE
id IN
(
SELECT
rp.id
FROM
report_open_items_account ra
INNER JOIN
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s AND ra.currency_id IS NOT NULL
)
"""
params_compute_partners_cur_due_cumul = (self.id,) params_compute_partners_cur_due_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_due_cumul, self.env.cr.execute(query_compute_partners_cur_due_cumul,
params_compute_partners_cur_due_cumul) params_compute_partners_cur_due_cumul)

12
account_financial_report/report/templates/general_ledger.xml

@ -189,7 +189,7 @@
<t t-if="type == 'account_type'"> <t t-if="type == 'account_type'">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id), t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/> ('debit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -203,7 +203,7 @@
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id), t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id), ('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/> ('debit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -219,7 +219,7 @@
<t t-if="type == 'account_type'"> <t t-if="type == 'account_type'">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id), t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/> ('credit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -233,7 +233,7 @@
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id), t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id), ('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/> ('credit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -249,7 +249,7 @@
<t t-if="type == 'account_type'"> <t t-if="type == 'account_type'">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id), t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'" t-att-data-res-model="'account.move.line'"
@ -262,7 +262,7 @@
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id), t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id), ('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'" t-att-data-res-model="'account.move.line'"

58
account_financial_report/report/templates/trial_balance.xml

@ -246,7 +246,7 @@
<t t-if="line.account_id"> <t t-if="line.account_id">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', line.account_id.id), t-value="[('account_id', '=', line.account_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'" t-att-data-res-model="'account.move.line'"
@ -258,7 +258,7 @@
<t t-if="line.account_group_id"> <t t-if="line.account_group_id">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids), t-value="[('account_id', 'in', line.compute_account_ids.ids),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'" t-att-data-res-model="'account.move.line'"
@ -272,7 +272,7 @@
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id), t-value="[('account_id', '=', line.report_account_id.account_id.id),
('partner_id', '=', line.partner_id.id), ('partner_id', '=', line.partner_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'" t-att-data-res-model="'account.move.line'"
@ -288,8 +288,8 @@
<t t-if="line.account_id"> <t t-if="line.account_id">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', line.account_id.id), t-value="[('account_id', '=', line.account_id.id),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to),
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/> ('debit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -302,8 +302,8 @@
<t t-if="line.account_group_id"> <t t-if="line.account_group_id">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids), t-value="[('account_id', 'in', line.compute_account_ids.ids),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to),
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/> ('debit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -318,8 +318,8 @@
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id), t-value="[('account_id', '=', line.report_account_id.account_id.id),
('partner_id', '=', line.partner_id.id), ('partner_id', '=', line.partner_id.id),
('date', '&gt;=', line.report_account_id.report_id.date_from),
('date', '&lt;=', line.report_account_id.report_id.date_to),
('date', '&gt;=', line.report_account_id.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_account_id.report_id.date_to.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/> ('debit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -336,8 +336,8 @@
<t t-if="line.account_id"> <t t-if="line.account_id">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', line.account_id.id), t-value="[('account_id', '=', line.account_id.id),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to),
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/> ('credit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -350,8 +350,8 @@
<t t-if="line.account_group_id"> <t t-if="line.account_group_id">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids), t-value="[('account_id', 'in', line.compute_account_ids.ids),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to),
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/> ('credit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -366,8 +366,8 @@
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id), t-value="[('account_id', '=', line.report_account_id.account_id.id),
('partner_id', '=', line.partner_id.id), ('partner_id', '=', line.partner_id.id),
('date', '&gt;=', line.report_account_id.report_id.date_from),
('date', '&lt;=', line.report_account_id.report_id.date_to),
('date', '&gt;=', line.report_account_id.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_account_id.report_id.date_to.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/> ('credit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -384,8 +384,8 @@
<t t-if="line.account_id"> <t t-if="line.account_id">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', line.account_id.id), t-value="[('account_id', '=', line.account_id.id),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to)]"/>
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d'))]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'" t-att-data-res-model="'account.move.line'"
@ -397,8 +397,8 @@
<t t-if="line.account_group_id"> <t t-if="line.account_group_id">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids), t-value="[('account_id', 'in', line.compute_account_ids.ids),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to)]"/>
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d'))]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'" t-att-data-res-model="'account.move.line'"
@ -412,8 +412,8 @@
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id), t-value="[('account_id', '=', line.report_account_id.account_id.id),
('partner_id', '=', line.partner_id.id), ('partner_id', '=', line.partner_id.id),
('date', '&gt;=', line.report_account_id.report_id.date_from),
('date', '&lt;=', line.report_account_id.report_id.date_to)]"/>
('date', '&gt;=', line.report_account_id.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_account_id.report_id.date_to.strftime('%Y-%m-%d'))]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'" t-att-data-res-model="'account.move.line'"
@ -576,7 +576,7 @@
<div class="act_as_cell amount" style="width: 9.64%;"> <div class="act_as_cell amount" style="width: 9.64%;">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', account.account_id.id), t-value="[('account_id', '=', account.account_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'" t-att-data-res-model="'account.move.line'"
@ -589,8 +589,8 @@
<div class="act_as_cell amount" style="width: 9.64%;"> <div class="act_as_cell amount" style="width: 9.64%;">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', account.account_id.id), t-value="[('account_id', '=', account.account_id.id),
('date', '&gt;=', account.report_id.date_from),
('date', '&lt;=', account.report_id.date_to),
('date', '&gt;=', account.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', account.report_id.date_to.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/> ('debit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -604,8 +604,8 @@
<div class="act_as_cell amount" style="width: 9.64%;"> <div class="act_as_cell amount" style="width: 9.64%;">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', account.account_id.id), t-value="[('account_id', '=', account.account_id.id),
('date', '&gt;=', account.report_id.date_from),
('date', '&lt;=', account.report_id.date_to),
('date', '&gt;=', account.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', account.report_id.date_to.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/> ('credit', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -619,8 +619,8 @@
<div class="act_as_cell amount" style="width: 9.64%;"> <div class="act_as_cell amount" style="width: 9.64%;">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', account.account_id.id), t-value="[('account_id', '=', account.account_id.id),
('date', '&gt;=', account.report_id.date_from),
('date', '&lt;=', account.report_id.date_to),
('date', '&gt;=', account.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', account.report_id.date_to.strftime('%Y-%m-%d')),
('period_balance', '&lt;&gt;', 0)]"/> ('period_balance', '&lt;&gt;', 0)]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
@ -654,7 +654,7 @@
<div class="act_as_cell amount" style="width: 8.86%;"> <div class="act_as_cell amount" style="width: 8.86%;">
<t t-set="domain" <t t-set="domain"
t-value="[('account_id', '=', account.account_id.id), t-value="[('account_id', '=', account.account_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span> <span>
<a t-att-data-domain="domain" <a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'" t-att-data-res-model="'account.move.line'"

13
account_financial_report/report/trial_balance.py

@ -74,8 +74,10 @@ class TrialBalanceReportAccount(models.TransientModel):
index=True index=True
) )
hide_line = fields.Boolean(compute='_compute_hide_line') hide_line = fields.Boolean(compute='_compute_hide_line')
# Data fields, used to keep link with real object
sequence = fields.Integer(index=True, default=1)
# Data fields, used to keep link with real object.
# Sequence is a Char later built with 'parent_path' for groups
# and parent_path + account code for accounts
sequence = fields.Char(index=True, default='1')
level = fields.Integer(index=True, default=1) level = fields.Integer(index=True, default=1)
# Data fields, used to keep link with real object # Data fields, used to keep link with real object
@ -209,7 +211,8 @@ class TrialBalanceReportCompute(models.TransientModel):
'report_trial_balance_qweb' 'report_trial_balance_qweb'
return self.env['ir.actions.report'].search( return self.env['ir.actions.report'].search(
[('report_name', '=', report_name), [('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self, config=False)
('report_type', '=', report_type)],
limit=1).report_action(self, config=False)
def _get_html(self): def _get_html(self):
result = {} result = {}
@ -410,7 +413,7 @@ SELECT
accgroup.parent_id, accgroup.parent_id,
coalesce(accgroup.code_prefix, accgroup.name), coalesce(accgroup.code_prefix, accgroup.name),
accgroup.name, accgroup.name,
accgroup.id * 100000,
accgroup.parent_path,
accgroup.level accgroup.level
FROM FROM
account_group accgroup""" account_group accgroup"""
@ -557,7 +560,7 @@ WHERE report_trial_balance_account.account_group_id = accgroup.id
"""Compute sequence, level for report_trial_balance_account account.""" """Compute sequence, level for report_trial_balance_account account."""
query_update_account_group = """ query_update_account_group = """
UPDATE report_trial_balance_account UPDATE report_trial_balance_account
SET sequence = newline.sequence + 1,
SET sequence = CONCAT(newline.sequence, newline.code),
level = newline.level + 1 level = newline.level + 1
FROM report_trial_balance_account as newline FROM report_trial_balance_account as newline
WHERE newline.account_group_id = report_trial_balance_account.parent_id WHERE newline.account_group_id = report_trial_balance_account.parent_id

8
account_financial_report/static/description/index.html

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! 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/11.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-11-0/account-financial-reporting-11-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/11.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 <p>This module adds a set of financial reports. They are accessible under
Accounting / Reporting / OCA Reports.</p> Accounting / Reporting / OCA Reports.</p>
<ul class="simple"> <ul class="simple">
@ -431,7 +431,7 @@ currency balances are not available.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues">GitHub Issues</a>. <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. 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 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:%2011.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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -459,7 +459,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Robert Rottermann &lt;<a class="reference external" href="mailto:robert&#64;redcor.ch">robert&#64;redcor.ch</a>&gt;</li> <li>Robert Rottermann &lt;<a class="reference external" href="mailto:robert&#64;redcor.ch">robert&#64;redcor.ch</a>&gt;</li>
<li>Ciro Urselli &lt;<a class="reference external" href="mailto:c.urselli&#64;apuliasoftware.it">c.urselli&#64;apuliasoftware.it</a>&gt;</li> <li>Ciro Urselli &lt;<a class="reference external" href="mailto:c.urselli&#64;apuliasoftware.it">c.urselli&#64;apuliasoftware.it</a>&gt;</li>
<li>Francesco Apruzzese &lt;<a class="reference external" href="mailto:opencode&#64;e-ware.org">opencode&#64;e-ware.org</a>&gt;</li> <li>Francesco Apruzzese &lt;<a class="reference external" href="mailto:opencode&#64;e-ware.org">opencode&#64;e-ware.org</a>&gt;</li>
<li>Lorenzo Battistini &lt;<a class="reference external" href="mailto:lorenzo.battistini&#64;agilebg.com">lorenzo.battistini&#64;agilebg.com</a>&gt;</li>
<li>Lorenzo Battistini &lt;<a class="reference external" href="https://github.com/eLBati">https://github.com/eLBati</a>&gt;</li>
<li>Julien Coux &lt;<a class="reference external" href="mailto:julien.coux&#64;camptocamp.com">julien.coux&#64;camptocamp.com</a>&gt;</li> <li>Julien Coux &lt;<a class="reference external" href="mailto:julien.coux&#64;camptocamp.com">julien.coux&#64;camptocamp.com</a>&gt;</li>
<li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li> <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>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis&#64;via.ecp.fr">alexis&#64;via.ecp.fr</a>&gt;</li>
@ -476,7 +476,7 @@ April 2016.</p>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> 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/11.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> <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>
</div> </div>

2
account_financial_report/static/src/less/report.less → account_financial_report/static/src/css/report.css

@ -95,8 +95,6 @@
} }
.o_account_financial_reports_page { .o_account_financial_reports_page {
background-color: @odoo-view-background-color;
color: @odoo-main-text-color;
padding-top: 10px; padding-top: 10px;
width: 90%; width: 90%;
margin-right: auto; margin-right: auto;

39
account_financial_report/static/src/js/account_financial_report_backend.js

@ -27,7 +27,7 @@ odoo.define('account_financial_report.account_financial_report_backend', functio
action.params.active_id; action.params.active_id;
this.given_context.model = action.context.active_model || false; this.given_context.model = action.context.active_model || false;
this.given_context.ttype = action.context.ttype || false; this.given_context.ttype = action.context.ttype || false;
return this._super.apply (this, arguments);
return this._super.apply(this, arguments);
}, },
willStart: function () { willStart: function () {
return $.when(this.get_html()); return $.when(this.get_html());
@ -43,12 +43,13 @@ odoo.define('account_financial_report.account_financial_report_backend', functio
self.report_widget.$el.html(self.html); self.report_widget.$el.html(self.html);
}); });
}, },
start: function() {
start: function () {
this.set_html(); this.set_html();
return this._super(); return this._super();
}, },
// Fetches the html and is previous report.context if any, else create it
get_html: function() {
// Fetches the html and is previous report.context if any,
// else create it
get_html: function () {
var self = this; var self = this;
var defs = []; var defs = [];
return this._rpc({ return this._rpc({
@ -63,31 +64,6 @@ odoo.define('account_financial_report.account_financial_report_backend', functio
return $.when.apply($, defs); return $.when.apply($, 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);
}
},
do_show: function() {
this._super();
this.update_cp();
},
print: function() {
var self = this;
this._rpc({
model: this.given_context.model,
method: 'print_report',
args: [this.given_context.active_id, 'qweb-pdf'],
context: self.odoo_context,
}).then(function(result){
self.do_action(result);
});
},
// Updates the control panel and render the elements that have yet // Updates the control panel and render the elements that have yet
// to be rendered // to be rendered
update_cp: function () { update_cp: function () {
@ -110,7 +86,7 @@ odoo.define('account_financial_report.account_financial_report_backend', functio
method: 'print_report', method: 'print_report',
args: [this.given_context.active_id, 'qweb-pdf'], args: [this.given_context.active_id, 'qweb-pdf'],
context: self.odoo_context, context: self.odoo_context,
}).then(function(result){
}).then(function (result) {
self.do_action(result); self.do_action(result);
}); });
}, },
@ -121,8 +97,7 @@ odoo.define('account_financial_report.account_financial_report_backend', functio
method: 'print_report', method: 'print_report',
args: [this.given_context.active_id, 'xlsx'], args: [this.given_context.active_id, 'xlsx'],
context: self.odoo_context, context: self.odoo_context,
})
.then(function(result){
}).then(function (result) {
self.do_action(result); self.do_action(result);
}); });
}, },

27
account_financial_report/tests/test_general_ledger.py

@ -5,7 +5,8 @@
import time import time
from odoo.tests import common from odoo.tests import common
from datetime import date, datetime
from odoo import fields
from datetime import date
from . import abstract_test_foreign_currency as a_t_f_c from . import abstract_test_foreign_currency as a_t_f_c
@ -88,11 +89,11 @@ class TestGeneralLedgerReport(common.TransactionCase):
def setUp(self): def setUp(self):
super(TestGeneralLedgerReport, self).setUp() super(TestGeneralLedgerReport, self).setUp()
self.before_previous_fy_year = datetime.strptime('2014-05-05', '%Y-%m-%d')
self.previous_fy_date_start = datetime.strptime('2015-01-01', '%Y-%m-%d')
self.previous_fy_date_end = datetime.strptime('2015-12-31', '%Y-%m-%d')
self.fy_date_start = datetime.strptime('2016-01-01', '%Y-%m-%d')
self.fy_date_end = datetime.strptime('2016-12-31', '%Y-%m-%d')
self.before_previous_fy_year = fields.Date.from_string('2014-05-05')
self.previous_fy_date_start = fields.Date.from_string('2015-01-01')
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([ self.receivable_account = self.env['account.account'].search([
('user_type_id.name', '=', 'Receivable') ('user_type_id.name', '=', 'Receivable')
], limit=1) ], limit=1)
@ -121,7 +122,6 @@ class TestGeneralLedgerReport(common.TransactionCase):
partner = self.env.ref('base.res_partner_12') partner = self.env.ref('base.res_partner_12')
move_vals = { move_vals = {
'journal_id': journal.id, 'journal_id': journal.id,
'partner_id': partner.id,
'name': move_name, 'name': move_name,
'date': date, 'date': date,
'line_ids': [ 'line_ids': [
@ -129,17 +129,20 @@ class TestGeneralLedgerReport(common.TransactionCase):
'name': move_name, 'name': move_name,
'debit': receivable_debit, 'debit': receivable_debit,
'credit': receivable_credit, 'credit': receivable_credit,
'account_id': self.receivable_account.id}),
'account_id': self.receivable_account.id,
'partner_id': partner.id}),
(0, 0, { (0, 0, {
'name': move_name, 'name': move_name,
'debit': income_debit, 'debit': income_debit,
'credit': income_credit, 'credit': income_credit,
'account_id': self.income_account.id}),
'account_id': self.income_account.id,
'partner_id': partner.id}),
(0, 0, { (0, 0, {
'name': move_name, 'name': move_name,
'debit': unaffected_debit, 'debit': unaffected_debit,
'credit': unaffected_credit, 'credit': unaffected_credit,
'account_id': self.unaffected_account.id}),
'account_id': self.unaffected_account.id,
'partner_id': partner.id}),
]} ]}
move = self.env['account.move'].create(move_vals) move = self.env['account.move'].create(move_vals)
move.post() move.post()
@ -546,5 +549,5 @@ class TestGeneralLedgerReport(common.TransactionCase):
wizard = self.env["general.ledger.report.wizard"].create({ wizard = self.env["general.ledger.report.wizard"].create({
'date_range_id': dr.id}) 'date_range_id': dr.id})
wizard.onchange_date_range_id() wizard.onchange_date_range_id()
self.assertEqual(wizard.date_from, '2018-01-01')
self.assertEqual(wizard.date_to, '2018-12-31')
self.assertEqual(wizard.date_from, date(2018, 1, 1))
self.assertEqual(wizard.date_to, date(2018, 12, 31))

2
account_financial_report/tests/test_journal_ledger.py

@ -1,8 +1,6 @@
# Copyright 2017 ACSONE SA/NV # Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import time
from datetime import datetime, date from datetime import datetime, date
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta

7
account_financial_report/tests/test_trial_balance.py

@ -2,7 +2,6 @@
# Copyright 2016 Camptocamp SA # Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
from datetime import date from datetime import date
from odoo.tests import common from odoo.tests import common
from . import abstract_test_foreign_currency as a_t_f_c from . import abstract_test_foreign_currency as a_t_f_c
@ -131,7 +130,6 @@ class TestTrialBalanceReport(common.TransactionCase):
partner = self.env.ref('base.res_partner_12') partner = self.env.ref('base.res_partner_12')
move_vals = { move_vals = {
'journal_id': journal.id, 'journal_id': journal.id,
'partner_id': partner.id,
'name': move_name, 'name': move_name,
'date': date, 'date': date,
'line_ids': [ 'line_ids': [
@ -139,26 +137,31 @@ class TestTrialBalanceReport(common.TransactionCase):
'name': move_name, 'name': move_name,
'debit': receivable_debit, 'debit': receivable_debit,
'credit': receivable_credit, 'credit': receivable_credit,
'partner_id': partner.id,
'account_id': self.account100.id}), 'account_id': self.account100.id}),
(0, 0, { (0, 0, {
'name': move_name, 'name': move_name,
'debit': income_debit, 'debit': income_debit,
'credit': income_credit, 'credit': income_credit,
'partner_id': partner.id,
'account_id': self.account200.id}), 'account_id': self.account200.id}),
(0, 0, { (0, 0, {
'name': move_name, 'name': move_name,
'debit': unaffected_debit, 'debit': unaffected_debit,
'credit': unaffected_credit, 'credit': unaffected_credit,
'partner_id': partner.id,
'account_id': self.account110.id}), 'account_id': self.account110.id}),
(0, 0, { (0, 0, {
'name': move_name, 'name': move_name,
'debit': receivable_debit, 'debit': receivable_debit,
'credit': receivable_credit, 'credit': receivable_credit,
'partner_id': partner.id,
'account_id': self.account300.id}), 'account_id': self.account300.id}),
(0, 0, { (0, 0, {
'name': move_name, 'name': move_name,
'debit': receivable_credit, 'debit': receivable_credit,
'credit': receivable_debit, 'credit': receivable_debit,
'partner_id': partner.id,
'account_id': self.account301.id}) 'account_id': self.account301.id})
]} ]}
move = self.env['account.move'].create(move_vals) move = self.env['account.move'].create(move_vals)

17
account_financial_report/tests/test_vat_report.py

@ -110,7 +110,7 @@ class TestVATReport(common.TransactionCase):
'account_id': self.tax_account.id, 'account_id': self.tax_account.id,
'company_id': self.company.id, 'company_id': self.company.id,
'refund_account_id': self.tax_account.id, 'refund_account_id': self.tax_account.id,
'cash_basis_account': self.tax_account.id,
'cash_basis_account_id': self.tax_account.id,
'tax_group_id': self.tax_group_20.id, 'tax_group_id': self.tax_group_20.id,
'tag_ids': [(6, 0, [self.tax_tag_02.id, self.tax_tag_03.id])] 'tag_ids': [(6, 0, [self.tax_tag_02.id, self.tax_tag_03.id])]
}) })
@ -157,7 +157,8 @@ class TestVATReport(common.TransactionCase):
def _get_report_lines(self): def _get_report_lines(self):
self.cbinvoice.pay_and_reconcile( self.cbinvoice.pay_and_reconcile(
self.bank_journal.id, 300, date(date.today().year, date.today().month, 10))
self.bank_journal.id, 300, date(
date.today().year, date.today().month, 10))
vat_report = self.env['report_vat_report'].create({ vat_report = self.env['report_vat_report'].create({
'date_from': self.date_from, 'date_from': self.date_from,
'date_to': self.date_to, 'date_to': self.date_to,
@ -274,8 +275,10 @@ class TestVATReport(common.TransactionCase):
'date_to': time.strftime('%Y-%m-01'), 'date_to': time.strftime('%Y-%m-01'),
'tax_detail': True}) 'tax_detail': True})
wizard.onchange_date_range_id() wizard.onchange_date_range_id()
self.assertEqual(wizard.date_from, date(date.today().year, 1, 1))
self.assertEqual(wizard.date_to, date(date.today().year, date.today().month, 28))
self.assertEqual(wizard.date_from, date(
date.today().year, date.today().month, 1))
self.assertEqual(wizard.date_to, date(
date.today().year, date.today().month, 28))
wizard._export('qweb-pdf') wizard._export('qweb-pdf')
wizard.button_export_html() wizard.button_export_html()
wizard.button_export_pdf() wizard.button_export_pdf()
@ -287,8 +290,10 @@ class TestVATReport(common.TransactionCase):
'based_on': 'taxgroups', 'based_on': 'taxgroups',
'tax_detail': True}) 'tax_detail': True})
wizard.onchange_date_range_id() wizard.onchange_date_range_id()
self.assertEqual(wizard.date_from, date(date.today().year, 1, 1))
self.assertEqual(wizard.date_to, date(date.today().year, date.today().month, 28))
self.assertEqual(wizard.date_from, date(
date.today().year, date.today().month, 1))
self.assertEqual(wizard.date_to, date(
date.today().year, date.today().month, 28))
wizard._export('qweb-pdf') wizard._export('qweb-pdf')
wizard.button_export_html() wizard.button_export_html()
wizard.button_export_pdf() wizard.button_export_pdf()

3
account_financial_report/view/report_template.xml

@ -4,13 +4,14 @@
<template id="account_financial_report_assets_backend" <template id="account_financial_report_assets_backend"
name="account_financial_report assets" inherit_id="web.assets_backend"> name="account_financial_report assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside"> <xpath expr="." position="inside">
<link href="/account_financial_report/static/src/less/report.less" rel="stylesheet"/>
<link href="/account_financial_report/static/src/css/report.css" rel="stylesheet"/>
<script type="text/javascript" <script type="text/javascript"
src="/account_financial_report/static/src/js/account_financial_report_backend.js"/> src="/account_financial_report/static/src/js/account_financial_report_backend.js"/>
<script type="text/javascript" <script type="text/javascript"
src="/account_financial_report/static/src/js/account_financial_report_widgets.js"/> src="/account_financial_report/static/src/js/account_financial_report_widgets.js"/>
</xpath> </xpath>
</template> </template>
<template id="report_buttons"> <template id="report_buttons">
<div class="button_row"> <div class="button_row">
<button class="o_account_financial_reports_print btn btn-sm oe_button"><span class="fa fa-print"/> Print</button> <button class="o_account_financial_reports_print btn btn-sm oe_button"><span class="fa fa-print"/> Print</button>

1
account_financial_report/wizard/__init__.py

@ -1,3 +1,4 @@
from . import abstract_wizard
from . import aged_partner_balance_wizard from . import aged_partner_balance_wizard
from . import general_ledger_wizard from . import general_ledger_wizard
from . import journal_ledger_wizard from . import journal_ledger_wizard

32
account_financial_report/wizard/abstract_wizard.py

@ -0,0 +1,32 @@
# Copyright 2019 Lorenzo Battistini @ TAKOBI
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class AbstractWizard(models.AbstractModel):
_name = 'account_financial_report_abstract_wizard'
_description = 'Abstract Wizard'
def _get_partner_ids_domain(self):
return [
'&',
'|',
('company_id', '=', self.company_id.id),
('company_id', '=', False),
'|',
('parent_id', '=', False),
('is_company', '=', True),
]
def _default_partners(self):
context = self.env.context
if (
context.get('active_ids') and
context.get('active_model') == 'res.partner'
):
partners = self.env['res.partner'].browse(context['active_ids'])
corp_partners = partners.filtered('parent_id')
partners -= corp_partners
partners |= corp_partners.mapped('commercial_partner_id')
return partners.ids

7
account_financial_report/wizard/aged_partner_balance_wizard.py

@ -13,6 +13,7 @@ class AgedPartnerBalanceWizard(models.TransientModel):
_name = 'aged.partner.balance.wizard' _name = 'aged.partner.balance.wizard'
_description = 'Aged Partner Balance Wizard' _description = 'Aged Partner Balance Wizard'
_inherit = 'account_financial_report_abstract_wizard'
company_id = fields.Many2one( company_id = fields.Many2one(
comodel_name='res.company', comodel_name='res.company',
@ -59,11 +60,7 @@ class AgedPartnerBalanceWizard(models.TransientModel):
else: else:
res['domain']['account_ids'] += [ res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)] ('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += [
'&',
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False),
('parent_id', '=', False)]
res['domain']['partner_ids'] += self._get_partner_ids_domain()
return res return res
@api.onchange('receivable_accounts_only', 'payable_accounts_only') @api.onchange('receivable_accounts_only', 'payable_accounts_only')

25
account_financial_report/wizard/general_ledger_wizard.py

@ -9,10 +9,9 @@
from odoo import api, fields, models, _ from odoo import api, fields, models, _
from odoo.tools.safe_eval import safe_eval from odoo.tools.safe_eval import safe_eval
from odoo.tools import pycompat, DEFAULT_SERVER_DATE_FORMAT
from odoo.tools import pycompat
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
import time import time
from datetime import datetime
class GeneralLedgerReportWizard(models.TransientModel): class GeneralLedgerReportWizard(models.TransientModel):
@ -20,6 +19,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
_name = "general.ledger.report.wizard" _name = "general.ledger.report.wizard"
_description = "General Ledger Report Wizard" _description = "General Ledger Report Wizard"
_inherit = 'account_financial_report_abstract_wizard'
company_id = fields.Many2one( company_id = fields.Many2one(
comodel_name='res.company', comodel_name='res.company',
@ -104,25 +104,12 @@ class GeneralLedgerReportWizard(models.TransientModel):
def _default_foreign_currency(self): def _default_foreign_currency(self):
return self.env.user.has_group('base.group_multi_currency') return self.env.user.has_group('base.group_multi_currency')
def _default_partners(self):
context = self.env.context
if context.get('active_ids') and context.get('active_model') \
== 'res.partner':
partner_ids = context['active_ids']
corp_partners = self.env['res.partner'].browse(partner_ids). \
filtered(lambda p: p.parent_id)
partner_ids = set(partner_ids) - set(corp_partners.ids)
partner_ids |= set(corp_partners.mapped('parent_id.id'))
return list(partner_ids)
@api.depends('date_from') @api.depends('date_from')
def _compute_fy_start_date(self): def _compute_fy_start_date(self):
for wiz in self.filtered('date_from'): for wiz in self.filtered('date_from'):
date = fields.Datetime.from_string(wiz.date_from) date = fields.Datetime.from_string(wiz.date_from)
res = self.company_id.compute_fiscalyear_dates(date) res = self.company_id.compute_fiscalyear_dates(date)
wiz.fy_start_date = datetime.strftime(res['date_from'], DEFAULT_SERVER_DATE_FORMAT)
wiz.fy_start_date = fields.Date.to_string(res['date_from'])
@api.onchange('company_id') @api.onchange('company_id')
def onchange_company_id(self): def onchange_company_id(self):
@ -168,11 +155,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
('company_id', '=', self.company_id.id)] ('company_id', '=', self.company_id.id)]
res['domain']['account_journal_ids'] += [ res['domain']['account_journal_ids'] += [
('company_id', '=', self.company_id.id)] ('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += [
'&',
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False),
('parent_id', '=', False)]
res['domain']['partner_ids'] += self._get_partner_ids_domain()
res['domain']['cost_center_ids'] += [ res['domain']['cost_center_ids'] += [
('company_id', '=', self.company_id.id)] ('company_id', '=', self.company_id.id)]
res['domain']['date_range_id'] += [ res['domain']['date_range_id'] += [

20
account_financial_report/wizard/open_items_wizard.py

@ -13,6 +13,7 @@ class OpenItemsReportWizard(models.TransientModel):
_name = "open.items.report.wizard" _name = "open.items.report.wizard"
_description = "Open Items Report Wizard" _description = "Open Items Report Wizard"
_inherit = 'account_financial_report_abstract_wizard'
company_id = fields.Many2one( company_id = fields.Many2one(
comodel_name='res.company', comodel_name='res.company',
@ -57,19 +58,6 @@ class OpenItemsReportWizard(models.TransientModel):
def _default_foreign_currency(self): def _default_foreign_currency(self):
return self.env.user.has_group('base.group_multi_currency') return self.env.user.has_group('base.group_multi_currency')
def _default_partners(self):
context = self.env.context
if context.get('active_ids') and context.get('active_model') \
== 'res.partner':
partner_ids = context['active_ids']
corp_partners = self.env['res.partner'].browse(partner_ids). \
filtered(lambda p: p.parent_id)
partner_ids = set(partner_ids) - set(corp_partners.ids)
partner_ids |= set(corp_partners.mapped('parent_id.id'))
return list(partner_ids)
@api.onchange('company_id') @api.onchange('company_id')
def onchange_company_id(self): def onchange_company_id(self):
"""Handle company change.""" """Handle company change."""
@ -90,11 +78,7 @@ class OpenItemsReportWizard(models.TransientModel):
else: else:
res['domain']['account_ids'] += [ res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)] ('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += [
'&',
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False),
('parent_id', '=', False)]
res['domain']['partner_ids'] += self._get_partner_ids_domain()
return res return res
@api.onchange('receivable_accounts_only', 'payable_accounts_only') @api.onchange('receivable_accounts_only', 'payable_accounts_only')

13
account_financial_report/wizard/trial_balance_wizard.py

@ -6,15 +6,16 @@
from odoo import api, fields, models, _ from odoo import api, fields, models, _
from odoo.tools.safe_eval import safe_eval from odoo.tools.safe_eval import safe_eval
from odoo.tools import pycompat, DEFAULT_SERVER_DATE_FORMAT
from odoo.tools import pycompat
from odoo.exceptions import UserError, ValidationError from odoo.exceptions import UserError, ValidationError
from datetime import datetime
class TrialBalanceReportWizard(models.TransientModel): class TrialBalanceReportWizard(models.TransientModel):
"""Trial balance report wizard.""" """Trial balance report wizard."""
_name = "trial.balance.report.wizard" _name = "trial.balance.report.wizard"
_description = "Trial Balance Report Wizard" _description = "Trial Balance Report Wizard"
_inherit = 'account_financial_report_abstract_wizard'
company_id = fields.Many2one( company_id = fields.Many2one(
comodel_name='res.company', comodel_name='res.company',
@ -98,7 +99,7 @@ class TrialBalanceReportWizard(models.TransientModel):
for wiz in self.filtered('date_from'): for wiz in self.filtered('date_from'):
date = fields.Datetime.from_string(wiz.date_from) date = fields.Datetime.from_string(wiz.date_from)
res = self.company_id.compute_fiscalyear_dates(date) res = self.company_id.compute_fiscalyear_dates(date)
wiz.fy_start_date = datetime.strftime(res['date_from'], DEFAULT_SERVER_DATE_FORMAT)
wiz.fy_start_date = fields.Date.to_string(res['date_from'])
@api.onchange('company_id') @api.onchange('company_id')
def onchange_company_id(self): def onchange_company_id(self):
@ -137,11 +138,7 @@ class TrialBalanceReportWizard(models.TransientModel):
else: else:
res['domain']['account_ids'] += [ res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)] ('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += [
'&',
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False),
('parent_id', '=', False)]
res['domain']['partner_ids'] += self._get_partner_ids_domain()
res['domain']['date_range_id'] += [ res['domain']['date_range_id'] += [
'|', ('company_id', '=', self.company_id.id), '|', ('company_id', '=', self.company_id.id),
('company_id', '=', False)] ('company_id', '=', False)]

Loading…
Cancel
Save