Browse Source

migrate account_financial_report_qweb to 11.0

pull/367/head
Jordi Ballester 7 years ago
parent
commit
4e1d5bd621
  1. 10
      account_financial_report/README.rst
  2. 8
      account_financial_report/__init__.py
  3. 9
      account_financial_report/__manifest__.py
  4. 0
      account_financial_report/i18n/account_financial_report_qweb.pot
  5. 0
      account_financial_report/i18n/es.po
  6. 0
      account_financial_report/i18n/fr.po
  7. 0
      account_financial_report/i18n/hr_HR.po
  8. 0
      account_financial_report/i18n/nl_NL.po
  9. 0
      account_financial_report/i18n/pt.po
  10. 0
      account_financial_report/menuitems.xml
  11. 2
      account_financial_report/models/__init__.py
  12. 2
      account_financial_report/models/account.py
  13. 2
      account_financial_report/report/__init__.py
  14. 25
      account_financial_report/report/abstract_report_xlsx.py
  15. 107
      account_financial_report/report/aged_partner_balance.py
  16. 24
      account_financial_report/report/aged_partner_balance_xlsx.py
  17. 102
      account_financial_report/report/general_ledger.py
  18. 22
      account_financial_report/report/general_ledger_xlsx.py
  19. 107
      account_financial_report/report/open_items.py
  20. 22
      account_financial_report/report/open_items_xlsx.py
  21. 32
      account_financial_report/report/templates/aged_partner_balance.xml
  22. 23
      account_financial_report/report/templates/general_ledger.xml
  23. 14
      account_financial_report/report/templates/layouts.xml
  24. 20
      account_financial_report/report/templates/open_items.xml
  25. 26
      account_financial_report/report/templates/trial_balance.xml
  26. 56
      account_financial_report/report/trial_balance.py
  27. 23
      account_financial_report/report/trial_balance_xlsx.py
  28. 151
      account_financial_report/reports.xml
  29. 0
      account_financial_report/static/description/icon.png
  30. 0
      account_financial_report/static/src/css/report.css
  31. 2
      account_financial_report/tests/__init__.py
  32. 82
      account_financial_report/tests/abstract_test.py
  33. 10
      account_financial_report/tests/test_aged_partner_balance.py
  34. 16
      account_financial_report/tests/test_general_ledger.py
  35. 10
      account_financial_report/tests/test_open_items.py
  36. 10
      account_financial_report/tests/test_trial_balance.py
  37. 0
      account_financial_report/view/account_view.xml
  38. 2
      account_financial_report/wizard/__init__.py
  39. 20
      account_financial_report/wizard/aged_partner_balance_wizard.py
  40. 5
      account_financial_report/wizard/aged_partner_balance_wizard_view.xml
  41. 20
      account_financial_report/wizard/general_ledger_wizard.py
  42. 5
      account_financial_report/wizard/general_ledger_wizard_view.xml
  43. 20
      account_financial_report/wizard/open_items_wizard.py
  44. 5
      account_financial_report/wizard/open_items_wizard_view.xml
  45. 20
      account_financial_report/wizard/trial_balance_wizard.py
  46. 5
      account_financial_report/wizard/trial_balance_wizard_view.xml
  47. 19
      account_financial_report_qweb/__init__.py
  48. 114
      account_financial_report_qweb/reports.xml
  49. 3
      oca_dependencies.txt
  50. 2
      requirements.txt

10
account_financial_report_qweb/README.rst → account_financial_report/README.rst

@ -1,10 +1,10 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
=============================
account_financial_report_qweb
=============================
======================
QWeb Financial Reports
======================
This module adds a set of financial reports. They are accessible under
Accounting / Reporting / OCA Reports.
@ -16,7 +16,7 @@ Accounting / Reporting / OCA Reports.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/91/9.0
:target: https://runbot.odoo-community.org/runbot/91/11.0
Bug Tracker
===========

8
account_financial_report/__init__.py

@ -0,0 +1,8 @@
# Author: Damien Crier
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from . import report
from . import wizard

