-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,618 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
====================== | ||
QWeb Financial Reports | ||
====================== | ||
|
||
This module adds a set of financial reports. They are accessible under | ||
Accounting / Reporting / OCA Reports. | ||
|
||
- General ledger | ||
- Trial Balance | ||
- Open Items | ||
- Aged Partner Balance | ||
|
||
.. 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/11.0 | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/account-financial-reporting/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Jordi Ballester <jordi.ballester@eficient.com> | ||
* Yannick Vaucher <yannick.vaucher@camptocamp.com> | ||
* Simone Orsi <simone.orsi@abstract.com> | ||
* Leonardo Pistone <leonardo.pistone@camptocamp.com> | ||
* Damien Crier <damien.crier@camptocamp.com> | ||
* Andrea Stirpe <a.stirpe@onestein.nl> | ||
* Thomas Rehn <thomas.rehn@initos.com> | ||
* Andrea Gallina <4everamd@gmail.com> | ||
* Robert Rottermann <robert@redcor.ch> | ||
* Ciro Urselli <c.urselli@apuliasoftware.it> | ||
* Francesco Apruzzese <opencode@e-ware.org> | ||
* Lorenzo Battistini <lorenzo.battistini@agilebg.com> | ||
* Julien Coux <julien.coux@camptocamp.com> | ||
* Akim Juillerat <akim.juillerat@camptocamp.com> | ||
* Alexis de Lattre <alexis@via.ecp.fr> | ||
|
||
Much of the work in this module was done at a sprint in Sorrento, Italy in | ||
April 2016. | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import models | ||
from . import report | ||
from . import wizards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2018 Forest and Biomass Romania | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
'name': 'Romania - Accounting Report', | ||
'summary': 'Romania - Accounting Report', | ||
'version': '11.0.1.0.0', | ||
'category': 'Localization', | ||
'author': 'Forest and Biomass Romania, ' | ||
'Odoo Community Association (OCA)', | ||
'website': 'https://www.forbiom.eu', | ||
'license': 'AGPL-3', | ||
'installable': True, | ||
'depends': ['account', 'l10n_ro', 'date_range', 'report_xlsx'], | ||
'data': [ | ||
"views/layouts.xml", | ||
"views/report_template.xml", | ||
"views/report_trial_balance.xml", | ||
"views/trial_balance.xml", | ||
"views/trial_balance_view.xml", | ||
"wizards/trial_balance_wizard_view.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (C) 2018 FOREST AND BIOMASS ROMANIA SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountGroup(models.Model): | ||
_inherit = 'account.group' | ||
|
||
group_child_ids = fields.One2many( | ||
comodel_name='account.group', | ||
inverse_name='parent_id', | ||
string='Child Groups') | ||
account_ids = fields.One2many( | ||
comodel_name='account.account', | ||
inverse_name='group_id', | ||
string="Accounts") | ||
compute_account_ids = fields.Many2many( | ||
'account.account', | ||
compute='_compute_group_accounts', | ||
string="Accounts", store=True) | ||
|
||
@api.multi | ||
@api.depends('code_prefix', 'account_ids', | ||
'group_child_ids', 'group_child_ids.account_ids') | ||
def _compute_group_accounts(self): | ||
account_obj = self.env['account.account'] | ||
company_id = self.env.user.company_id.id | ||
comp_accounts = account_obj.search([('company_id', '=', company_id)]) | ||
for group in self.filtered(lambda g: g.code_prefix is not False): | ||
gr_acc = comp_accounts.filtered( | ||
lambda a: a.code.startswith(group.code_prefix)).ids | ||
group.compute_account_ids = [(6, 0, gr_acc)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import trial_balance | ||
from . import abstract_report_xlsx | ||
from . import trial_balance_xlsx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
# Copyright 2018 Forest and Biomass Romania | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models | ||
|
||
|
||
class AbstractReportXslx(models.AbstractModel): | ||
_name = 'report.romania.account.abstract_report_xlsx' | ||
_inherit = 'report.report_xlsx.abstract' | ||
|
||
def __init__(self, pool, cr): | ||
# main sheet which will contains report | ||
self.sheet = None | ||
|
||
# columns of the report | ||
self.columns = None | ||
|
||
# row_pos must be incremented at each writing lines | ||
self.row_pos = None | ||
|
||
def get_workbook_options(self): | ||
return {'constant_memory': True} | ||
|
||
def generate_xlsx_report(self, workbook, data, objects): | ||
report = objects | ||
|
||
self.row_pos = 0 | ||
|
||
self._define_formats(workbook) | ||
|
||
comp_data = self._get_report_company_name(report) | ||
report_name = self._get_report_name() | ||
filters = self._get_report_filters(report) | ||
self.columns = self._get_report_columns(report) | ||
|
||
self.sheet = workbook.add_worksheet(report_name[:31]) | ||
|
||
self._set_column_width() | ||
|
||
self._write_report_company_data(workbook, comp_data) | ||
self._write_report_title(workbook, report_name) | ||
|
||
self._write_filters(workbook, filters) | ||
|
||
self._generate_report_content(workbook, report) | ||
|
||
def _define_formats(self, workbook): | ||
""" Add cell formats to current workbook. | ||
Those formats can be used on all cell. | ||
Available formats are : | ||
* format_bold | ||
* format_right | ||
* format_right_bold_italic | ||
* format_header_left | ||
* format_header_center | ||
* format_header_right | ||
* format_header_amount | ||
* format_amount | ||
* format_percent_bold_italic | ||
""" | ||
self.format_bold = workbook.add_format({'bold': True}) | ||
self.format_right = workbook.add_format({'align': 'right'}) | ||
self.format_right_bold_italic = workbook.add_format( | ||
{'align': 'right', 'bold': True, 'italic': True} | ||
) | ||
self.format_header_left = workbook.add_format( | ||
{'bold': True, | ||
'border': True, | ||
'bg_color': '#FFFFCC'}) | ||
self.format_header_center = workbook.add_format( | ||
{'bold': True, | ||
'align': 'center', | ||
'border': True, | ||
'bg_color': '#FFFFCC'}) | ||
self.format_header_right = workbook.add_format( | ||
{'bold': True, | ||
'align': 'right', | ||
'border': True, | ||
'bg_color': '#FFFFCC'}) | ||
self.format_header_amount = workbook.add_format( | ||
{'bold': True, | ||
'border': True, | ||
'bg_color': '#FFFFCC'}) | ||
self.format_header_amount.set_num_format('#,##0.00') | ||
self.format_amount = workbook.add_format() | ||
self.format_amount.set_num_format('#,##0.00') | ||
self.format_percent_bold_italic = workbook.add_format( | ||
{'bold': True, 'italic': True} | ||
) | ||
self.format_percent_bold_italic.set_num_format('#,##0.00%') | ||
|
||
def _set_column_width(self): | ||
"""Set width for all defined columns. | ||
Columns are defined with `_get_report_columns` method. | ||
""" | ||
for position, column in self.columns.items(): | ||
self.sheet.set_column(position, position, column['width']) | ||
|
||
def _write_report_company_data(self, workbook, company_name): | ||
"""Write report title on current line using all defined columns width. | ||
Columns are defined with `_get_report_columns` method. | ||
""" | ||
for line in company_name.splitlines(): | ||
self.sheet.merge_range( | ||
self.row_pos, 0, self.row_pos, len(self.columns) - 1, | ||
line, workbook.add_format({'bold': True}) | ||
) | ||
self.row_pos += 1 | ||
self.row_pos += 1 | ||
|
||
def _write_report_title(self, workbook, title): | ||
"""Write report title on current line using all defined columns width. | ||
Columns are defined with `_get_report_columns` method. | ||
""" | ||
self.sheet.merge_range( | ||
self.row_pos, 0, self.row_pos, len(self.columns) - 1, | ||
title, workbook.add_format({'bold': True}) | ||
) | ||
self.row_pos += 3 | ||
|
||
def _write_filters(self, workbook, filters): | ||
"""Write one line per filters on starting on current line. | ||
Columns number for filter name is defined | ||
with `_get_col_count_filter_name` method. | ||
Columns number for filter value is define | ||
with `_get_col_count_filter_value` method. | ||
""" | ||
col_name = 1 | ||
col_count_filter_name = self._get_col_count_filter_name() | ||
col_count_filter_value = self._get_col_count_filter_value() | ||
col_value = col_name + col_count_filter_name + 1 | ||
for title, value in filters: | ||
self.sheet.merge_range( | ||
self.row_pos, col_name, | ||
self.row_pos, col_name + col_count_filter_name - 1, | ||
title, workbook.add_format( | ||
{'bold': True, | ||
'border': True, | ||
'bg_color': '#FFFFCC'})) | ||
self.sheet.merge_range( | ||
self.row_pos, col_value, | ||
self.row_pos, col_value + col_count_filter_value - 1, | ||
value) | ||
self.row_pos += 1 | ||
self.row_pos += 2 | ||
|
||
def write_array_title(self, workbook, title): | ||
"""Write array title on current line using all defined columns width. | ||
Columns are defined with `_get_report_columns` method. | ||
""" | ||
self.sheet.merge_range( | ||
self.row_pos, 0, self.row_pos, len(self.columns) - 1, | ||
title, workbook.add_format({'bold': True}) | ||
) | ||
self.row_pos += 1 | ||
|
||
def write_array_header(self, workbook): | ||
"""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.items(): | ||
self.sheet.write(self.row_pos, col_pos, column['header'], | ||
workbook.add_format( | ||
{'bold': True, | ||
'align': 'center', | ||
'border': True, | ||
'bg_color': '#FFFFCC'})) | ||
self.row_pos += 1 | ||
|
||
def write_line(self, workbook, line_object, formats): | ||
"""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.items(): | ||
value = getattr(line_object, column['field']) | ||
cell_type = column.get('type', 'string') | ||
if cell_type == 'string': | ||
self.sheet.write_string(self.row_pos, col_pos, value or '', | ||
workbook.add_format(formats)) | ||
elif cell_type == 'amount': | ||
self.sheet.write_number( | ||
self.row_pos, col_pos, float(value), | ||
workbook.add_format(formats) | ||
) | ||
self.row_pos += 1 | ||
|
||
def _generate_report_content(self, workbook, report): | ||
pass | ||
|
||
def _get_report_company_name(self, report): | ||
""" | ||
Allow to define the report company data. | ||
Company data will be printed in columns A1. | ||
:return: the company data | ||
""" | ||
raise NotImplementedError() | ||
|
||
def _get_report_name(self): | ||
""" | ||
Allow to define the report name. | ||
Report name will be used as sheet name and as report title. | ||
:return: the report name | ||
""" | ||
raise NotImplementedError() | ||
|
||
def _get_report_columns(self, report): | ||
""" | ||
Allow to define the report columns | ||
which will be used to generate report. | ||
:return: the report columns as dict | ||
:Example: | ||
{ | ||
0: {'header': 'Simple column', | ||
'field': 'field_name_on_my_object', | ||
'width': 11}, | ||
1: {'header': 'Amount column', | ||
'field': 'field_name_on_my_object', | ||
'type': 'amount', | ||
'width': 14}, | ||
} | ||
""" | ||
raise NotImplementedError() | ||
|
||
def _get_report_filters(self, report): | ||
""" | ||
:return: the report filters as list | ||
:Example: | ||
[ | ||
['first_filter_name', 'first_filter_value'], | ||
['second_filter_name', 'second_filter_value'] | ||
] | ||
""" | ||
raise NotImplementedError() | ||
|
||
def _get_col_count_filter_name(self): | ||
""" | ||
:return: the columns number used for filter names. | ||
""" | ||
raise NotImplementedError() | ||
|
||
def _get_col_count_filter_value(self): | ||
""" | ||
:return: the columns number used for filter values. | ||
""" | ||
raise NotImplementedError() |
Oops, something went wrong.