9
account_financial_report_qweb/__manifest__.py → account_financial_report/__manifest__.py

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# Author: Damien Crier
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'QWeb Financial Reports',
'version': '10.0.1.2.0',
'name': 'Account Financial Reports',
'version': '11.0.1.1.0',
'category': 'Reporting',
'summary': 'OCA Financial Reports',
'author': 'Camptocamp SA,'
@ -18,7 +18,6 @@
'date_range',
'account_fiscal_year',
'report_xlsx',
'report',
],
'data': [
'wizard/aged_partner_balance_wizard_view.xml',
@ -27,9 +26,9 @@
'wizard/trial_balance_wizard_view.xml',
'menuitems.xml',
'reports.xml',
'report/templates/layouts.xml',
'report/templates/aged_partner_balance.xml',
'report/templates/general_ledger.xml',
'report/templates/layouts.xml',
'report/templates/open_items.xml',
'report/templates/trial_balance.xml',
'view/account_view.xml'

0
account_financial_report_qweb/i18n/account_financial_report_qweb.pot → account_financial_report/i18n/account_financial_report_qweb.pot

0
account_financial_report_qweb/i18n/es.po → account_financial_report/i18n/es.po

0
account_financial_report_qweb/i18n/fr.po → account_financial_report/i18n/fr.po

0
account_financial_report_qweb/i18n/hr_HR.po → account_financial_report/i18n/hr_HR.po

0
account_financial_report_qweb/i18n/nl_NL.po → account_financial_report/i18n/nl_NL.po

0
account_financial_report_qweb/i18n/pt.po → account_financial_report/i18n/pt.po

0
account_financial_report_qweb/menuitems.xml → account_financial_report/menuitems.xml

2
account_financial_report_qweb/models/__init__.py → account_financial_report/models/__init__.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Author: Damien Crier
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

2
account_financial_report_qweb/models/account.py → account_financial_report/models/account.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# © 2011 Guewen Baconnier (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
from odoo import models, fields

2
account_financial_report_qweb/report/__init__.py → account_financial_report/report/__init__.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# © 2015 Yannick Vaucher (Camptocamp)
# © 2016 Damien Crier (Camptocamp)
# © 2016 Julien Coux (Camptocamp)

25
account_financial_report_qweb/report/abstract_report_xlsx.py → account_financial_report/report/abstract_report_xlsx.py

@ -1,18 +1,15 @@
# -*- coding: utf-8 -*-
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
from odoo.addons.report_xlsx.report.report_xlsx import ReportXlsx
class AbstractReportXslx(ReportXlsx):
def __init__(self, name, table, rml=False, parser=False, header=True,
store=False):
super(AbstractReportXslx, self).__init__(
name, table, rml, parser, header, store)
class AbstractReportXslx(models.AbstractModel):
_name = 'report.account_financial_report.abstract_report_xlsx'
_inherit = 'report.report_xlsx.abstract'
def __init__(self, pool, cr):
# main sheet which will contains report
self.sheet = None
@ -107,7 +104,7 @@ class AbstractReportXslx(ReportXlsx):
"""Set width for all defined columns.
Columns are defined with `_get_report_columns` method.
"""
for position, column in self.columns.iteritems():
for position, column in self.columns.items():
self.sheet.set_column(position, position, column['width'])
def _write_report_title(self, title):
@ -157,7 +154,7 @@ class AbstractReportXslx(ReportXlsx):
"""Write array header on current line using all defined columns name.
Columns are defined with `_get_report_columns` method.
"""
for col_pos, column in self.columns.iteritems():
for col_pos, column in self.columns.items():
self.sheet.write(self.row_pos, col_pos, column['header'],
self.format_header_center)
self.row_pos += 1
@ -166,7 +163,7 @@ class AbstractReportXslx(ReportXlsx):
"""Write a line on current line using all defined columns field name.
Columns are defined with `_get_report_columns` method.
"""
for col_pos, column in self.columns.iteritems():
for col_pos, column in self.columns.items():
value = getattr(line_object, column['field'])
cell_type = column.get('type', 'string')
if cell_type == 'string':
@ -185,7 +182,7 @@ class AbstractReportXslx(ReportXlsx):
"""
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.iteritems():
for col_pos, column in self.columns.items():
if column.get('field_initial_balance'):
value = getattr(my_object, column['field_initial_balance'])
cell_type = column.get('type', 'string')
@ -213,7 +210,7 @@ class AbstractReportXslx(ReportXlsx):
)
self.sheet.write(self.row_pos, col_pos_label, label,
self.format_header_right)
for col_pos, column in self.columns.iteritems():
for col_pos, column in self.columns.items():
if column.get('field_final_balance'):
value = getattr(my_object, column['field_final_balance'])
cell_type = column.get('type', 'string')

107
account_financial_report_qweb/report/aged_partner_balance.py → account_financial_report/report/aged_partner_balance.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -18,7 +18,7 @@ class AgedPartnerBalanceReport(models.TransientModel):
If "show_move_line_details" is selected
"""
_name = 'report_aged_partner_balance_qweb'
_name = 'report_aged_partner_balance'
# Filters fields, used for data computation
date_at = fields.Date()
@ -29,22 +29,22 @@ class AgedPartnerBalanceReport(models.TransientModel):
show_move_line_details = fields.Boolean()
# Open Items Report Data fields, used as base for compute the data reports
open_items_id = fields.Many2one(comodel_name='report_open_items_qweb')
open_items_id = fields.Many2one(comodel_name='report_open_items')
# Data fields, used to browse report data
account_ids = fields.One2many(
comodel_name='report_aged_partner_balance_qweb_account',
comodel_name='report_aged_partner_balance_account',
inverse_name='report_id'
)
class AgedPartnerBalanceReportAccount(models.TransientModel):
_name = 'report_aged_partner_balance_qweb_account'
_name = 'report_aged_partner_balance_account'
_order = 'code ASC'
report_id = fields.Many2one(
comodel_name='report_aged_partner_balance_qweb',
comodel_name='report_aged_partner_balance',
ondelete='cascade',
index=True
)
@ -76,17 +76,17 @@ class AgedPartnerBalanceReportAccount(models.TransientModel):
# Data fields, used to browse report data
partner_ids = fields.One2many(
comodel_name='report_aged_partner_balance_qweb_partner',
comodel_name='report_aged_partner_balance_partner',
inverse_name='report_account_id'
)
class AgedPartnerBalanceReportPartner(models.TransientModel):
_name = 'report_aged_partner_balance_qweb_partner'
_name = 'report_aged_partner_balance_partner'
report_account_id = fields.Many2one(
comodel_name='report_aged_partner_balance_qweb_account',
comodel_name='report_aged_partner_balance_account',
ondelete='cascade',
index=True
)
@ -102,11 +102,11 @@ class AgedPartnerBalanceReportPartner(models.TransientModel):
# Data fields, used to browse report data
move_line_ids = fields.One2many(
comodel_name='report_aged_partner_balance_qweb_move_line',
comodel_name='report_aged_partner_balance_move_line',
inverse_name='report_partner_id'
)
line_ids = fields.One2many(
comodel_name='report_aged_partner_balance_qweb_line',
comodel_name='report_aged_partner_balance_line',
inverse_name='report_partner_id'
)
@ -117,20 +117,20 @@ class AgedPartnerBalanceReportPartner(models.TransientModel):
ORDER BY
CASE
WHEN
"report_aged_partner_balance_qweb_partner"."partner_id" IS NOT NULL
"report_aged_partner_balance_partner"."partner_id" IS NOT NULL
THEN 0
ELSE 1
END,
"report_aged_partner_balance_qweb_partner"."name"
"report_aged_partner_balance_partner"."name"
"""
class AgedPartnerBalanceReportLine(models.TransientModel):
_name = 'report_aged_partner_balance_qweb_line'
_name = 'report_aged_partner_balance_line'
report_partner_id = fields.Many2one(
comodel_name='report_aged_partner_balance_qweb_partner',
comodel_name='report_aged_partner_balance_partner',
ondelete='cascade',
index=True
)
@ -148,10 +148,10 @@ class AgedPartnerBalanceReportLine(models.TransientModel):
class AgedPartnerBalanceReportMoveLine(models.TransientModel):
_name = 'report_aged_partner_balance_qweb_move_line'
_name = 'report_aged_partner_balance_move_line'
report_partner_id = fields.Many2one(
comodel_name='report_aged_partner_balance_qweb_partner',
comodel_name='report_aged_partner_balance_partner',
ondelete='cascade',
index=True
)
@ -182,20 +182,21 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
For class fields, go more top at this file.
"""
_inherit = 'report_aged_partner_balance_qweb'
_inherit = 'report_aged_partner_balance'
@api.multi
def print_report(self, xlsx_report=False):
def print_report(self, report_type):
self.ensure_one()
self.compute_data_for_report()
if xlsx_report:
report_name = 'account_financial_report_qweb.' \
'report_aged_partner_balance_xlsx'
if report_type == 'xlsx':
report_name = 'a_f_r.report_aged_partner_balance_xlsx'
else:
report_name = 'account_financial_report_qweb.' \
report_name = 'account_financial_report.' \
'report_aged_partner_balance_qweb'
return self.env['report'].get_action(docids=self.ids,
report_name=report_name)
report = self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1)
return report.report_action(self)
def _prepare_report_open_items(self):
self.ensure_one()
@ -213,7 +214,7 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
# Compute Open Items Report Data.
# The data of Aged Partner Balance Report
# are based on Open Items Report data.
model = self.env['report_open_items_qweb']
model = self.env['report_open_items']
self.open_items_id = model.create(self._prepare_report_open_items())
self.open_items_id.compute_data_for_report()
@ -230,10 +231,10 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
self.refresh()
def _inject_account_values(self):
"""Inject report values for report_aged_partner_balance_qweb_account"""
"""Inject report values for report_aged_partner_balance_account"""
query_inject_account = """
INSERT INTO
report_aged_partner_balance_qweb_account
report_aged_partner_balance_account
(
report_id,
create_uid,
@ -250,7 +251,7 @@ SELECT
rao.code,
rao.name
FROM
report_open_items_qweb_account rao
report_open_items_account rao
WHERE
rao.report_id = %s
"""
@ -262,10 +263,10 @@ WHERE
self.env.cr.execute(query_inject_account, query_inject_account_params)
def _inject_partner_values(self):
"""Inject report values for report_aged_partner_balance_qweb_partner"""
"""Inject report values for report_aged_partner_balance_partner"""
query_inject_partner = """
INSERT INTO
report_aged_partner_balance_qweb_partner
report_aged_partner_balance_partner
(
report_account_id,
create_uid,
@ -280,11 +281,11 @@ SELECT
rpo.partner_id,
rpo.name
FROM
report_open_items_qweb_partner rpo
report_open_items_partner rpo
INNER JOIN
report_open_items_qweb_account rao ON rpo.report_account_id = rao.id
report_open_items_account rao ON rpo.report_account_id = rao.id
INNER JOIN
report_aged_partner_balance_qweb_account ra ON rao.code = ra.code
report_aged_partner_balance_account ra ON rao.code = ra.code
WHERE
rao.report_id = %s
AND ra.report_id = %s
@ -297,7 +298,7 @@ AND ra.report_id = %s
self.env.cr.execute(query_inject_partner, query_inject_partner_params)
def _inject_line_values(self, only_empty_partner_line=False):
""" Inject report values for report_aged_partner_balance_qweb_line.
""" Inject report values for report_aged_partner_balance_line.
The "only_empty_partner_line" value is used
to compute data without partner.
@ -315,7 +316,7 @@ WITH
DATE %s - INTEGER '150' AS date_older
)
INSERT INTO
report_aged_partner_balance_qweb_line
report_aged_partner_balance_line
(
report_partner_id,
create_uid,
@ -381,15 +382,15 @@ SELECT
) AS older
FROM
date_range,
report_open_items_qweb_move_line rlo
report_open_items_move_line rlo
INNER JOIN
report_open_items_qweb_partner rpo ON rlo.report_partner_id = rpo.id
report_open_items_partner rpo ON rlo.report_partner_id = rpo.id
INNER JOIN
report_open_items_qweb_account rao ON rpo.report_account_id = rao.id
report_open_items_account rao ON rpo.report_account_id = rao.id
INNER JOIN
report_aged_partner_balance_qweb_account ra ON rao.code = ra.code
report_aged_partner_balance_account ra ON rao.code = ra.code
INNER JOIN
report_aged_partner_balance_qweb_partner rp
report_aged_partner_balance_partner rp
ON
ra.id = rp.report_account_id
"""
@ -418,7 +419,7 @@ GROUP BY
self.env.cr.execute(query_inject_line, query_inject_line_params)
def _inject_move_line_values(self, only_empty_partner_line=False):
""" Inject report values for report_aged_partner_balance_qweb_move_line
""" Inject report values for report_aged_partner_balance_move_line
The "only_empty_partner_line" value is used
to compute data without partner.
@ -436,7 +437,7 @@ WITH
DATE %s - INTEGER '150' AS date_older
)
INSERT INTO
report_aged_partner_balance_qweb_move_line
report_aged_partner_balance_move_line
(
report_partner_id,
create_uid,
@ -502,15 +503,15 @@ SELECT
END AS older
FROM
date_range,
report_open_items_qweb_move_line rlo
report_open_items_move_line rlo
INNER JOIN
report_open_items_qweb_partner rpo ON rlo.report_partner_id = rpo.id
report_open_items_partner rpo ON rlo.report_partner_id = rpo.id
INNER JOIN
report_open_items_qweb_account rao ON rpo.report_account_id = rao.id
report_open_items_account rao ON rpo.report_account_id = rao.id
INNER JOIN
report_aged_partner_balance_qweb_account ra ON rao.code = ra.code
report_aged_partner_balance_account ra ON rao.code = ra.code
INNER JOIN
report_aged_partner_balance_qweb_partner rp
report_aged_partner_balance_partner rp
ON
ra.id = rp.report_account_id
"""
@ -539,7 +540,7 @@ AND ra.report_id = %s
def _compute_accounts_cumul(self):
""" Compute cumulative amount for
report_aged_partner_balance_qweb_account.
report_aged_partner_balance_account.
"""
query_compute_accounts_cumul = """
WITH
@ -555,12 +556,12 @@ WITH
SUM(rl.age_120_days) AS cumul_age_120_days,
SUM(rl.older) AS cumul_older
FROM
report_aged_partner_balance_qweb_line rl
report_aged_partner_balance_line rl
INNER JOIN
report_aged_partner_balance_qweb_partner rp
report_aged_partner_balance_partner rp
ON rl.report_partner_id = rp.id
INNER JOIN
report_aged_partner_balance_qweb_account ra
report_aged_partner_balance_account ra
ON rp.report_account_id = ra.id
WHERE
ra.report_id = %s
@ -568,7 +569,7 @@ WITH
ra.id
)
UPDATE
report_aged_partner_balance_qweb_account
report_aged_partner_balance_account
SET
cumul_amount_residual = c.cumul_amount_residual,
cumul_current = c.cumul_current,

24
account_financial_report_qweb/report/aged_partner_balance_xlsx.py → account_financial_report/report/aged_partner_balance_xlsx.py

@ -1,19 +1,14 @@
# -*- coding: utf-8 -*-
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import abstract_report_xlsx
from odoo.report import report_sxw
from odoo import _
from odoo import _, models
class AgedPartnerBalanceXslx(abstract_report_xlsx.AbstractReportXslx):
def __init__(self, name, table, rml=False, parser=False, header=True,
store=False):
super(AgedPartnerBalanceXslx, self).__init__(
name, table, rml, parser, header, store)
class AgedPartnerBalanceXslx(models.AbstractModel):
_name = 'report.a_f_r.report_aged_partner_balance_xlsx'
_inherit = 'report.account_financial_report.abstract_report_xlsx'
def _get_report_name(self):
return _('Aged Partner Balance')
@ -238,7 +233,7 @@ class AgedPartnerBalanceXslx(abstract_report_xlsx.AbstractReportXslx):
Specific function to write account footer for Aged Partner Balance
"""
col_pos_footer_label = self._get_col_pos_footer_label(report)
for col_pos, column in self.columns.iteritems():
for col_pos, column in self.columns.items():
if col_pos == col_pos_footer_label or column.get(field_name):
if col_pos == col_pos_footer_label:
value = label
@ -260,10 +255,3 @@ class AgedPartnerBalanceXslx(abstract_report_xlsx.AbstractReportXslx):
string_format)
self.row_pos += 1
AgedPartnerBalanceXslx(
'report.account_financial_report_qweb.report_aged_partner_balance_xlsx',
'report_aged_partner_balance_qweb',
parser=report_sxw.rml_parse
)

102
account_financial_report_qweb/report/general_ledger.py → account_financial_report/report/general_ledger.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -21,7 +21,7 @@ class GeneralLedgerReport(models.TransientModel):
For receivable/payable and not centralized accounts
"""
_name = 'report_general_ledger_qweb'
_name = 'report_general_ledger'
# Filters fields, used for data computation
date_from = fields.Date()
@ -47,7 +47,7 @@ class GeneralLedgerReport(models.TransientModel):
# Data fields, used to browse report data
account_ids = fields.One2many(
comodel_name='report_general_ledger_qweb_account',
comodel_name='report_general_ledger_account',
inverse_name='report_id'
)
@ -70,11 +70,11 @@ class GeneralLedgerReport(models.TransientModel):
class GeneralLedgerReportAccount(models.TransientModel):
_name = 'report_general_ledger_qweb_account'
_name = 'report_general_ledger_account'
_order = 'code ASC'
report_id = fields.Many2one(
comodel_name='report_general_ledger_qweb',
comodel_name='report_general_ledger',
ondelete='cascade',
index=True
)
@ -100,21 +100,21 @@ class GeneralLedgerReportAccount(models.TransientModel):
# Data fields, used to browse report data
move_line_ids = fields.One2many(
comodel_name='report_general_ledger_qweb_move_line',
comodel_name='report_general_ledger_move_line',
inverse_name='report_account_id'
)
partner_ids = fields.One2many(
comodel_name='report_general_ledger_qweb_partner',
comodel_name='report_general_ledger_partner',
inverse_name='report_account_id'
)
class GeneralLedgerReportPartner(models.TransientModel):
_name = 'report_general_ledger_qweb_partner'
_name = 'report_general_ledger_partner'
report_account_id = fields.Many2one(
comodel_name='report_general_ledger_qweb_account',
comodel_name='report_general_ledger_account',
ondelete='cascade',
index=True
)
@ -136,7 +136,7 @@ class GeneralLedgerReportPartner(models.TransientModel):
# Data fields, used to browse report data
move_line_ids = fields.One2many(
comodel_name='report_general_ledger_qweb_move_line',
comodel_name='report_general_ledger_move_line',
inverse_name='report_partner_id'
)
@ -146,25 +146,25 @@ class GeneralLedgerReportPartner(models.TransientModel):
return """
ORDER BY
CASE
WHEN "report_general_ledger_qweb_partner"."partner_id" IS NOT NULL
WHEN "report_general_ledger_partner"."partner_id" IS NOT NULL
THEN 0
ELSE 1
END,
"report_general_ledger_qweb_partner"."name"
"report_general_ledger_partner"."name"
"""
class GeneralLedgerReportMoveLine(models.TransientModel):
_name = 'report_general_ledger_qweb_move_line'
_name = 'report_general_ledger_move_line'
report_account_id = fields.Many2one(
comodel_name='report_general_ledger_qweb_account',
comodel_name='report_general_ledger_account',
ondelete='cascade',
index=True
)
report_partner_id = fields.Many2one(
comodel_name='report_general_ledger_qweb_partner',
comodel_name='report_general_ledger_partner',
ondelete='cascade',
index=True
)
@ -193,20 +193,20 @@ class GeneralLedgerReportCompute(models.TransientModel):
For class fields, go more top at this file.
"""
_inherit = 'report_general_ledger_qweb'
_inherit = 'report_general_ledger'
@api.multi
def print_report(self, xlsx_report=False):
def print_report(self, report_type):
self.ensure_one()
self.compute_data_for_report()
if xlsx_report:
report_name = 'account_financial_report_qweb.' \
'report_general_ledger_xlsx'
if report_type == 'xlsx':
report_name = 'a_f_r.report_general_ledger_xlsx'
else:
report_name = 'account_financial_report_qweb.' \
report_name = 'account_financial_report.' \
'report_general_ledger_qweb'
return self.env['report'].get_action(docids=self.ids,
report_name=report_name)
return self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self)
@api.multi
def compute_data_for_report(self,
@ -346,7 +346,7 @@ class GeneralLedgerReportCompute(models.TransientModel):
return subquery_sum_amounts
def _inject_account_values(self):
"""Inject report values for report_general_ledger_qweb_account."""
"""Inject report values for report_general_ledger_account."""
query_inject_account = """
WITH
accounts AS
@ -412,7 +412,7 @@ WITH
initial_sum_amounts AS ( """ + init_subquery + """ ),
final_sum_amounts AS ( """ + final_subquery + """ )
INSERT INTO
report_general_ledger_qweb_account
report_general_ledger_account
(
report_id,
create_uid,
@ -612,11 +612,11 @@ AND
return subquery_sum_amounts
def _inject_partner_values(self, only_empty_partner=False):
""" Inject report values for report_general_ledger_qweb_partner.
""" Inject report values for report_general_ledger_partner.
Only for "partner" accounts (payable and receivable).
"""
# pylint: disable=sql-injection
query_inject_partner = """
WITH
accounts_partners AS
@ -637,7 +637,7 @@ WITH
'""" + _('No partner allocated') + """'
) AS partner_name
FROM
report_general_ledger_qweb_account ra
report_general_ledger_account ra
INNER JOIN
account_account a ON ra.account_id = a.id
INNER JOIN
@ -702,7 +702,7 @@ WITH
initial_sum_amounts AS ( """ + init_subquery + """ ),
final_sum_amounts AS ( """ + final_subquery + """ )
INSERT INTO
report_general_ledger_qweb_partner
report_general_ledger_partner
(
report_account_id,
create_uid,
@ -830,7 +830,7 @@ AND
is_partner_line=False,
only_empty_partner_line=False,
only_unaffected_earnings_account=False):
""" Inject report values for report_general_ledger_qweb_move_line.
""" Inject report values for report_general_ledger_move_line.
If centralized option have been chosen,
only non centralized accounts are computed.
@ -843,7 +843,7 @@ AND
"""
query_inject_move_line = """
INSERT INTO
report_general_ledger_qweb_move_line
report_general_ledger_move_line
(
"""
if is_account_line:
@ -943,13 +943,13 @@ FROM
"""
if is_account_line:
query_inject_move_line += """
report_general_ledger_qweb_account ra
report_general_ledger_account ra
"""
elif is_partner_line:
query_inject_move_line += """
report_general_ledger_qweb_partner rp
report_general_ledger_partner rp
INNER JOIN
report_general_ledger_qweb_account ra ON rp.report_account_id = ra.id
report_general_ledger_account ra ON rp.report_account_id = ra.id
"""
query_inject_move_line += """
INNER JOIN
@ -1070,7 +1070,7 @@ ORDER BY
)
def _inject_line_centralized_values(self):
""" Inject report values for report_general_ledger_qweb_move_line.
""" Inject report values for report_general_ledger_move_line.
Only centralized accounts are computed.
"""
@ -1088,7 +1088,7 @@ WITH
SUM(ml.credit) AS credit,
SUM(ml.balance) AS balance
FROM
report_general_ledger_qweb_account ra
report_general_ledger_account ra
INNER JOIN
account_move_line ml ON ra.account_id = ml.account_id
INNER JOIN
@ -1122,7 +1122,7 @@ WITH
ra.id, ml.account_id, a.code, 2
)
INSERT INTO
report_general_ledger_qweb_move_line
report_general_ledger_move_line
(
report_account_id,
create_uid,
@ -1148,7 +1148,7 @@ SELECT
OVER (PARTITION BY a.code ORDER BY ml.date)
) AS cumul_balance
FROM
report_general_ledger_qweb_account ra
report_general_ledger_account ra
INNER JOIN
move_lines ml ON ra.account_id = ml.account_id
INNER JOIN
@ -1184,16 +1184,16 @@ ORDER BY
""" Compute "has_second_currency" flag which will used for display."""
query_update_has_second_currency = """
UPDATE
report_general_ledger_qweb
report_general_ledger
SET
has_second_currency =
(
SELECT
TRUE
FROM
report_general_ledger_qweb_move_line l
report_general_ledger_move_line l
INNER JOIN
report_general_ledger_qweb_account a
report_general_ledger_account a
ON l.report_account_id = a.id
WHERE
a.report_id = %s
@ -1205,12 +1205,12 @@ SET
SELECT
TRUE
FROM
report_general_ledger_qweb_move_line l
report_general_ledger_move_line l
INNER JOIN
report_general_ledger_qweb_partner p
report_general_ledger_partner p
ON l.report_partner_id = p.id
INNER JOIN
report_general_ledger_qweb_account a
report_general_ledger_account a
ON p.report_account_id = a.id
WHERE
a.report_id = %s
@ -1278,7 +1278,7 @@ WHERE id = %s
def _inject_unaffected_earnings_account_values(self):
"""Inject the report values of the unaffected earnings account
for report_general_ledger_qweb_account."""
for report_general_ledger_account."""
subquery_sum_amounts = """
SELECT
SUM(COALESCE(sub.balance, 0.0)) AS balance
@ -1299,11 +1299,13 @@ WHERE id = %s
subquery_sum_amounts += """
) sub
"""
# pylint: disable=sql-injection
query_inject_account = """
WITH
initial_sum_amounts AS ( """ + subquery_sum_amounts + """ )
INSERT INTO
report_general_ledger_qweb_account
report_general_ledger_account
(
report_id,
create_uid,
@ -1364,7 +1366,7 @@ WHERE id = %s
def _complete_unaffected_earnings_account_values(self):
"""Complete the report values of the unaffected earnings account
for report_general_ledger_qweb_account."""
for report_general_ledger_account."""
query_update_unaffected_earnings_account_values = """
WITH
sum_amounts AS
@ -1377,9 +1379,9 @@ WHERE id = %s
COALESCE(rml.credit, 0.0)
) + ra.initial_balance AS balance
FROM
report_general_ledger_qweb_account ra
report_general_ledger_account ra
LEFT JOIN
report_general_ledger_qweb_move_line rml
report_general_ledger_move_line rml
ON ra.id = rml.report_account_id
WHERE
ra.report_id = %s
@ -1388,7 +1390,7 @@ WHERE id = %s
ra.id
)
UPDATE
report_general_ledger_qweb_account ra
report_general_ledger_account ra
SET
initial_debit = 0.0,
initial_credit = 0.0,

22
account_financial_report_qweb/report/general_ledger_xlsx.py → account_financial_report/report/general_ledger_xlsx.py

@ -1,20 +1,15 @@
# -*- coding: utf-8 -*-
# Author: Damien Crier
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import abstract_report_xlsx
from odoo.report import report_sxw
from odoo import _
from odoo import _, models
class GeneralLedgerXslx(abstract_report_xlsx.AbstractReportXslx):
def __init__(self, name, table, rml=False, parser=False, header=True,
store=False):
super(GeneralLedgerXslx, self).__init__(
name, table, rml, parser, header, store)
class GeneralLedgerXslx(models.AbstractModel):
_name = 'report.a_f_r.report_general_ledger_xlsx'
_inherit = 'report.account_financial_report.abstract_report_xlsx'
def _get_report_name(self):
return _('General Ledger')
@ -140,10 +135,3 @@ class GeneralLedgerXslx(abstract_report_xlsx.AbstractReportXslx):
super(GeneralLedgerXslx, self).write_ending_balance(
my_object, name, label
)
GeneralLedgerXslx(
'report.account_financial_report_qweb.report_general_ledger_xlsx',
'report_general_ledger_qweb',
parser=report_sxw.rml_parse
)

107
account_financial_report_qweb/report/open_items.py → account_financial_report/report/open_items.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -16,7 +16,7 @@ class OpenItemsReport(models.TransientModel):
**** OpenItemsReportMoveLine
"""
_name = 'report_open_items_qweb'
_name = 'report_open_items'
# Filters fields, used for data computation
date_at = fields.Date()
@ -31,18 +31,18 @@ class OpenItemsReport(models.TransientModel):
# Data fields, used to browse report data
account_ids = fields.One2many(
comodel_name='report_open_items_qweb_account',
comodel_name='report_open_items_account',
inverse_name='report_id'
)
class OpenItemsReportAccount(models.TransientModel):
_name = 'report_open_items_qweb_account'
_name = 'report_open_items_account'
_order = 'code ASC'
report_id = fields.Many2one(
comodel_name='report_open_items_qweb',
comodel_name='report_open_items',
ondelete='cascade',
index=True
)
@ -60,17 +60,17 @@ class OpenItemsReportAccount(models.TransientModel):
# Data fields, used to browse report data
partner_ids = fields.One2many(
comodel_name='report_open_items_qweb_partner',
comodel_name='report_open_items_partner',
inverse_name='report_account_id'
)
class OpenItemsReportPartner(models.TransientModel):
_name = 'report_open_items_qweb_partner'
_name = 'report_open_items_partner'
report_account_id = fields.Many2one(
comodel_name='report_open_items_qweb_account',
comodel_name='report_open_items_account',
ondelete='cascade',
index=True
)
@ -87,7 +87,7 @@ class OpenItemsReportPartner(models.TransientModel):
# Data fields, used to browse report data
move_line_ids = fields.One2many(
comodel_name='report_open_items_qweb_move_line',
comodel_name='report_open_items_move_line',
inverse_name='report_partner_id'
)
@ -97,20 +97,20 @@ class OpenItemsReportPartner(models.TransientModel):
return """
ORDER BY
CASE
WHEN "report_open_items_qweb_partner"."partner_id" IS NOT NULL
WHEN "report_open_items_partner"."partner_id" IS NOT NULL
THEN 0
ELSE 1
END,
"report_open_items_qweb_partner"."name"
"report_open_items_partner"."name"
"""
class OpenItemsReportMoveLine(models.TransientModel):
_name = 'report_open_items_qweb_move_line'
_name = 'report_open_items_move_line'
report_partner_id = fields.Many2one(
comodel_name='report_open_items_qweb_partner',
comodel_name='report_open_items_partner',
ondelete='cascade',
index=True
)
@ -138,20 +138,20 @@ class OpenItemsReportCompute(models.TransientModel):
For class fields, go more top at this file.
"""
_inherit = 'report_open_items_qweb'
_inherit = 'report_open_items'
@api.multi
def print_report(self, xlsx_report=False):
def print_report(self, report_type):
self.ensure_one()
self.compute_data_for_report()
if xlsx_report:
report_name = 'account_financial_report_qweb.' \
'report_open_items_xlsx'
if report_type == 'xlsx':
report_name = 'a_f_r.report_open_items_xlsx'
else:
report_name = 'account_financial_report_qweb.' \
report_name = 'account_financial_report.' \
'report_open_items_qweb'
return self.env['report'].get_action(docids=self.ids,
report_name=report_name)
return self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self)
@api.multi
def compute_data_for_report(self):
@ -173,7 +173,7 @@ class OpenItemsReportCompute(models.TransientModel):
self.refresh()
def _inject_account_values(self):
"""Inject report values for report_open_items_qweb_account."""
"""Inject report values for report_open_items_account."""
query_inject_account = """
WITH
accounts AS
@ -218,7 +218,7 @@ WITH
a.id
)
INSERT INTO
report_open_items_qweb_account
report_open_items_account
(
report_id,
create_uid,
@ -256,7 +256,8 @@ FROM
self.env.cr.execute(query_inject_account, query_inject_account_params)
def _inject_partner_values(self):
""" Inject report values for report_open_items_qweb_partner. """
""" Inject report values for report_open_items_partner. """
# pylint: disable=sql-injection
query_inject_partner = """
WITH
accounts_partners AS
@ -277,7 +278,7 @@ WITH
'""" + _('No partner allocated') + """'
) AS partner_name
FROM
report_open_items_qweb_account ra
report_open_items_account ra
INNER JOIN
account_account a ON ra.account_id = a.id
INNER JOIN
@ -309,7 +310,7 @@ WITH
at.include_initial_balance
)
INSERT INTO
report_open_items_qweb_partner
report_open_items_partner
(
report_account_id,
create_uid,
@ -363,9 +364,9 @@ FROM
END
) AS partial_amount_currency
FROM
report_open_items_qweb_partner rp
report_open_items_partner rp
INNER JOIN
report_open_items_qweb_account ra
report_open_items_account ra
ON rp.report_account_id = ra.id
INNER JOIN
account_move_line ml
@ -423,7 +424,7 @@ FROM
return sub_query
def _inject_line_values(self, only_empty_partner_line=False):
""" Inject report values for report_open_items_qweb_move_line.
""" Inject report values for report_open_items_move_line.
The "only_empty_partner_line" value is used
to compute data without partner.
@ -478,7 +479,7 @@ WITH
amount_currency
)
INSERT INTO
report_open_items_qweb_move_line
report_open_items_move_line
(
report_partner_id,
create_uid,
@ -530,9 +531,9 @@ SELECT
ml.amount_currency,
ml2.amount_residual_currency
FROM
report_open_items_qweb_partner rp
report_open_items_partner rp
INNER JOIN
report_open_items_qweb_account ra ON rp.report_account_id = ra.id
report_open_items_account ra ON rp.report_account_id = ra.id
INNER JOIN
account_move_line ml ON ra.account_id = ml.account_id
INNER JOIN
@ -600,20 +601,20 @@ ORDER BY
def _compute_partners_and_accounts_cumul(self):
""" Compute cumulative amount for
report_open_items_qweb_partner and report_open_items_qweb_account.
report_open_items_partner and report_open_items_account.
"""
query_compute_partners_cumul = """
UPDATE
report_open_items_qweb_partner
report_open_items_partner
SET
final_amount_residual =
(
SELECT
SUM(rml.amount_residual) AS final_amount_residual
FROM
report_open_items_qweb_move_line rml
report_open_items_move_line rml
WHERE
rml.report_partner_id = report_open_items_qweb_partner.id
rml.report_partner_id = report_open_items_partner.id
)
WHERE
id IN
@ -621,9 +622,9 @@ WHERE
SELECT
rp.id
FROM
report_open_items_qweb_account ra
report_open_items_account ra
INNER JOIN
report_open_items_qweb_partner rp
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s
@ -634,16 +635,16 @@ WHERE
params_compute_partners_cumul)
query_compute_accounts_cumul = """
UPDATE
report_open_items_qweb_account
report_open_items_account
SET
final_amount_residual =
(
SELECT
SUM(rp.final_amount_residual) AS final_amount_residual
FROM
report_open_items_qweb_partner rp
report_open_items_partner rp
WHERE
rp.report_account_id = report_open_items_qweb_account.id
rp.report_account_id = report_open_items_account.id
)
WHERE
report_id = %s
@ -655,26 +656,26 @@ WHERE
def _clean_partners_and_accounts(self,
only_delete_account_balance_at_0=False):
""" Delete empty data for
report_open_items_qweb_partner and report_open_items_qweb_account.
report_open_items_partner and report_open_items_account.
The "only_delete_account_balance_at_0" value is used
to delete also the data with cumulative amounts at 0.
"""
query_clean_partners = """
DELETE FROM
report_open_items_qweb_partner
report_open_items_partner
WHERE
id IN
(
SELECT
DISTINCT rp.id
FROM
report_open_items_qweb_account ra
report_open_items_account ra
INNER JOIN
report_open_items_qweb_partner rp
report_open_items_partner rp
ON ra.id = rp.report_account_id
LEFT JOIN
report_open_items_qweb_move_line rml
report_open_items_move_line rml
ON rp.id = rml.report_partner_id
WHERE
ra.report_id = %s
@ -697,16 +698,16 @@ WHERE
self.env.cr.execute(query_clean_partners, params_clean_partners)
query_clean_accounts = """
DELETE FROM
report_open_items_qweb_account
report_open_items_account
WHERE
id IN
(
SELECT
DISTINCT ra.id
FROM
report_open_items_qweb_account ra
report_open_items_account ra
LEFT JOIN
report_open_items_qweb_partner rp
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s
@ -732,19 +733,19 @@ WHERE
""" Compute "has_second_currency" flag which will used for display."""
query_update_has_second_currency = """
UPDATE
report_open_items_qweb
report_open_items
SET
has_second_currency =
(
SELECT
TRUE
FROM
report_open_items_qweb_move_line l
report_open_items_move_line l
INNER JOIN
report_open_items_qweb_partner p
report_open_items_partner p
ON l.report_partner_id = p.id
INNER JOIN
report_open_items_qweb_account a
report_open_items_account a
ON p.report_account_id = a.id
WHERE
a.report_id = %s

22
account_financial_report_qweb/report/open_items_xlsx.py → account_financial_report/report/open_items_xlsx.py

@ -1,19 +1,14 @@
# -*- coding: utf-8 -*-
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import abstract_report_xlsx
from odoo.report import report_sxw
from odoo import _
from odoo import _, models
class OpenItemsXslx(abstract_report_xlsx.AbstractReportXslx):
def __init__(self, name, table, rml=False, parser=False, header=True,
store=False):
super(OpenItemsXslx, self).__init__(
name, table, rml, parser, header, store)
class OpenItemsXslx(models.AbstractModel):
_name = 'report.a_f_r.report_open_items_xlsx'
_inherit = 'report.account_financial_report.abstract_report_xlsx'
def _get_report_name(self):
return _('Open Items')
@ -108,10 +103,3 @@ class OpenItemsXslx(abstract_report_xlsx.AbstractReportXslx):
name = my_object.code + ' - ' + my_object.name
label = _('Ending balance')
super(OpenItemsXslx, self).write_ending_balance(my_object, name, label)
OpenItemsXslx(
'report.account_financial_report_qweb.report_open_items_xlsx',
'report_open_items_qweb',
parser=report_sxw.rml_parse
)

32
account_financial_report_qweb/report/templates/aged_partner_balance.xml → account_financial_report/report/templates/aged_partner_balance.xml

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="account_financial_report_qweb.report_aged_partner_balance_qweb">
<t t-call="report.html_container">
<template id="account_financial_report.report_aged_partner_balance_qweb">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="show_move_line_details" t-value="o.show_move_line_details"/>
<t t-call="account_financial_report_qweb.internal_layout">
<t t-call="account_financial_report.internal_layout">
<!-- Defines global variables used by internal layout -->
<t t-set="title">Aged Partner Balance</t>
<t t-set="company_name" t-value="o.company_id.name"/>
<div class="page">
<!-- Display filters -->
<t t-call="account_financial_report_qweb.report_aged_partner_balance_qweb_filters"/>
<t t-call="account_financial_report.report_aged_partner_balance_filters"/>
<t t-foreach="o.account_ids" t-as="account">
<div class="page_break">
@ -28,17 +28,17 @@
<t t-if="not show_move_line_details">
<div class="act_as_table data_table" style="width: 1140px !important;">
<!-- Display account header -->
<t t-call="account_financial_report_qweb.report_aged_partner_balance_qweb_lines_header"/>
<t t-call="account_financial_report.report_aged_partner_balance_lines_header"/>
<t t-foreach="account.partner_ids" t-as="partner">
<!-- Display one line per partner -->
<t t-call="account_financial_report_qweb.report_aged_partner_balance_qweb_lines"/>
<t t-call="account_financial_report.report_aged_partner_balance_lines"/>
</t>
</div>
<!-- Display account footer -->
<t t-call="account_financial_report_qweb.report_aged_partner_balance_qweb_account_ending_cumul"/>
<t t-call="account_financial_report.report_aged_partner_balance_account_ending_cumul"/>
</t>
<!-- Display account move lines -->
@ -53,17 +53,17 @@
</div>
<!-- Display partner move lines -->
<t t-call="account_financial_report_qweb.report_aged_partner_balance_qweb_move_lines"/>
<t t-call="account_financial_report.report_aged_partner_balance_move_lines"/>
<!-- Display partner footer -->
<t t-call="account_financial_report_qweb.report_aged_partner_balance_qweb_partner_ending_cumul">
<t t-call="account_financial_report.report_aged_partner_balance_partner_ending_cumul">
<t t-set="partner_cumul_line" t-value="partner.line_ids"/>
</t>
</div>
</t>
<!-- Display account footer -->
<t t-call="account_financial_report_qweb.report_aged_partner_balance_qweb_account_ending_cumul"/>
<t t-call="account_financial_report.report_aged_partner_balance_account_ending_cumul"/>
</t>
</div>
</t>
@ -73,7 +73,7 @@
</t>
</template>
<template id="account_financial_report_qweb.report_aged_partner_balance_qweb_filters">
<template id="account_financial_report.report_aged_partner_balance_filters">
<div class="act_as_table data_table" style="width: 1140px !important;">
<div class="act_as_row labels">
<div class="act_as_cell">Date at filter</div>
@ -91,7 +91,7 @@
</div>
</template>
<template id="account_financial_report_qweb.report_aged_partner_balance_qweb_lines_header">
<template id="account_financial_report.report_aged_partner_balance_lines_header">
<!-- Display table headers for lines -->
<div class="act_as_thead">
<div class="act_as_row labels">
@ -115,7 +115,7 @@
</div>
</template>
<template id="account_financial_report_qweb.report_aged_partner_balance_qweb_lines">
<template id="account_financial_report.report_aged_partner_balance_lines">
<!-- Display each lines -->
<t t-foreach="partner.line_ids" t-as="line">
<!-- # lines -->
@ -140,7 +140,7 @@
</t>
</template>
<template id="account_financial_report_qweb.report_aged_partner_balance_qweb_move_lines">
<template id="account_financial_report.report_aged_partner_balance_move_lines">
<div class="act_as_table data_table" style="width: 1140px !important;">
<!-- Display table headers for move lines -->
<div class="act_as_thead">
@ -212,7 +212,7 @@
</div>
</template>
<template id="account_financial_report_qweb.report_aged_partner_balance_qweb_partner_ending_cumul">
<template id="account_financial_report.report_aged_partner_balance_partner_ending_cumul">
<!-- Display ending balance line for partner -->
<div class="act_as_table list_table" style="width: 1141px !important;">
<div class="act_as_row labels" style="font-weight: bold;">
@ -238,7 +238,7 @@
</div>
</template>
<template id="account_financial_report_qweb.report_aged_partner_balance_qweb_account_ending_cumul">
<template id="account_financial_report.report_aged_partner_balance_account_ending_cumul">
<!-- Display ending balance line for account -->
<div class="act_as_table list_table" style="width: 1141px !important;">
<div class="act_as_row labels" style="font-weight: bold;">

23
account_financial_report_qweb/report/templates/general_ledger.xml → account_financial_report/report/templates/general_ledger.xml

@ -1,21 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="account_financial_report_qweb.report_general_ledger_qweb">
<t t-call="report.html_container">
<template id="report_general_ledger_qweb">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="show_cost_center" t-value="o.show_cost_center"/>
<t t-set="has_second_currency" t-value="o.has_second_currency"/>
<t t-call="account_financial_report_qweb.internal_layout">
<t t-call="account_financial_report.internal_layout">
<!-- Defines global variables used by internal layout -->
<t t-set="title">General Ledger</t>
<t t-set="company_name" t-value="o.company_id.name"/>
<div class="page">
<!-- Display filters -->
<t t-call="account_financial_report_qweb.report_general_ledger_qweb_filters"/>
<t t-call="account_financial_report.report_general_ledger_filters"/>
<t t-foreach="o.account_ids" t-as="account">
<div class="page_break">
@ -27,7 +26,7 @@
<t t-if="not account.partner_ids">
<!-- Display account move lines without partner regroup -->
<t t-call="account_financial_report_qweb.report_general_ledger_qweb_lines">
<t t-call="account_financial_report.report_general_ledger_lines">
<t t-set="account_or_partner_object" t-value="account"/>
</t>
</t>
@ -42,12 +41,12 @@
</div>
<!-- Display partner move lines -->
<t t-call="account_financial_report_qweb.report_general_ledger_qweb_lines">
<t t-call="account_financial_report.report_general_ledger_lines">
<t t-set="account_or_partner_object" t-value="partner"/>
</t>
<!-- Display partner footer -->
<t t-call="account_financial_report_qweb.report_general_ledger_qweb_ending_cumul">
<t t-call="account_financial_report.report_general_ledger_ending_cumul">
<t t-set="account_or_partner_object" t-value="partner"/>
<t t-set="type" t-value='"partner_type"'/>
</t>
@ -56,7 +55,7 @@
</t>
<!-- Display account footer -->
<t t-call="account_financial_report_qweb.report_general_ledger_qweb_ending_cumul">
<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>
@ -68,7 +67,7 @@
</t>
</template>
<template id="account_financial_report_qweb.report_general_ledger_qweb_filters">
<template id="account_financial_report.report_general_ledger_filters">
<div class="act_as_table data_table" style="width: 1140px !important;">
<div class="act_as_row labels">
<div class="act_as_cell">Date range filter</div>
@ -96,7 +95,7 @@
</div>
</template>
<template id="account_financial_report_qweb.report_general_ledger_qweb_lines">
<template id="account_financial_report.report_general_ledger_lines">
<div class="act_as_table data_table" style="width: 1140px !important;">
<!-- Display table headers for lines -->
@ -214,7 +213,7 @@
</div>
</template>
<template id="account_financial_report_qweb.report_general_ledger_qweb_ending_cumul">
<template id="account_financial_report.report_general_ledger_ending_cumul">
<!-- Display ending balance line for account or partner -->
<div class="act_as_table list_table" style="width: 1141px !important;">
<div class="act_as_row labels" style="font-weight: bold;">

14
account_financial_report_qweb/report/templates/layouts.xml → account_financial_report/report/templates/layouts.xml

@ -1,13 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_specific" inherit_id="report.assets_common">
<xpath expr="." position="inside">
<link href="/account_financial_report_qweb/static/src/css/report.css" rel="stylesheet"/>
</xpath>
</template>
<template id="account_financial_report_qweb.internal_layout">
<template id="account_financial_report.internal_layout">
<div class="header">
<div class="row">
<div class="col-xs-6">
@ -18,7 +12,11 @@
</div>
</div>
</div>
<t t-raw="0" />
<div class="article">
<link href="/account_financial_report/static/src/css/report.css" rel="stylesheet"/>
<t t-raw="0" />
</div>
<div class="footer">
<div class="row">
<div class="col-xs-6 custom_footer">

20
account_financial_report_qweb/report/templates/open_items.xml → account_financial_report/report/templates/open_items.xml

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="account_financial_report_qweb.report_open_items_qweb">
<t t-call="report.html_container">
<template id="account_financial_report.report_open_items_qweb">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="has_second_currency" t-value="o.has_second_currency"/>
<t t-call="account_financial_report_qweb.internal_layout">
<t t-call="account_financial_report.internal_layout">
<!-- Defines global variables used by internal layout -->
<t t-set="title">Open Items</t>
<t t-set="company_name" t-value="o.company_id.name"/>
<div class="page">
<!-- Display filters -->
<t t-call="account_financial_report_qweb.report_open_items_qweb_filters"/>
<t t-call="account_financial_report.report_open_items_filters"/>
<t t-foreach="o.account_ids" t-as="account">
<div class="page_break">
@ -33,10 +33,10 @@
</div>
<!-- Display partner move lines -->
<t t-call="account_financial_report_qweb.report_open_items_qweb_lines"/>
<t t-call="account_financial_report.report_open_items_lines"/>
<!-- Display partner footer -->
<t t-call="account_financial_report_qweb.report_open_items_qweb_ending_cumul">
<t t-call="account_financial_report.report_open_items_ending_cumul">
<t t-set="account_or_partner_object" t-value="partner"/>
<t t-set="type" t-value='"partner_type"'/>
</t>
@ -44,7 +44,7 @@
</t>
<!-- Display account footer -->
<t t-call="account_financial_report_qweb.report_open_items_qweb_ending_cumul">
<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>
@ -57,7 +57,7 @@
</template>
<template id="account_financial_report_qweb.report_open_items_qweb_filters">
<template id="account_financial_report.report_open_items_filters">
<div class="act_as_table data_table" style="width: 1140px !important;">
<div class="act_as_row labels">
<div class="act_as_cell">Date at filter</div>
@ -80,7 +80,7 @@
</div>
</template>
<template id="account_financial_report_qweb.report_open_items_qweb_lines">
<template id="account_financial_report.report_open_items_lines">
<div class="act_as_table data_table" style="width: 1140px !important;">
<!-- Display table headers for lines -->
<div class="act_as_thead">
@ -157,7 +157,7 @@
</div>
</template>
<template id="account_financial_report_qweb.report_open_items_qweb_ending_cumul">
<template id="account_financial_report.report_open_items_ending_cumul">
<!-- Display ending balance line for account or partner -->
<div class="act_as_table list_table" style="width: 1141px !important;">
<div class="act_as_row labels" style="font-weight: bold;">

26
account_financial_report_qweb/report/templates/trial_balance.xml → account_financial_report/report/templates/trial_balance.xml

@ -1,32 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="account_financial_report_qweb.report_trial_balance_qweb">
<t t-call="report.html_container">
<template id="account_financial_report.report_trial_balance_qweb">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="show_partner_details" t-value="o.show_partner_details"/>
<t t-call="account_financial_report_qweb.internal_layout">
<t t-call="account_financial_report.internal_layout">
<!-- Defines global variables used by internal layout -->
<t t-set="title">Trial Balance</t>
<t t-set="company_name" t-value="o.company_id.name"/>
<div class="page">
<!-- Display filters -->
<t t-call="account_financial_report_qweb.report_trial_balance_qweb_filters"/>
<t t-call="account_financial_report.report_trial_balance_filters"/>
<div class="act_as_table list_table" style="margin-top: 10px;"/>
<!-- Display account lines -->
<t t-if="not show_partner_details">
<div class="act_as_table data_table" style="width: 1140px !important;">
<!-- Display account header -->
<t t-call="account_financial_report_qweb.report_trial_balance_qweb_lines_header"/>
<t t-call="account_financial_report.report_trial_balance_lines_header"/>
<!-- Display each lines -->
<t t-foreach="o.account_ids" t-as="line">
<!-- Display account lines -->
<t t-call="account_financial_report_qweb.report_trial_balance_qweb_line"/>
<t t-call="account_financial_report.report_trial_balance_line"/>
</t>
</div>
</t>
@ -43,17 +43,17 @@
<div class="act_as_table data_table" style="width: 1140px !important;">
<!-- Display account/partner header -->
<t t-call="account_financial_report_qweb.report_trial_balance_qweb_lines_header"/>
<t t-call="account_financial_report.report_trial_balance_lines_header"/>
<!-- Display each partners -->
<t t-foreach="account.partner_ids" t-as="line">
<!-- Display partner line -->
<t t-call="account_financial_report_qweb.report_trial_balance_qweb_line"/>
<t t-call="account_financial_report.report_trial_balance_line"/>
</t>
</div>
<!-- Display account footer -->
<t t-call="account_financial_report_qweb.report_trial_balance_qweb_account_footer"/>
<t t-call="account_financial_report.report_trial_balance_account_footer"/>
</div>
</t>
@ -64,7 +64,7 @@
</t>
</template>
<template id="account_financial_report_qweb.report_trial_balance_qweb_filters">
<template id="account_financial_report.report_trial_balance_filters">
<div class="act_as_table data_table" style="width: 1140px !important;">
<div class="act_as_row labels">
<div class="act_as_cell">Date range filter</div>
@ -87,7 +87,7 @@
</div>
</template>
<template id="account_financial_report_qweb.report_trial_balance_qweb_lines_header">
<template id="account_financial_report.report_trial_balance_lines_header">
<!-- Display table headers for lines -->
<div class="act_as_thead">
<div class="act_as_row labels">
@ -113,7 +113,7 @@
</div>
</template>
<template id="account_financial_report_qweb.report_trial_balance_qweb_line">
<template id="account_financial_report.report_trial_balance_line">
<!-- # line -->
<div class="act_as_row lines">
<t t-if="not show_partner_details">
@ -133,7 +133,7 @@
</div>
</template>
<template id="account_financial_report_qweb.report_trial_balance_qweb_account_footer">
<template id="account_financial_report.report_trial_balance_account_footer">
<!-- Display account footer -->
<div class="act_as_table list_table" style="width: 1141px !important;">
<div class="act_as_row labels" style="font-weight: bold;">

56
account_financial_report_qweb/report/trial_balance.py → account_financial_report/report/trial_balance.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -16,7 +16,7 @@ class TrialBalanceReport(models.TransientModel):
If "show_partner_details" is selected
"""
_name = 'report_trial_balance_qweb'
_name = 'report_trial_balance'
# Filters fields, used for data computation
date_from = fields.Date()
@ -32,23 +32,23 @@ class TrialBalanceReport(models.TransientModel):
# General Ledger Report Data fields,
# used as base for compute the data reports
general_ledger_id = fields.Many2one(
comodel_name='report_general_ledger_qweb'
comodel_name='report_general_ledger'
)
# Data fields, used to browse report data
account_ids = fields.One2many(
comodel_name='report_trial_balance_qweb_account',
comodel_name='report_trial_balance_account',
inverse_name='report_id'
)
class TrialBalanceReportAccount(models.TransientModel):
_name = 'report_trial_balance_qweb_account'
_name = 'report_trial_balance_account'
_order = 'code ASC'
report_id = fields.Many2one(
comodel_name='report_trial_balance_qweb',
comodel_name='report_trial_balance',
ondelete='cascade',
index=True
)
@ -70,17 +70,17 @@ class TrialBalanceReportAccount(models.TransientModel):
# Data fields, used to browse report data
partner_ids = fields.One2many(
comodel_name='report_trial_balance_qweb_partner',
comodel_name='report_trial_balance_partner',
inverse_name='report_account_id'
)
class TrialBalanceReportPartner(models.TransientModel):
_name = 'report_trial_balance_qweb_partner'
_name = 'report_trial_balance_partner'
report_account_id = fields.Many2one(
comodel_name='report_trial_balance_qweb_account',
comodel_name='report_trial_balance_account',
ondelete='cascade',
index=True
)
@ -105,11 +105,11 @@ class TrialBalanceReportPartner(models.TransientModel):
return """
ORDER BY
CASE
WHEN "report_trial_balance_qweb_partner"."partner_id" IS NOT NULL
WHEN "report_trial_balance_partner"."partner_id" IS NOT NULL
THEN 0
ELSE 1
END,
"report_trial_balance_qweb_partner"."name"
"report_trial_balance_partner"."name"
"""
@ -118,20 +118,20 @@ class TrialBalanceReportCompute(models.TransientModel):
For class fields, go more top at this file.
"""
_inherit = 'report_trial_balance_qweb'
_inherit = 'report_trial_balance'
@api.multi
def print_report(self, xlsx_report=False):
def print_report(self, report_type):
self.ensure_one()
self.compute_data_for_report()
if xlsx_report:
report_name = 'account_financial_report_qweb.' \
'report_trial_balance_xlsx'
if report_type == 'xlsx':
report_name = 'a_f_r.report_trial_balance_xlsx'
else:
report_name = 'account_financial_report_qweb.' \
report_name = 'account_financial_report.' \
'report_trial_balance_qweb'
return self.env['report'].get_action(docids=self.ids,
report_name=report_name)
return self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self)
def _prepare_report_general_ledger(self):
self.ensure_one()
@ -152,7 +152,7 @@ class TrialBalanceReportCompute(models.TransientModel):
# Compute General Ledger Report Data.
# The data of Trial Balance Report
# are based on General Ledger Report data.
model = self.env['report_general_ledger_qweb']
model = self.env['report_general_ledger']
self.general_ledger_id = model.create(
self._prepare_report_general_ledger()
)
@ -168,10 +168,10 @@ class TrialBalanceReportCompute(models.TransientModel):
self.refresh()
def _inject_account_values(self):
"""Inject report values for report_trial_balance_qweb_account"""
"""Inject report values for report_trial_balance_account"""
query_inject_account = """
INSERT INTO
report_trial_balance_qweb_account
report_trial_balance_account
(
report_id,
create_uid,
@ -196,7 +196,7 @@ SELECT
rag.final_credit - rag.initial_credit AS credit,
rag.final_balance AS final_balance
FROM
report_general_ledger_qweb_account rag
report_general_ledger_account rag
WHERE
rag.report_id = %s
"""
@ -208,10 +208,10 @@ WHERE
self.env.cr.execute(query_inject_account, query_inject_account_params)
def _inject_partner_values(self):
"""Inject report values for report_trial_balance_qweb_partner"""
"""Inject report values for report_trial_balance_partner"""
query_inject_partner = """
INSERT INTO
report_trial_balance_qweb_partner
report_trial_balance_partner
(
report_account_id,
create_uid,
@ -234,11 +234,11 @@ SELECT
rpg.final_credit - rpg.initial_credit AS credit,
rpg.final_balance AS final_balance
FROM
report_general_ledger_qweb_partner rpg
report_general_ledger_partner rpg
INNER JOIN
report_general_ledger_qweb_account rag ON rpg.report_account_id = rag.id
report_general_ledger_account rag ON rpg.report_account_id = rag.id
INNER JOIN
report_trial_balance_qweb_account ra ON rag.code = ra.code
report_trial_balance_account ra ON rag.code = ra.code
WHERE
rag.report_id = %s
AND ra.report_id = %s

23
account_financial_report_qweb/report/trial_balance_xlsx.py → account_financial_report/report/trial_balance_xlsx.py

@ -1,19 +1,15 @@
# -*- coding: utf-8 -*-
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import abstract_report_xlsx
from odoo.report import report_sxw
from odoo import _
from odoo import _, models
class TrialBalanceXslx(abstract_report_xlsx.AbstractReportXslx):
def __init__(self, name, table, rml=False, parser=False, header=True,
store=False):
super(TrialBalanceXslx, self).__init__(
name, table, rml, parser, header, store)
class TrialBalanceXslx(models.AbstractModel):
_name = 'report.a_f_r.report_trial_balance_xlsx'
_inherit = 'report.account_financial_report.abstract_report_xlsx'
def _get_report_name(self):
return _('Trial Balance')
@ -111,7 +107,7 @@ class TrialBalanceXslx(abstract_report_xlsx.AbstractReportXslx):
def write_account_footer(self, account, name_value):
"""Specific function to write account footer for Trial Balance"""
for col_pos, column in self.columns.iteritems():
for col_pos, column in self.columns.items():
if column['field'] == 'name':
value = name_value
else:
@ -124,10 +120,3 @@ class TrialBalanceXslx(abstract_report_xlsx.AbstractReportXslx):
self.sheet.write_number(self.row_pos, col_pos, float(value),
self.format_header_amount)
self.row_pos += 1
TrialBalanceXslx(
'report.account_financial_report_qweb.report_trial_balance_xlsx',
'report_trial_balance_qweb',
parser=report_sxw.rml_parse
)

151
account_financial_report/reports.xml

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- PDF/HMTL REPORTS -->
<!-- General Ledger -->
<report
id="action_report_general_ledger_qweb"
model="report_general_ledger"
string="General Ledger"
report_type="qweb-pdf"
name="account_financial_report.report_general_ledger_qweb"
file="account_financial_report.report_general_ledger"
/>
<report
id="action_report_general_ledger_html"
model="report_general_ledger"
string="General Ledger"
report_type="qweb-html"
name="account_financial_report.report_general_ledger_qweb"
file="account_financial_report.report_general_ledger"
/>
<!-- Trial Balance -->
<report
id="action_report_trial_balance_qweb"
model="report_trial_balance"
string="Trial Balance"
report_type="qweb-pdf"
name="account_financial_report.report_trial_balance_qweb"
file="account_financial_report.report_trial_balance_qweb"
/>
<report
id="action_report_trial_balance_html"
model="report_trial_balance"
string="Trial Balance"
report_type="qweb-html"
name="account_financial_report.report_trial_balance_qweb"
file="account_financial_report.report_trial_balance_html"
/>
<!-- Open Items -->
<report
id="action_report_open_items_qweb"
model="report_open_items"
string="Open Items"
report_type="qweb-pdf"
name="account_financial_report.report_open_items_qweb"
file="account_financial_report.report_open_items_qweb"
/>
<report
id="action_report_open_items_html"
model="report_open_items"
string="Open Items"
report_type="qweb-html"
name="account_financial_report.report_open_items_qweb"
file="account_financial_report.report_open_items_html"
/>
<!-- Aged Partner Balance -->
<report
id="action_report_aged_partner_balance_qweb"
model="report_aged_partner_balance"
string="Aged Partner Balance"
report_type="qweb-pdf"
name="account_financial_report.report_aged_partner_balance_qweb"
file="account_financial_report.report_aged_partner_balance_qweb"
/>
<report
id="action_report_aged_partner_balance_html"
model="report_aged_partner_balance"
string="Aged Partner Balance"
report_type="qweb-html"
name="account_financial_report.report_aged_partner_balance_qweb"
file="account_financial_report.report_aged_partner_balance_html"
/>
<!-- PDF REPORTS : paperformat -->
<record id="report_qweb_paperformat" model="report.paperformat">
<field name="name">Account financial report qweb paperformat</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">297</field>
<field name="page_width">210</field>
<field name="orientation">Portrait</field>
<field name="margin_top">12</field>
<field name="margin_bottom">8</field>
<field name="margin_left">5</field>
<field name="margin_right">5</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">10</field>
<field name="dpi">110</field>
</record>
<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_report_open_items_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat"/>
</record>
<record id="action_report_aged_partner_balance_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">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>
<field name="report_file">report_general_ledger</field>
</record>
<record id="action_report_trial_balance_xlsx" model="ir.actions.report">
<field name="name">Trial Balance XLSX</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>
<field name="report_file">report_trial_balance</field>
</record>
<record id="action_report_open_items_xlsx" model="ir.actions.report">
<field name="name">Open Items XLSX</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>
<field name="report_file">report_open_items</field>
</record>
<record id="action_report_aged_partner_balance_xlsx" model="ir.actions.report">
<field name="name">Aged Partner Balance XLSX</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>
<field name="report_file">report_aged_partner_balance</field>
</record>
</odoo>

0
account_financial_report_qweb/static/description/icon.png → account_financial_report/static/description/icon.png

Before

Width: 256  |  Height: 256  |  Size: 15 KiB

After

Width: 256  |  Height: 256  |  Size: 15 KiB

0
account_financial_report_qweb/static/src/css/report.css → account_financial_report/static/src/css/report.css

2
account_financial_report_qweb/tests/__init__.py → account_financial_report/tests/__init__.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-

82
account_financial_report_qweb/tests/abstract_test.py → account_financial_report/tests/abstract_test.py

@ -1,9 +1,16 @@
# -*- coding: utf-8 -*-
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
import logging
_logger = logging.getLogger(__name__)
try:
from xlrd import open_workbook
except ImportError:
_logger.debug('Can not import xlsxwriter`.')
class AbstractTest(TransactionCase):
@ -29,10 +36,11 @@ class AbstractTest(TransactionCase):
"""Check if report PDF/HTML is correctly generated"""
# Check if returned report action is correct
report_action = self.report.print_report()
report_type = 'qweb-pdf'
report_action = self.report.print_report(report_type)
self.assertDictContainsSubset(
{
'type': 'ir.actions.report.xml',
'type': 'ir.actions.report',
'report_name': self.qweb_report_name,
'report_type': 'qweb-pdf',
},
@ -40,38 +48,70 @@ class AbstractTest(TransactionCase):
)
# Check if report template is correct
report_html = self.env['report'].get_html(
self.report.id, self.qweb_report_name
)
self.assertTrue(self.report_title.encode('utf8') in report_html)
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-pdf')
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 report_html
self.report.account_ids[0].name.encode('utf8') in rep[0]
)
def test_02_generation_report_xlsx(self):
"""Check if report XLSX is correctly generated"""
def test_02_generation_report_html(self):
"""Check if report HTML is correctly generated"""
# Check if returned report action is correct
report_action = self.report.print_report(xlsx_report=True)
report_type = 'qweb-html'
report_action = self.report.print_report(report_type)
self.assertDictContainsSubset(
{
'type': 'ir.actions.report.xml',
'report_name': self.xlsx_report_name,
'report_type': 'xlsx',
'type': 'ir.actions.report',
'report_name': self.qweb_report_name,
'report_type': 'qweb-html',
},
report_action
)
# Check if report template is correct
report_xlsx = self.env.ref(self.xlsx_action_name).render_report(
self.report.ids,
self.xlsx_report_name,
{'report_type': 'xlsx'}
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]
)
self.assertGreaterEqual(len(report_xlsx[0]), 1)
self.assertEqual(report_xlsx[1], 'xlsx')
def test_03_compute_data(self):
def test_03_generation_report_xlsx(self):
"""Check if report XLSX is correctly generated"""
report_object = self.env['ir.actions.report']
# Check if returned report action is correct
report_type = 'xlsx'
report_action = self.report.print_report(report_type)
self.assertDictContainsSubset(
{
'type': 'ir.actions.report',
'report_name': self.xlsx_report_name,
'report_type': 'xlsx',
},
report_action
)
report = report_object._get_report_from_name(self.xlsx_report_name)
self.assertEqual(report.report_type, 'xlsx')
report_xlsx = report.render(self.report.ids, {})
wb = open_workbook(file_contents=report_xlsx[0])
sheet = wb.sheet_by_index(0)
class_name = 'report.%s' % report.report_name
self.assertEqual(sheet.cell(0, 0).value,
self.env[class_name]._get_report_name())
def test_04_compute_data(self):
"""Check that the SQL queries work with all filters options"""
for filters in [{}] + self.additional_filters:

10
account_financial_report_qweb/tests/test_aged_partner_balance.py → account_financial_report/tests/test_aged_partner_balance.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -13,16 +13,16 @@ class TestAgedPartnerBalance(abstract_test.AbstractTest):
"""
def _getReportModel(self):
return self.env['report_aged_partner_balance_qweb']
return self.env['report_aged_partner_balance']
def _getQwebReportName(self):
return 'account_financial_report_qweb.report_aged_partner_balance_qweb'
return 'account_financial_report.report_aged_partner_balance_qweb'
def _getXlsxReportName(self):
return 'account_financial_report_qweb.report_aged_partner_balance_xlsx'
return 'a_f_r.report_aged_partner_balance_xlsx'
def _getXlsxReportActionName(self):
return 'account_financial_report_qweb.' \
return 'account_financial_report.' \
'action_report_aged_partner_balance_xlsx'
def _getReportTitle(self):

16
account_financial_report_qweb/tests/test_general_ledger.py → account_financial_report/tests/test_general_ledger.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -14,16 +14,16 @@ class TestGeneralLedger(abstract_test.AbstractTest):
"""
def _getReportModel(self):
return self.env['report_general_ledger_qweb']
return self.env['report_general_ledger']
def _getQwebReportName(self):
return 'account_financial_report_qweb.report_general_ledger_qweb'
return 'account_financial_report.report_general_ledger_qweb'
def _getXlsxReportName(self):
return 'account_financial_report_qweb.report_general_ledger_xlsx'
return 'a_f_r.report_general_ledger_xlsx'
def _getXlsxReportActionName(self):
return 'account_financial_report_qweb.' \
return 'account_financial_report.' \
'action_report_general_ledger_xlsx'
def _getReportTitle(self):
@ -116,7 +116,7 @@ class TestGeneralLedgerReport(TransactionCase):
def _get_report_lines(self, with_partners=False):
company = self.env.ref('base.main_company')
general_ledger = self.env['report_general_ledger_qweb'].create({
general_ledger = self.env['report_general_ledger'].create({
'date_from': self.fy_date_start,
'date_to': self.fy_date_end,
'only_posted_moves': True,
@ -128,7 +128,7 @@ class TestGeneralLedgerReport(TransactionCase):
with_line_details=True, with_partners=with_partners
)
lines = {}
report_account_model = self.env['report_general_ledger_qweb_account']
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),
@ -143,7 +143,7 @@ class TestGeneralLedgerReport(TransactionCase):
])
if with_partners:
report_partner_model = self.env[
'report_general_ledger_qweb_partner'
'report_general_ledger_partner'
]
lines['partner_receivable'] = report_partner_model.search([
('report_account_id', '=', lines['receivable'].id),

10
account_financial_report_qweb/tests/test_open_items.py → account_financial_report/tests/test_open_items.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -13,16 +13,16 @@ class TestOpenItems(abstract_test.AbstractTest):
"""
def _getReportModel(self):
return self.env['report_open_items_qweb']
return self.env['report_open_items']
def _getQwebReportName(self):
return 'account_financial_report_qweb.report_open_items_qweb'
return 'account_financial_report.report_open_items_qweb'
def _getXlsxReportName(self):
return 'account_financial_report_qweb.report_open_items_xlsx'
return 'a_f_r.report_open_items_xlsx'
def _getXlsxReportActionName(self):
return 'account_financial_report_qweb.action_report_open_items_xlsx'
return 'account_financial_report.action_report_open_items_xlsx'
def _getReportTitle(self):
return 'Open Items'

10
account_financial_report_qweb/tests/test_trial_balance.py → account_financial_report/tests/test_trial_balance.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -13,16 +13,16 @@ class TestTrialBalance(abstract_test.AbstractTest):
"""
def _getReportModel(self):
return self.env['report_trial_balance_qweb']
return self.env['report_trial_balance']
def _getQwebReportName(self):
return 'account_financial_report_qweb.report_trial_balance_qweb'
return 'account_financial_report.report_trial_balance_qweb'
def _getXlsxReportName(self):
return 'account_financial_report_qweb.report_trial_balance_xlsx'
return 'a_f_r.report_trial_balance_xlsx'
def _getXlsxReportActionName(self):
return 'account_financial_report_qweb.action_report_trial_balance_xlsx'
return 'account_financial_report.action_report_trial_balance_xlsx'
def _getReportTitle(self):
return 'Trial Balance'

0
account_financial_report_qweb/view/account_view.xml → account_financial_report/view/account_view.xml

2
account_financial_report_qweb/wizard/__init__.py → account_financial_report/wizard/__init__.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Author: Damien Crier
# Author: Julien Coux
# Copyright 2016 Camptocamp SA

20
account_financial_report_qweb/wizard/aged_partner_balance_wizard.py → account_financial_report/wizard/aged_partner_balance_wizard.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Author: Damien Crier, Andrea Stirpe, Kevin Graveman, Dennis Sluijk
# Author: Julien Coux
# Copyright 2016 Camptocamp SA, Onestein B.V.
@ -53,15 +53,23 @@ class AgedPartnerBalance(models.TransientModel):
else:
self.account_ids = None
@api.multi
def button_export_html(self):
self.ensure_one()
report_type = 'qweb-html'
return self._export(report_type)
@api.multi
def button_export_pdf(self):
self.ensure_one()
return self._export()
report_type = 'qweb-pdf'
return self._export(report_type)
@api.multi
def button_export_xlsx(self):
self.ensure_one()
return self._export(xlsx_report=True)
report_type = 'xlsx'
return self._export(report_type)
def _prepare_report_aged_partner_balance(self):
self.ensure_one()
@ -74,8 +82,8 @@ class AgedPartnerBalance(models.TransientModel):
'show_move_line_details': self.show_move_line_details,
}
def _export(self, xlsx_report=False):
def _export(self, report_type):
"""Default export is PDF."""
model = self.env['report_aged_partner_balance_qweb']
model = self.env['report_aged_partner_balance']
report = model.create(self._prepare_report_aged_partner_balance())
return report.print_report(xlsx_report)
return report.print_report(report_type)

5
account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml → account_financial_report/wizard/aged_partner_balance_wizard_view.xml

@ -29,7 +29,10 @@
</group>
<field name="account_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
<footer>
<button name="button_export_pdf" string="Export PDF" type="object" default_focus="1" class="oe_highlight"/>
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>
or
<button name="button_export_pdf" string="Export PDF" type="object"/>
or
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
or

20
account_financial_report_qweb/wizard/general_ledger_wizard.py → account_financial_report/wizard/general_ledger_wizard.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Author: Damien Crier
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
@ -107,15 +107,23 @@ class GeneralLedgerReportWizard(models.TransientModel):
else:
self.receivable_accounts_only = self.payable_accounts_only = False
@api.multi
def button_export_html(self):
self.ensure_one()
report_type = 'qweb-html'
return self._export(report_type)
@api.multi
def button_export_pdf(self):
self.ensure_one()
return self._export()
report_type = 'qweb-pdf'
return self._export(report_type)
@api.multi
def button_export_xlsx(self):
self.ensure_one()
return self._export(xlsx_report=True)
report_type = 'xlsx'
return self._export(report_type)
def _prepare_report_general_ledger(self):
self.ensure_one()
@ -132,8 +140,8 @@ class GeneralLedgerReportWizard(models.TransientModel):
'fy_start_date': self.fy_start_date,
}
def _export(self, xlsx_report=False):
def _export(self, report_type):
"""Default export is PDF."""
model = self.env['report_general_ledger_qweb']
model = self.env['report_general_ledger']
report = model.create(self._prepare_report_general_ledger())
return report.print_report(xlsx_report)
return report.print_report(report_type)

5
account_financial_report_qweb/wizard/general_ledger_wizard_view.xml → account_financial_report/wizard/general_ledger_wizard_view.xml

@ -45,7 +45,10 @@
</div>
<footer>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
<button name="button_export_pdf" string="Export PDF" type="object" default_focus="1" class="oe_highlight"/>
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>
or
<button name="button_export_pdf" string="Export PDF" type="object"/>
or
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
or

20
account_financial_report_qweb/wizard/open_items_wizard.py → account_financial_report/wizard/open_items_wizard.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Author: Damien Crier
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
@ -60,15 +60,23 @@ class OpenItemsReportWizard(models.TransientModel):
else:
self.account_ids = None
@api.multi
def button_export_html(self):
self.ensure_one()
report_type = 'qweb-html'
return self._export(report_type)
@api.multi
def button_export_pdf(self):
self.ensure_one()
return self._export()
report_type = 'qweb-pdf'
return self._export(report_type)
@api.multi
def button_export_xlsx(self):
self.ensure_one()
return self._export(xlsx_report=True)
report_type = 'xlsx'
return self._export(report_type)
def _prepare_report_open_items(self):
self.ensure_one()
@ -81,8 +89,8 @@ class OpenItemsReportWizard(models.TransientModel):
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],
}
def _export(self, xlsx_report=False):
def _export(self, report_type):
"""Default export is PDF."""
model = self.env['report_open_items_qweb']
model = self.env['report_open_items']
report = model.create(self._prepare_report_open_items())
return report.print_report(xlsx_report)
return report.print_report(report_type)

5
account_financial_report_qweb/wizard/open_items_wizard_view.xml → account_financial_report/wizard/open_items_wizard_view.xml

@ -29,7 +29,10 @@
</group>
<field name="account_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
<footer>
<button name="button_export_pdf" string="Export PDF" type="object" default_focus="1" class="oe_highlight"/>
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>
or
<button name="button_export_pdf" string="Export PDF" type="object"/>
or
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
or

20
account_financial_report_qweb/wizard/trial_balance_wizard.py → account_financial_report/wizard/trial_balance_wizard.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# Copyright 2017 Akretion - Alexis de Lattre
@ -101,15 +101,23 @@ class TrialBalanceReportWizard(models.TransientModel):
else:
self.receivable_accounts_only = self.payable_accounts_only = False
@api.multi
def button_export_html(self):
self.ensure_one()
report_type = 'qweb-html'
return self._export(report_type)
@api.multi
def button_export_pdf(self):
self.ensure_one()
return self._export()
report_type = 'qweb-pdf'
return self._export(report_type)
@api.multi
def button_export_xlsx(self):
self.ensure_one()
return self._export(xlsx_report=True)
report_type = 'xlsx'
return self._export(report_type)
def _prepare_report_trial_balance(self):
self.ensure_one()
@ -125,8 +133,8 @@ class TrialBalanceReportWizard(models.TransientModel):
'show_partner_details': self.show_partner_details,
}
def _export(self, xlsx_report=False):
def _export(self, report_type):
"""Default export is PDF."""
model = self.env['report_trial_balance_qweb']
model = self.env['report_trial_balance']
report = model.create(self._prepare_report_trial_balance())
return report.print_report(xlsx_report)
return report.print_report(report_type)

5
account_financial_report_qweb/wizard/trial_balance_wizard_view.xml → account_financial_report/wizard/trial_balance_wizard_view.xml

@ -42,7 +42,10 @@
</div>
<footer>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
<button name="button_export_pdf" string="Export PDF" type="object" default_focus="1" class="oe_highlight"/>
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>
or
<button name="button_export_pdf" string="Export PDF" type="object"/>
or
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
or

19
account_financial_report_qweb/__init__.py

@ -1,19 +0,0 @@
# -*- coding: utf-8 -*-
# Author: Damien Crier
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from . import wizard
# Don't break installations that don't have this module installed
have_report_xlsx = False
try:
from odoo.addons.report_xlsx.report.report_xlsx import ReportXlsx
have_report_xlsx = True
except ImportError:
import logging
logging.getLogger(__name__).warn('Module report_xlsx is not available')
if have_report_xlsx:
from . import report

114
account_financial_report_qweb/reports.xml

@ -1,114 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- PDF REPORTS -->
<report
id="action_report_general_ledger_qweb"
model="report_general_ledger_qweb"
string="General Ledger"
report_type="qweb-pdf"
name="account_financial_report_qweb.report_general_ledger_qweb"
file="account_financial_report_qweb.report_general_ledger_qweb"
/>
<report
id="action_report_trial_balance_qweb"
model="report_trial_balance_qweb"
string="Trial Balance"
report_type="qweb-pdf"
name="account_financial_report_qweb.report_trial_balance_qweb"
file="account_financial_report_qweb.report_trial_balance_qweb"
/>
<report
id="action_report_open_items_qweb"
model="report_open_items_qweb"
string="Open Items"
report_type="qweb-pdf"
name="account_financial_report_qweb.report_open_items_qweb"
file="account_financial_report_qweb.report_open_items_qweb"
/>
<report
id="action_report_aged_partner_balance_qweb"
model="report_aged_partner_balance_qweb"
string="Aged Partner Balance"
report_type="qweb-pdf"
name="account_financial_report_qweb.report_aged_partner_balance_qweb"
file="account_financial_report_qweb.report_aged_partner_balance_qweb"
/>
<!-- PDF REPORTS : paperformat -->
<record id="report_qweb_paperformat" model="report.paperformat">
<field name="name">Account financial report qweb paperformat</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">297</field>
<field name="page_width">210</field>
<field name="orientation">Portrait</field>
<field name="margin_top">12</field>
<field name="margin_bottom">8</field>
<field name="margin_left">5</field>
<field name="margin_right">5</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">10</field>
<field name="dpi">110</field>
</record>
<record id="action_report_general_ledger_qweb" model="ir.actions.report.xml">
<field name="paperformat_id" ref="report_qweb_paperformat"/>
</record>
<record id="action_report_trial_balance_qweb" model="ir.actions.report.xml">
<field name="paperformat_id" ref="report_qweb_paperformat"/>
</record>
<record id="action_report_open_items_qweb" model="ir.actions.report.xml">
<field name="paperformat_id" ref="report_qweb_paperformat"/>
</record>
<record id="action_report_aged_partner_balance_qweb" model="ir.actions.report.xml">
<field name="paperformat_id" ref="report_qweb_paperformat"/>
</record>
<!-- XLSX REPORTS -->
<record id="action_report_general_ledger_xlsx" model="ir.actions.report.xml">
<field name="name">General Ledger XLSX</field>
<field name="model">report_general_ledger_qweb</field>
<field name="type">ir.actions.report.xml</field>
<field name="report_name">account_financial_report_qweb.report_general_ledger_xlsx</field>
<field name="report_type">xlsx</field>
<field name="auto" eval="False"/>
</record>
<record id="action_report_trial_balance_xlsx" model="ir.actions.report.xml">
<field name="name">Trial Balance XLSX</field>
<field name="model">report_trial_balance_qweb</field>
<field name="type">ir.actions.report.xml</field>
<field name="report_name">account_financial_report_qweb.report_trial_balance_xlsx</field>
<field name="report_type">xlsx</field>
<field name="auto" eval="False"/>
</record>
<record id="action_report_open_items_xlsx" model="ir.actions.report.xml">
<field name="name">Open Items XLSX</field>
<field name="model">report_open_items_qweb</field>
<field name="type">ir.actions.report.xml</field>
<field name="report_name">account_financial_report_qweb.report_open_items_xlsx</field>
<field name="report_type">xlsx</field>
<field name="auto" eval="False"/>
</record>
<record id="action_report_aged_partner_balance_xlsx" model="ir.actions.report.xml">
<field name="name">Aged Partner Balance XLSX</field>
<field name="model">report_aged_partner_balance_qweb</field>
<field name="type">ir.actions.report.xml</field>
<field name="report_name">account_financial_report_qweb.report_aged_partner_balance_xlsx</field>
<field name="report_type">xlsx</field>
<field name="auto" eval="False"/>
</record>
</odoo>

3
oca_dependencies.txt

@ -1 +1,4 @@
server-ux
account-financial-tools https://github.com/Eficent/account-financial-tools 11.0-mig-account_fiscal_year
reporting-engine https://github.com/OCA/reporting-engine
server-ux https://github.com/OCA/server-ux

2
requirements.txt

@ -0,0 +1,2 @@
xlsxwriter
xlrd
Loading…
Cancel
Save