[MIG] account_financial_report: Migration to 14.0
Since v14, Odoo defines the `__slots__` attribute in the `BaseModel` class (ea3e39506a
)
This makes it impossible to add attributes to an instance like it was done here in v13.
The use of the `report_data` dictionary passed between method is the closes and simples solution to this "issue".
TT26415
Co-authored-by: Alex Cuellar <acuellar@grupoyacck.com>
pull/868/head
parent
1e92a40691
commit
1fc07d0633
|
@ -14,13 +14,13 @@ Account Financial Reports
|
||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github
|
||||||
:target: https://github.com/OCA/account-financial-reporting/tree/13.0/account_financial_report
|
:target: https://github.com/OCA/account-financial-reporting/tree/14.0/account_financial_report
|
||||||
:alt: OCA/account-financial-reporting
|
:alt: OCA/account-financial-reporting
|
||||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||||
:target: https://translation.odoo-community.org/projects/account-financial-reporting-13-0/account-financial-reporting-13-0-account_financial_report
|
:target: https://translation.odoo-community.org/projects/account-financial-reporting-14-0/account-financial-reporting-14-0-account_financial_report
|
||||||
:alt: Translate me on Weblate
|
:alt: Translate me on Weblate
|
||||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||||
:target: https://runbot.odoo-community.org/runbot/91/13.0
|
:target: https://runbot.odoo-community.org/runbot/91/14.0
|
||||||
:alt: Try me on Runbot
|
:alt: Try me on Runbot
|
||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||||
|
@ -87,7 +87,7 @@ Bug Tracker
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_financial_report%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_financial_report%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
@ -128,6 +128,7 @@ Contributors
|
||||||
* Pedro M. Baeza
|
* Pedro M. Baeza
|
||||||
* Sergio Teruel
|
* Sergio Teruel
|
||||||
* Ernesto Tejeda
|
* Ernesto Tejeda
|
||||||
|
* João Marques
|
||||||
|
|
||||||
Much of the work in this module was done at a sprint in Sorrento, Italy in
|
Much of the work in this module was done at a sprint in Sorrento, Italy in
|
||||||
April 2016.
|
April 2016.
|
||||||
|
@ -145,6 +146,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.
|
promote its widespread use.
|
||||||
|
|
||||||
This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/13.0/account_financial_report>`_ project on GitHub.
|
This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/14.0/account_financial_report>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
# Author: Julien Coux
|
# Author: Julien Coux
|
||||||
# Copyright 2016 Camptocamp SA
|
# Copyright 2016 Camptocamp SA
|
||||||
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
|
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
# Copyright 2021 Tecnativa - João Marques
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
{
|
{
|
||||||
"name": "Account Financial Reports",
|
"name": "Account Financial Reports",
|
||||||
"version": "13.0.1.4.1",
|
"version": "14.0.1.0.0",
|
||||||
"category": "Reporting",
|
"category": "Reporting",
|
||||||
"summary": "OCA Financial Reports",
|
"summary": "OCA Financial Reports",
|
||||||
"author": "Camptocamp SA,"
|
"author": "Camptocamp SA,"
|
||||||
|
@ -13,9 +14,10 @@
|
||||||
"redCOR AG,"
|
"redCOR AG,"
|
||||||
"ForgeFlow,"
|
"ForgeFlow,"
|
||||||
"Odoo Community Association (OCA)",
|
"Odoo Community Association (OCA)",
|
||||||
"website": "https://odoo-community.org/",
|
"website": "https://github.com/OCA/account-financial-reporting",
|
||||||
"depends": ["account", "date_range", "report_xlsx"],
|
"depends": ["account", "date_range", "report_xlsx"],
|
||||||
"data": [
|
"data": [
|
||||||
|
"security/ir.model.access.csv",
|
||||||
"wizard/aged_partner_balance_wizard_view.xml",
|
"wizard/aged_partner_balance_wizard_view.xml",
|
||||||
"wizard/general_ledger_wizard_view.xml",
|
"wizard/general_ledger_wizard_view.xml",
|
||||||
"wizard/journal_ledger_wizard_view.xml",
|
"wizard/journal_ledger_wizard_view.xml",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from . import account
|
|
||||||
from . import account_group
|
from . import account_group
|
||||||
|
from . import account
|
||||||
from . import account_move_line
|
from . import account_move_line
|
||||||
from . import ir_actions_report
|
from . import ir_actions_report
|
||||||
|
|
|
@ -10,7 +10,7 @@ class AccountGroup(models.Model):
|
||||||
group_child_ids = fields.One2many(
|
group_child_ids = fields.One2many(
|
||||||
comodel_name="account.group", inverse_name="parent_id", string="Child Groups"
|
comodel_name="account.group", inverse_name="parent_id", string="Child Groups"
|
||||||
)
|
)
|
||||||
level = fields.Integer(string="Level", compute="_compute_level", store=True)
|
level = fields.Integer(string="Level", compute="_compute_level")
|
||||||
account_ids = fields.One2many(
|
account_ids = fields.One2many(
|
||||||
comodel_name="account.account", inverse_name="group_id", string="Accounts"
|
comodel_name="account.account", inverse_name="group_id", string="Accounts"
|
||||||
)
|
)
|
||||||
|
@ -31,15 +31,15 @@ class AccountGroup(models.Model):
|
||||||
else:
|
else:
|
||||||
self.complete_name = self.name
|
self.complete_name = self.name
|
||||||
|
|
||||||
@api.depends("code_prefix", "parent_id.complete_code")
|
@api.depends("code_prefix_start", "parent_id.complete_code")
|
||||||
def _compute_complete_code(self):
|
def _compute_complete_code(self):
|
||||||
""" Forms complete code of location from parent location to child location. """
|
""" Forms complete code of location from parent location to child location. """
|
||||||
if self.parent_id.complete_code:
|
if self.parent_id.complete_code:
|
||||||
self.complete_code = "{}/{}".format(
|
self.complete_code = "{}/{}".format(
|
||||||
self.parent_id.complete_code, self.code_prefix
|
self.parent_id.complete_code, self.code_prefix_start
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.complete_code = self.code_prefix
|
self.complete_code = self.code_prefix_start
|
||||||
|
|
||||||
@api.depends("parent_id", "parent_id.level")
|
@api.depends("parent_id", "parent_id.level")
|
||||||
def _compute_level(self):
|
def _compute_level(self):
|
||||||
|
@ -50,7 +50,7 @@ class AccountGroup(models.Model):
|
||||||
group.level = group.parent_id.level + 1
|
group.level = group.parent_id.level + 1
|
||||||
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
"code_prefix",
|
"code_prefix_start",
|
||||||
"account_ids",
|
"account_ids",
|
||||||
"account_ids.code",
|
"account_ids.code",
|
||||||
"group_child_ids",
|
"group_child_ids",
|
||||||
|
@ -60,6 +60,6 @@ class AccountGroup(models.Model):
|
||||||
account_obj = self.env["account.account"]
|
account_obj = self.env["account.account"]
|
||||||
accounts = account_obj.search([])
|
accounts = account_obj.search([])
|
||||||
for group in self:
|
for group in self:
|
||||||
prefix = group.code_prefix if group.code_prefix else group.name
|
prefix = group.code_prefix_start if group.code_prefix_start else group.name
|
||||||
gr_acc = accounts.filtered(lambda a: a.code.startswith(prefix)).ids
|
gr_acc = accounts.filtered(lambda a: a.code.startswith(prefix)).ids
|
||||||
group.compute_account_ids = [(6, 0, gr_acc)]
|
group.compute_account_ids = [(6, 0, gr_acc)]
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
* Pedro M. Baeza
|
* Pedro M. Baeza
|
||||||
* Sergio Teruel
|
* Sergio Teruel
|
||||||
* Ernesto Tejeda
|
* Ernesto Tejeda
|
||||||
|
* João Marques
|
||||||
|
|
||||||
Much of the work in this module was done at a sprint in Sorrento, Italy in
|
Much of the work in this module was done at a sprint in Sorrento, Italy in
|
||||||
April 2016.
|
April 2016.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Author: Julien Coux
|
# Author: Julien Coux
|
||||||
# Copyright 2016 Camptocamp SA
|
# Copyright 2016 Camptocamp SA
|
||||||
|
# Copyright 2021 Tecnativa - João Marques
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
from odoo import models
|
from odoo import models
|
||||||
|
|
||||||
|
@ -9,56 +10,37 @@ class AbstractReportXslx(models.AbstractModel):
|
||||||
_description = "Abstract XLSX Account Financial Report"
|
_description = "Abstract XLSX Account Financial Report"
|
||||||
_inherit = "report.report_xlsx.abstract"
|
_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
|
|
||||||
|
|
||||||
# Formats
|
|
||||||
self.format_right = None
|
|
||||||
self.format_left = None
|
|
||||||
self.format_right_bold_italic = None
|
|
||||||
self.format_bold = None
|
|
||||||
self.format_header_left = None
|
|
||||||
self.format_header_center = None
|
|
||||||
self.format_header_right = None
|
|
||||||
self.format_header_amount = None
|
|
||||||
self.format_amount = None
|
|
||||||
self.format_percent_bold_italic = None
|
|
||||||
|
|
||||||
def get_workbook_options(self):
|
def get_workbook_options(self):
|
||||||
return {"constant_memory": True}
|
vals = super().get_workbook_options()
|
||||||
|
vals.update({"constant_memory": True})
|
||||||
|
return vals
|
||||||
|
|
||||||
def generate_xlsx_report(self, workbook, data, objects):
|
def generate_xlsx_report(self, workbook, data, objects):
|
||||||
report = objects
|
# Initialize report variables
|
||||||
|
report_data = {
|
||||||
self.row_pos = 0
|
"workbook": None,
|
||||||
|
"sheet": None, # main sheet which will contains report
|
||||||
self._define_formats(workbook)
|
"columns": None, # columns of the report
|
||||||
|
"row_pos": None, # row_pos must be incremented at each writing lines
|
||||||
report_name = self._get_report_name(report, data=data)
|
"formats": None,
|
||||||
|
}
|
||||||
|
self._define_formats(workbook, report_data)
|
||||||
|
# Get report data
|
||||||
|
report_name = self._get_report_name(objects, data=data)
|
||||||
report_footer = self._get_report_footer()
|
report_footer = self._get_report_footer()
|
||||||
filters = self._get_report_filters(report)
|
filters = self._get_report_filters(objects)
|
||||||
self.columns = self._get_report_columns(report)
|
report_data["columns"] = self._get_report_columns(objects)
|
||||||
self.workbook = workbook
|
report_data["workbook"] = workbook
|
||||||
self.sheet = workbook.add_worksheet(report_name[:31])
|
report_data["sheet"] = workbook.add_worksheet(report_name[:31])
|
||||||
|
self._set_column_width(report_data)
|
||||||
|
# Fill report
|
||||||
|
report_data["row_pos"] = 0
|
||||||
|
self._write_report_title(report_name, report_data)
|
||||||
|
self._write_filters(filters, report_data)
|
||||||
|
self._generate_report_content(workbook, objects, data, report_data)
|
||||||
|
self._write_report_footer(report_footer, report_data)
|
||||||
|
|
||||||
self._set_column_width()
|
def _define_formats(self, workbook, report_data):
|
||||||
|
|
||||||
self._write_report_title(report_name)
|
|
||||||
|
|
||||||
self._write_filters(filters)
|
|
||||||
|
|
||||||
self._generate_report_content(workbook, report, data)
|
|
||||||
|
|
||||||
self._write_report_footer(report_footer)
|
|
||||||
|
|
||||||
def _define_formats(self, workbook):
|
|
||||||
"""Add cell formats to current workbook.
|
"""Add cell formats to current workbook.
|
||||||
Those formats can be used on all cell.
|
Those formats can be used on all cell.
|
||||||
Available formats are :
|
Available formats are :
|
||||||
|
@ -72,77 +54,75 @@ class AbstractReportXslx(models.AbstractModel):
|
||||||
* format_amount
|
* format_amount
|
||||||
* format_percent_bold_italic
|
* format_percent_bold_italic
|
||||||
"""
|
"""
|
||||||
self.format_bold = workbook.add_format({"bold": True})
|
currency_id = self.env["res.company"]._default_currency_id()
|
||||||
self.format_right = workbook.add_format({"align": "right"})
|
report_data["formats"] = {
|
||||||
self.format_left = workbook.add_format({"align": "left"})
|
"format_bold": workbook.add_format({"bold": True}),
|
||||||
self.format_right_bold_italic = workbook.add_format(
|
"format_right": workbook.add_format({"align": "right"}),
|
||||||
{"align": "right", "bold": True, "italic": True}
|
"format_left": workbook.add_format({"align": "left"}),
|
||||||
)
|
"format_right_bold_italic": workbook.add_format(
|
||||||
self.format_header_left = workbook.add_format(
|
{"align": "right", "bold": True, "italic": True}
|
||||||
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
),
|
||||||
)
|
"format_header_left": workbook.add_format(
|
||||||
self.format_header_center = workbook.add_format(
|
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
||||||
{"bold": True, "align": "center", "border": True, "bg_color": "#FFFFCC"}
|
),
|
||||||
)
|
"format_header_center": workbook.add_format(
|
||||||
self.format_header_right = workbook.add_format(
|
{"bold": True, "align": "center", "border": True, "bg_color": "#FFFFCC"}
|
||||||
{"bold": True, "align": "right", "border": True, "bg_color": "#FFFFCC"}
|
),
|
||||||
)
|
"format_header_right": workbook.add_format(
|
||||||
self.format_header_amount = workbook.add_format(
|
{"bold": True, "align": "right", "border": True, "bg_color": "#FFFFCC"}
|
||||||
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
),
|
||||||
)
|
"format_header_amount": workbook.add_format(
|
||||||
currency_id = self.env["res.company"]._get_user_currency()
|
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
||||||
self.format_header_amount.set_num_format(
|
).set_num_format("#,##0." + "0" * currency_id.decimal_places),
|
||||||
"#,##0." + "0" * currency_id.decimal_places
|
"format_amount": workbook.add_format().set_num_format(
|
||||||
)
|
"#,##0." + "0" * currency_id.decimal_places
|
||||||
self.format_amount = workbook.add_format()
|
),
|
||||||
self.format_amount.set_num_format("#,##0." + "0" * currency_id.decimal_places)
|
"format_amount_bold": workbook.add_format({"bold": True}).set_num_format(
|
||||||
self.format_amount_bold = workbook.add_format({"bold": True})
|
"#,##0." + "0" * currency_id.decimal_places
|
||||||
self.format_amount_bold.set_num_format(
|
),
|
||||||
"#,##0." + "0" * currency_id.decimal_places
|
"format_percent_bold_italic": workbook.add_format(
|
||||||
)
|
{"bold": True, "italic": True}
|
||||||
self.format_percent_bold_italic = workbook.add_format(
|
).set_num_format("#,##0.00%"),
|
||||||
{"bold": True, "italic": True}
|
}
|
||||||
)
|
|
||||||
self.format_percent_bold_italic.set_num_format("#,##0.00%")
|
|
||||||
|
|
||||||
def _set_column_width(self):
|
def _set_column_width(self, report_data):
|
||||||
"""Set width for all defined columns.
|
"""Set width for all defined columns.
|
||||||
Columns are defined with `_get_report_columns` method.
|
Columns are defined with `_get_report_columns` method.
|
||||||
"""
|
"""
|
||||||
for position, column in self.columns.items():
|
for position, column in report_data["columns"].items():
|
||||||
self.sheet.set_column(position, position, column["width"])
|
report_data["sheet"].set_column(position, position, column["width"])
|
||||||
|
|
||||||
def _write_report_title(self, title):
|
def _write_report_title(self, title, report_data):
|
||||||
"""Write report title on current line using all defined columns width.
|
"""Write report title on current line using all defined columns width.
|
||||||
Columns are defined with `_get_report_columns` method.
|
Columns are defined with `_get_report_columns` method.
|
||||||
"""
|
"""
|
||||||
self.sheet.merge_range(
|
report_data["sheet"].merge_range(
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
0,
|
0,
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
len(self.columns) - 1,
|
len(report_data["columns"]) - 1,
|
||||||
title,
|
title,
|
||||||
self.format_bold,
|
report_data["formats"]["format_bold"],
|
||||||
)
|
)
|
||||||
self.row_pos += 3
|
report_data["row_pos"] += 3
|
||||||
|
|
||||||
def _write_report_footer(self, footer):
|
def _write_report_footer(self, footer, report_data):
|
||||||
"""Write report footer .
|
"""Write report footer .
|
||||||
Columns are defined with `_get_report_columns` method.
|
Columns are defined with `_get_report_columns` method.
|
||||||
"""
|
"""
|
||||||
if footer:
|
if footer:
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
self.sheet.merge_range(
|
report_data["sheet"].merge_range(
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
0,
|
0,
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
len(self.columns) - 1,
|
len(report_data["columns"]) - 1,
|
||||||
footer,
|
footer,
|
||||||
self.format_left,
|
report_data["formats"]["format_left"],
|
||||||
)
|
)
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
def _write_filters(self, filters):
|
def _write_filters(self, filters, report_data):
|
||||||
"""Write one line per filters on starting on current line.
|
"""Write one line per filters on starting on current line.
|
||||||
Columns number for filter name is defined
|
Columns number for filter name is defined
|
||||||
with `_get_col_count_filter_name` method.
|
with `_get_col_count_filter_name` method.
|
||||||
|
@ -154,91 +134,102 @@ class AbstractReportXslx(models.AbstractModel):
|
||||||
col_count_filter_value = self._get_col_count_filter_value()
|
col_count_filter_value = self._get_col_count_filter_value()
|
||||||
col_value = col_name + col_count_filter_name + 1
|
col_value = col_name + col_count_filter_name + 1
|
||||||
for title, value in filters:
|
for title, value in filters:
|
||||||
self.sheet.merge_range(
|
report_data["sheet"].merge_range(
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
col_name,
|
col_name,
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
col_name + col_count_filter_name - 1,
|
col_name + col_count_filter_name - 1,
|
||||||
title,
|
title,
|
||||||
self.format_header_left,
|
report_data["formats"]["format_header_left"],
|
||||||
)
|
)
|
||||||
self.sheet.merge_range(
|
report_data["sheet"].merge_range(
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
col_value,
|
col_value,
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
col_value + col_count_filter_value - 1,
|
col_value + col_count_filter_value - 1,
|
||||||
value,
|
value,
|
||||||
)
|
)
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
self.row_pos += 2
|
report_data["row_pos"] += 2
|
||||||
|
|
||||||
def write_array_title(self, title):
|
def write_array_title(self, title, report_data):
|
||||||
"""Write array title on current line using all defined columns width.
|
"""Write array title on current line using all defined columns width.
|
||||||
Columns are defined with `_get_report_columns` method.
|
Columns are defined with `_get_report_columns` method.
|
||||||
"""
|
"""
|
||||||
self.sheet.merge_range(
|
report_data["sheet"].merge_range(
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
0,
|
0,
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
len(self.columns) - 1,
|
len(report_data["columns"]) - 1,
|
||||||
title,
|
title,
|
||||||
self.format_bold,
|
report_data["formats"]["format_bold"],
|
||||||
)
|
)
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
def write_array_header(self):
|
def write_array_header(self, report_data):
|
||||||
"""Write array header on current line using all defined columns name.
|
"""Write array header on current line using all defined columns name.
|
||||||
Columns are defined with `_get_report_columns` method.
|
Columns are defined with `_get_report_columns` method.
|
||||||
"""
|
"""
|
||||||
for col_pos, column in self.columns.items():
|
for col_pos, column in report_data["columns"].items():
|
||||||
self.sheet.write(
|
report_data["sheet"].write(
|
||||||
self.row_pos, col_pos, column["header"], self.format_header_center
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
column["header"],
|
||||||
|
report_data["formats"]["format_header_center"],
|
||||||
)
|
)
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
def write_line(self, line_object):
|
def write_line(self, line_object, report_data):
|
||||||
"""Write a line on current line using all defined columns field name.
|
"""Write a line on current line using all defined columns field name.
|
||||||
Columns are defined with `_get_report_columns` method.
|
Columns are defined with `_get_report_columns` method.
|
||||||
"""
|
"""
|
||||||
for col_pos, column in self.columns.items():
|
for col_pos, column in report_data["columns"].items():
|
||||||
value = getattr(line_object, column["field"])
|
value = getattr(line_object, column["field"])
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "many2one":
|
if cell_type == "many2one":
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value.name or "", self.format_right
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value.name or "",
|
||||||
|
report_data["formats"]["format_right"],
|
||||||
)
|
)
|
||||||
elif cell_type == "string":
|
elif cell_type == "string":
|
||||||
if (
|
if (
|
||||||
hasattr(line_object, "account_group_id")
|
hasattr(line_object, "account_group_id")
|
||||||
and line_object.account_group_id
|
and line_object.account_group_id
|
||||||
):
|
):
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value or "", self.format_bold
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value or "",
|
||||||
|
report_data["formats"]["format_bold"],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.sheet.write_string(self.row_pos, col_pos, value or "")
|
report_data["sheet"].write_string(
|
||||||
|
report_data["row_pos"], col_pos, value or ""
|
||||||
|
)
|
||||||
elif cell_type == "amount":
|
elif cell_type == "amount":
|
||||||
if (
|
if (
|
||||||
hasattr(line_object, "account_group_id")
|
hasattr(line_object, "account_group_id")
|
||||||
and line_object.account_group_id
|
and line_object.account_group_id
|
||||||
):
|
):
|
||||||
cell_format = self.format_amount_bold
|
cell_format = report_data["formats"]["format_amount_bold"]
|
||||||
else:
|
else:
|
||||||
cell_format = self.format_amount
|
cell_format = report_data["formats"]["format_amount"]
|
||||||
self.sheet.write_number(
|
report_data["sheet"].write_number(
|
||||||
self.row_pos, col_pos, float(value), cell_format
|
report_data["row_pos"], col_pos, float(value), cell_format
|
||||||
)
|
)
|
||||||
elif cell_type == "amount_currency":
|
elif cell_type == "amount_currency":
|
||||||
if line_object.currency_id:
|
if line_object.currency_id:
|
||||||
format_amt = self._get_currency_amt_format(line_object)
|
format_amt = self._get_currency_amt_format(line_object, report_data)
|
||||||
self.sheet.write_number(
|
report_data["sheet"].write_number(
|
||||||
self.row_pos, col_pos, float(value), format_amt
|
report_data["row_pos"], col_pos, float(value), format_amt
|
||||||
)
|
)
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
def write_line_from_dict(self, line_dict):
|
def write_line_from_dict(self, line_dict, report_data):
|
||||||
"""Write a line on current line"""
|
"""Write a line on current line"""
|
||||||
for col_pos, column in self.columns.items():
|
for col_pos, column in report_data["columns"].items():
|
||||||
value = line_dict.get(column["field"], False)
|
value = line_dict.get(column["field"], False)
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "string":
|
if cell_type == "string":
|
||||||
|
@ -246,8 +237,11 @@ class AbstractReportXslx(models.AbstractModel):
|
||||||
line_dict.get("account_group_id", False)
|
line_dict.get("account_group_id", False)
|
||||||
and line_dict["account_group_id"]
|
and line_dict["account_group_id"]
|
||||||
):
|
):
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value or "", self.format_bold
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value or "",
|
||||||
|
report_data["formats"]["format_bold"],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if (
|
if (
|
||||||
|
@ -256,223 +250,302 @@ class AbstractReportXslx(models.AbstractModel):
|
||||||
and not isinstance(value, int)
|
and not isinstance(value, int)
|
||||||
):
|
):
|
||||||
value = value and value.strftime("%d/%m/%Y")
|
value = value and value.strftime("%d/%m/%Y")
|
||||||
self.sheet.write_string(self.row_pos, col_pos, value or "")
|
report_data["sheet"].write_string(
|
||||||
|
report_data["row_pos"], col_pos, value or ""
|
||||||
|
)
|
||||||
elif cell_type == "amount":
|
elif cell_type == "amount":
|
||||||
if (
|
if (
|
||||||
line_dict.get("account_group_id", False)
|
line_dict.get("account_group_id", False)
|
||||||
and line_dict["account_group_id"]
|
and line_dict["account_group_id"]
|
||||||
):
|
):
|
||||||
cell_format = self.format_amount_bold
|
cell_format = report_data["formats"]["format_amount_bold"]
|
||||||
else:
|
else:
|
||||||
cell_format = self.format_amount
|
cell_format = report_data["formats"]["format_amount"]
|
||||||
self.sheet.write_number(
|
report_data["sheet"].write_number(
|
||||||
self.row_pos, col_pos, float(value), cell_format
|
report_data["row_pos"], col_pos, float(value), cell_format
|
||||||
)
|
)
|
||||||
elif cell_type == "amount_currency":
|
elif cell_type == "amount_currency":
|
||||||
if line_dict.get("currency_name", False):
|
if line_dict.get("currency_name", False):
|
||||||
format_amt = self._get_currency_amt_format_dict(line_dict)
|
format_amt = self._get_currency_amt_format_dict(
|
||||||
self.sheet.write_number(
|
line_dict, report_data
|
||||||
self.row_pos, col_pos, float(value), format_amt
|
)
|
||||||
|
report_data["sheet"].write_number(
|
||||||
|
report_data["row_pos"], col_pos, float(value), format_amt
|
||||||
)
|
)
|
||||||
elif cell_type == "currency_name":
|
elif cell_type == "currency_name":
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value or "", self.format_right
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value or "",
|
||||||
|
report_data["formats"]["format_right"],
|
||||||
)
|
)
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
def write_initial_balance(self, my_object, label):
|
def write_initial_balance(self, my_object, label, report_data):
|
||||||
"""Write a specific initial balance line on current line
|
"""Write a specific initial balance line on current line
|
||||||
using defined columns field_initial_balance name.
|
using defined columns field_initial_balance name.
|
||||||
Columns are defined with `_get_report_columns` method.
|
Columns are defined with `_get_report_columns` method.
|
||||||
"""
|
"""
|
||||||
col_pos_label = self._get_col_pos_initial_balance_label()
|
col_pos_label = self._get_col_pos_initial_balance_label()
|
||||||
self.sheet.write(self.row_pos, col_pos_label, label, self.format_right)
|
report_data["sheet"].write(
|
||||||
for col_pos, column in self.columns.items():
|
report_data["row_pos"],
|
||||||
|
col_pos_label,
|
||||||
|
label,
|
||||||
|
report_data["formats"]["format_right"],
|
||||||
|
)
|
||||||
|
for col_pos, column in report_data["columns"].items():
|
||||||
if column.get("field_initial_balance"):
|
if column.get("field_initial_balance"):
|
||||||
value = getattr(my_object, column["field_initial_balance"])
|
value = getattr(my_object, column["field_initial_balance"])
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "string":
|
if cell_type == "string":
|
||||||
self.sheet.write_string(self.row_pos, col_pos, value or "")
|
report_data["sheet"].write_string(
|
||||||
|
report_data["row_pos"], col_pos, value or ""
|
||||||
|
)
|
||||||
elif cell_type == "amount":
|
elif cell_type == "amount":
|
||||||
self.sheet.write_number(
|
report_data["sheet"].write_number(
|
||||||
self.row_pos, col_pos, float(value), self.format_amount
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
float(value),
|
||||||
|
report_data["formats"]["format_amount"],
|
||||||
)
|
)
|
||||||
elif cell_type == "amount_currency":
|
elif cell_type == "amount_currency":
|
||||||
if my_object.currency_id:
|
if my_object.currency_id:
|
||||||
format_amt = self._get_currency_amt_format(my_object)
|
format_amt = self._get_currency_amt_format(
|
||||||
self.sheet.write_number(
|
my_object, report_data
|
||||||
self.row_pos, col_pos, float(value), format_amt
|
)
|
||||||
|
report_data["sheet"].write_number(
|
||||||
|
report_data["row_pos"], col_pos, float(value), format_amt
|
||||||
)
|
)
|
||||||
elif column.get("field_currency_balance"):
|
elif column.get("field_currency_balance"):
|
||||||
value = getattr(my_object, column["field_currency_balance"])
|
value = getattr(my_object, column["field_currency_balance"])
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "many2one":
|
if cell_type == "many2one":
|
||||||
if my_object.currency_id:
|
if my_object.currency_id:
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value.name or "", self.format_right
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value.name or "",
|
||||||
|
report_data["formats"]["format_right"],
|
||||||
)
|
)
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
def write_initial_balance_from_dict(self, my_object, label):
|
def write_initial_balance_from_dict(self, my_object, label, report_data):
|
||||||
"""Write a specific initial balance line on current line
|
"""Write a specific initial balance line on current line
|
||||||
using defined columns field_initial_balance name.
|
using defined columns field_initial_balance name.
|
||||||
Columns are defined with `_get_report_columns` method.
|
Columns are defined with `_get_report_columns` method.
|
||||||
"""
|
"""
|
||||||
col_pos_label = self._get_col_pos_initial_balance_label()
|
col_pos_label = self._get_col_pos_initial_balance_label()
|
||||||
self.sheet.write(self.row_pos, col_pos_label, label, self.format_right)
|
report_data["sheet"].write(
|
||||||
for col_pos, column in self.columns.items():
|
report_data["row_pos"],
|
||||||
|
col_pos_label,
|
||||||
|
label,
|
||||||
|
report_data["formats"]["format_right"],
|
||||||
|
)
|
||||||
|
for col_pos, column in report_data["columns"].items():
|
||||||
if column.get("field_initial_balance"):
|
if column.get("field_initial_balance"):
|
||||||
value = my_object.get(column["field_initial_balance"], False)
|
value = my_object.get(column["field_initial_balance"], False)
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "string":
|
if cell_type == "string":
|
||||||
self.sheet.write_string(self.row_pos, col_pos, value or "")
|
report_data["sheet"].write_string(
|
||||||
|
report_data["row_pos"], col_pos, value or ""
|
||||||
|
)
|
||||||
elif cell_type == "amount":
|
elif cell_type == "amount":
|
||||||
self.sheet.write_number(
|
report_data["sheet"].write_number(
|
||||||
self.row_pos, col_pos, float(value), self.format_amount
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
float(value),
|
||||||
|
report_data["formats"]["format_amount"],
|
||||||
)
|
)
|
||||||
elif cell_type == "amount_currency":
|
elif cell_type == "amount_currency":
|
||||||
if my_object["currency_id"]:
|
if my_object["currency_id"]:
|
||||||
format_amt = self._get_currency_amt_format(my_object)
|
format_amt = self._get_currency_amt_format(
|
||||||
self.sheet.write_number(
|
my_object, report_data
|
||||||
self.row_pos, col_pos, float(value), format_amt
|
)
|
||||||
|
report_data["sheet"].write_number(
|
||||||
|
report_data["row_pos"], col_pos, float(value), format_amt
|
||||||
)
|
)
|
||||||
elif column.get("field_currency_balance"):
|
elif column.get("field_currency_balance"):
|
||||||
value = my_object.get(column["field_currency_balance"], False)
|
value = my_object.get(column["field_currency_balance"], False)
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "many2one":
|
if cell_type == "many2one":
|
||||||
if my_object["currency_id"]:
|
if my_object["currency_id"]:
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value.name or "", self.format_right
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value.name or "",
|
||||||
|
report_data["formats"]["format_right"],
|
||||||
)
|
)
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
def write_ending_balance(self, my_object, name, label):
|
def write_ending_balance(self, my_object, name, label, report_data):
|
||||||
"""Write a specific ending balance line on current line
|
"""Write a specific ending balance line on current line
|
||||||
using defined columns field_final_balance name.
|
using defined columns field_final_balance name.
|
||||||
Columns are defined with `_get_report_columns` method.
|
Columns are defined with `_get_report_columns` method.
|
||||||
"""
|
"""
|
||||||
for i in range(0, len(self.columns)):
|
for i in range(0, len(report_data["columns"])):
|
||||||
self.sheet.write(self.row_pos, i, "", self.format_header_right)
|
report_data["sheet"].write(
|
||||||
|
report_data["row_pos"],
|
||||||
|
i,
|
||||||
|
"",
|
||||||
|
report_data["formats"]["format_header_right"],
|
||||||
|
)
|
||||||
row_count_name = self._get_col_count_final_balance_name()
|
row_count_name = self._get_col_count_final_balance_name()
|
||||||
col_pos_label = self._get_col_pos_final_balance_label()
|
col_pos_label = self._get_col_pos_final_balance_label()
|
||||||
self.sheet.merge_range(
|
report_data["sheet"].merge_range(
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
0,
|
0,
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
row_count_name - 1,
|
row_count_name - 1,
|
||||||
name,
|
name,
|
||||||
self.format_header_left,
|
report_data["formats"]["format_header_left"],
|
||||||
)
|
)
|
||||||
self.sheet.write(self.row_pos, col_pos_label, label, self.format_header_right)
|
report_data["sheet"].write(
|
||||||
for col_pos, column in self.columns.items():
|
report_data["row_pos"],
|
||||||
|
col_pos_label,
|
||||||
|
label,
|
||||||
|
report_data["formats"]["format_header_right"],
|
||||||
|
)
|
||||||
|
for col_pos, column in report_data["columns"].items():
|
||||||
if column.get("field_final_balance"):
|
if column.get("field_final_balance"):
|
||||||
value = getattr(my_object, column["field_final_balance"])
|
value = getattr(my_object, column["field_final_balance"])
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "string":
|
if cell_type == "string":
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value or "", self.format_header_right
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value or "",
|
||||||
|
report_data["formats"]["format_header_right"],
|
||||||
)
|
)
|
||||||
elif cell_type == "amount":
|
elif cell_type == "amount":
|
||||||
self.sheet.write_number(
|
report_data["sheet"].write_number(
|
||||||
self.row_pos, col_pos, float(value), self.format_header_amount
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
float(value),
|
||||||
|
report_data["formats"]["format_header_amount"],
|
||||||
)
|
)
|
||||||
elif cell_type == "amount_currency":
|
elif cell_type == "amount_currency":
|
||||||
if my_object.currency_id:
|
if my_object.currency_id:
|
||||||
format_amt = self._get_currency_amt_header_format(my_object)
|
format_amt = self._get_currency_amt_header_format(
|
||||||
self.sheet.write_number(
|
my_object, report_data
|
||||||
self.row_pos, col_pos, float(value), format_amt
|
)
|
||||||
|
report_data["sheet"].write_number(
|
||||||
|
report_data["row_pos"], col_pos, float(value), format_amt
|
||||||
)
|
)
|
||||||
elif column.get("field_currency_balance"):
|
elif column.get("field_currency_balance"):
|
||||||
value = getattr(my_object, column["field_currency_balance"])
|
value = getattr(my_object, column["field_currency_balance"])
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "many2one":
|
if cell_type == "many2one":
|
||||||
if my_object.currency_id:
|
if my_object.currency_id:
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
col_pos,
|
col_pos,
|
||||||
value.name or "",
|
value.name or "",
|
||||||
self.format_header_right,
|
report_data["formats"]["format_header_right"],
|
||||||
)
|
)
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
def write_ending_balance_from_dict(self, my_object, name, label):
|
def write_ending_balance_from_dict(self, my_object, name, label, report_data):
|
||||||
"""Write a specific ending balance line on current line
|
"""Write a specific ending balance line on current line
|
||||||
using defined columns field_final_balance name.
|
using defined columns field_final_balance name.
|
||||||
Columns are defined with `_get_report_columns` method.
|
Columns are defined with `_get_report_columns` method.
|
||||||
"""
|
"""
|
||||||
for i in range(0, len(self.columns)):
|
for i in range(0, len(report_data["columns"])):
|
||||||
self.sheet.write(self.row_pos, i, "", self.format_header_right)
|
report_data["sheet"].write(
|
||||||
|
report_data["row_pos"],
|
||||||
|
i,
|
||||||
|
"",
|
||||||
|
report_data["formats"]["format_header_right"],
|
||||||
|
)
|
||||||
row_count_name = self._get_col_count_final_balance_name()
|
row_count_name = self._get_col_count_final_balance_name()
|
||||||
col_pos_label = self._get_col_pos_final_balance_label()
|
col_pos_label = self._get_col_pos_final_balance_label()
|
||||||
self.sheet.merge_range(
|
report_data["sheet"].merge_range(
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
0,
|
0,
|
||||||
self.row_pos,
|
report_data["row_pos"],
|
||||||
row_count_name - 1,
|
row_count_name - 1,
|
||||||
name,
|
name,
|
||||||
self.format_header_left,
|
report_data["formats"]["format_header_left"],
|
||||||
)
|
)
|
||||||
self.sheet.write(self.row_pos, col_pos_label, label, self.format_header_right)
|
report_data["sheet"].write(
|
||||||
for col_pos, column in self.columns.items():
|
report_data["row_pos"],
|
||||||
|
col_pos_label,
|
||||||
|
label,
|
||||||
|
report_data["formats"]["format_header_right"],
|
||||||
|
)
|
||||||
|
for col_pos, column in report_data["columns"].items():
|
||||||
if column.get("field_final_balance"):
|
if column.get("field_final_balance"):
|
||||||
value = my_object.get(column["field_final_balance"], False)
|
value = my_object.get(column["field_final_balance"], False)
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "string":
|
if cell_type == "string":
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value or "", self.format_header_right
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value or "",
|
||||||
|
report_data["formats"]["format_header_right"],
|
||||||
)
|
)
|
||||||
elif cell_type == "amount":
|
elif cell_type == "amount":
|
||||||
self.sheet.write_number(
|
report_data["sheet"].write_number(
|
||||||
self.row_pos, col_pos, float(value), self.format_header_amount
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
float(value),
|
||||||
|
report_data["formats"]["format_header_amount"],
|
||||||
)
|
)
|
||||||
elif cell_type == "amount_currency":
|
elif cell_type == "amount_currency":
|
||||||
if my_object["currency_id"] and value:
|
if my_object["currency_id"] and value:
|
||||||
format_amt = self._get_currency_amt_format_dict(my_object)
|
format_amt = self._get_currency_amt_format_dict(
|
||||||
self.sheet.write_number(
|
my_object, report_data
|
||||||
self.row_pos, col_pos, float(value), format_amt
|
)
|
||||||
|
report_data["sheet"].write_number(
|
||||||
|
report_data["row_pos"], col_pos, float(value), format_amt
|
||||||
)
|
)
|
||||||
elif column.get("field_currency_balance"):
|
elif column.get("field_currency_balance"):
|
||||||
value = my_object.get(column["field_currency_balance"], False)
|
value = my_object.get(column["field_currency_balance"], False)
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "many2one":
|
if cell_type == "many2one":
|
||||||
if my_object["currency_id"]:
|
if my_object["currency_id"]:
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value or "", self.format_header_right
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value or "",
|
||||||
|
report_data["formats"]["format_header_right"],
|
||||||
)
|
)
|
||||||
elif cell_type == "currency_name":
|
elif cell_type == "currency_name":
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value or "", self.format_header_right
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value or "",
|
||||||
|
report_data["formats"]["format_header_right"],
|
||||||
)
|
)
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
def _get_currency_amt_format(self, line_object):
|
def _get_currency_amt_format(self, line_object, report_data):
|
||||||
""" Return amount format specific for each currency. """
|
""" Return amount format specific for each currency. """
|
||||||
if "account_group_id" in line_object and line_object["account_group_id"]:
|
if "account_group_id" in line_object and line_object["account_group_id"]:
|
||||||
format_amt = self.format_amount_bold
|
format_amt = report_data["formats"]["format_amount_bold"]
|
||||||
field_prefix = "format_amount_bold"
|
field_prefix = "format_amount_bold"
|
||||||
else:
|
else:
|
||||||
format_amt = self.format_amount
|
format_amt = report_data["formats"]["format_amount"]
|
||||||
field_prefix = "format_amount"
|
field_prefix = "format_amount"
|
||||||
if "currency_id" in line_object and line_object.get("currency_id", False):
|
if "currency_id" in line_object and line_object.get("currency_id", False):
|
||||||
field_name = "{}_{}".format(field_prefix, line_object["currency_id"].name)
|
field_name = "{}_{}".format(field_prefix, line_object["currency_id"].name)
|
||||||
if hasattr(self, field_name):
|
if hasattr(self, field_name):
|
||||||
format_amt = getattr(self, field_name)
|
format_amt = getattr(self, field_name)
|
||||||
else:
|
else:
|
||||||
format_amt = self.workbook.add_format()
|
format_amt = report_data["workbook"].add_format()
|
||||||
self.field_name = format_amt
|
report_data["field_name"] = format_amt
|
||||||
format_amount = "#,##0." + (
|
format_amount = "#,##0." + (
|
||||||
"0" * line_object["currency_id"].decimal_places
|
"0" * line_object["currency_id"].decimal_places
|
||||||
)
|
)
|
||||||
format_amt.set_num_format(format_amount)
|
format_amt.set_num_format(format_amount)
|
||||||
return format_amt
|
return format_amt
|
||||||
|
|
||||||
def _get_currency_amt_format_dict(self, line_dict):
|
def _get_currency_amt_format_dict(self, line_dict, report_data):
|
||||||
""" Return amount format specific for each currency. """
|
""" Return amount format specific for each currency. """
|
||||||
if line_dict.get("account_group_id", False) and line_dict["account_group_id"]:
|
if line_dict.get("account_group_id", False) and line_dict["account_group_id"]:
|
||||||
format_amt = self.format_amount_bold
|
format_amt = report_data["formats"]["format_amount_bold"]
|
||||||
field_prefix = "format_amount_bold"
|
field_prefix = "format_amount_bold"
|
||||||
else:
|
else:
|
||||||
format_amt = self.format_amount
|
format_amt = report_data["formats"]["format_amount"]
|
||||||
field_prefix = "format_amount"
|
field_prefix = "format_amount"
|
||||||
if line_dict.get("currency_id", False) and line_dict["currency_id"]:
|
if line_dict.get("currency_id", False) and line_dict["currency_id"]:
|
||||||
if isinstance(line_dict["currency_id"], int):
|
if isinstance(line_dict["currency_id"], int):
|
||||||
|
@ -483,49 +556,49 @@ class AbstractReportXslx(models.AbstractModel):
|
||||||
if hasattr(self, field_name):
|
if hasattr(self, field_name):
|
||||||
format_amt = getattr(self, field_name)
|
format_amt = getattr(self, field_name)
|
||||||
else:
|
else:
|
||||||
format_amt = self.workbook.add_format()
|
format_amt = report_data["workbook"].add_format()
|
||||||
self.field_name = format_amt
|
report_data["field_name"] = format_amt
|
||||||
format_amount = "#,##0." + ("0" * currency.decimal_places)
|
format_amount = "#,##0." + ("0" * currency.decimal_places)
|
||||||
format_amt.set_num_format(format_amount)
|
format_amt.set_num_format(format_amount)
|
||||||
return format_amt
|
return format_amt
|
||||||
|
|
||||||
def _get_currency_amt_header_format(self, line_object):
|
def _get_currency_amt_header_format(self, line_object, report_data):
|
||||||
""" Return amount header format for each currency. """
|
""" Return amount header format for each currency. """
|
||||||
format_amt = self.format_header_amount
|
format_amt = report_data["formats"]["format_header_amount"]
|
||||||
if line_object.currency_id:
|
if line_object.currency_id:
|
||||||
field_name = "format_header_amount_%s" % line_object.currency_id.name
|
field_name = "format_header_amount_%s" % line_object.currency_id.name
|
||||||
if hasattr(self, field_name):
|
if hasattr(self, field_name):
|
||||||
format_amt = getattr(self, field_name)
|
format_amt = getattr(self, field_name)
|
||||||
else:
|
else:
|
||||||
format_amt = self.workbook.add_format(
|
format_amt = report_data["workbook"].add_format(
|
||||||
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
||||||
)
|
)
|
||||||
self.field_name = format_amt
|
report_data["field_name"] = format_amt
|
||||||
format_amount = "#,##0." + (
|
format_amount = "#,##0." + (
|
||||||
"0" * line_object.currency_id.decimal_places
|
"0" * line_object.currency_id.decimal_places
|
||||||
)
|
)
|
||||||
format_amt.set_num_format(format_amount)
|
format_amt.set_num_format(format_amount)
|
||||||
return format_amt
|
return format_amt
|
||||||
|
|
||||||
def _get_currency_amt_header_format_dict(self, line_object):
|
def _get_currency_amt_header_format_dict(self, line_object, report_data):
|
||||||
""" Return amount header format for each currency. """
|
""" Return amount header format for each currency. """
|
||||||
format_amt = self.format_header_amount
|
format_amt = report_data["formats"]["format_header_amount"]
|
||||||
if line_object["currency_id"]:
|
if line_object["currency_id"]:
|
||||||
field_name = "format_header_amount_%s" % line_object["currency_name"]
|
field_name = "format_header_amount_%s" % line_object["currency_name"]
|
||||||
if hasattr(self, field_name):
|
if hasattr(self, field_name):
|
||||||
format_amt = getattr(self, field_name)
|
format_amt = getattr(self, field_name)
|
||||||
else:
|
else:
|
||||||
format_amt = self.workbook.add_format(
|
format_amt = report_data["workbook"].add_format(
|
||||||
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
||||||
)
|
)
|
||||||
self.field_name = format_amt
|
report_data["field_name"] = format_amt
|
||||||
format_amount = "#,##0." + (
|
format_amount = "#,##0." + (
|
||||||
"0" * line_object["currency_id"].decimal_places
|
"0" * line_object["currency_id"].decimal_places
|
||||||
)
|
)
|
||||||
format_amt.set_num_format(format_amount)
|
format_amt.set_num_format(format_amount)
|
||||||
return format_amt
|
return format_amt
|
||||||
|
|
||||||
def _generate_report_content(self, workbook, report, data):
|
def _generate_report_content(self, workbook, report, data, report_data):
|
||||||
"""
|
"""
|
||||||
Allow to fetch report content to be displayed.
|
Allow to fetch report content to be displayed.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Author: Julien Coux
|
# Author: Julien Coux
|
||||||
# Copyright 2016 Camptocamp SA
|
# Copyright 2016 Camptocamp SA
|
||||||
|
# Copyright 2021 Tecnativa - João Marques
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo import _, models
|
from odoo import _, models
|
||||||
|
@ -177,7 +178,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
|
||||||
def _get_col_pos_final_balance_label(self):
|
def _get_col_pos_final_balance_label(self):
|
||||||
return 5
|
return 5
|
||||||
|
|
||||||
def _generate_report_content(self, workbook, report, data):
|
def _generate_report_content(self, workbook, report, data, report_data):
|
||||||
res_data = self.env[
|
res_data = self.env[
|
||||||
"report.account_financial_report.aged_partner_balance"
|
"report.account_financial_report.aged_partner_balance"
|
||||||
]._get_report_values(report, data)
|
]._get_report_values(report, data)
|
||||||
|
@ -187,14 +188,16 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
|
||||||
# For each account
|
# For each account
|
||||||
for account in aged_partner_balance:
|
for account in aged_partner_balance:
|
||||||
# Write account title
|
# Write account title
|
||||||
self.write_array_title(account["code"] + " - " + account["name"])
|
self.write_array_title(
|
||||||
|
account["code"] + " - " + account["name"], report_data
|
||||||
|
)
|
||||||
|
|
||||||
# Display array header for partners lines
|
# Display array header for partners lines
|
||||||
self.write_array_header()
|
self.write_array_header(report_data)
|
||||||
|
|
||||||
# Display partner lines
|
# Display partner lines
|
||||||
for partner in account["partners"]:
|
for partner in account["partners"]:
|
||||||
self.write_line_from_dict(partner)
|
self.write_line_from_dict(partner, report_data)
|
||||||
|
|
||||||
# Display account lines
|
# Display account lines
|
||||||
self.write_account_footer_from_dict(
|
self.write_account_footer_from_dict(
|
||||||
|
@ -202,45 +205,49 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
|
||||||
account,
|
account,
|
||||||
("Total"),
|
("Total"),
|
||||||
"field_footer_total",
|
"field_footer_total",
|
||||||
self.format_header_right,
|
report_data["formats"]["format_header_right"],
|
||||||
self.format_header_amount,
|
report_data["formats"]["format_header_amount"],
|
||||||
False,
|
False,
|
||||||
|
report_data,
|
||||||
)
|
)
|
||||||
self.write_account_footer_from_dict(
|
self.write_account_footer_from_dict(
|
||||||
report,
|
report,
|
||||||
account,
|
account,
|
||||||
("Percents"),
|
("Percents"),
|
||||||
"field_footer_percent",
|
"field_footer_percent",
|
||||||
self.format_right_bold_italic,
|
report_data["formats"]["format_right_bold_italic"],
|
||||||
self.format_percent_bold_italic,
|
report_data["formats"]["format_percent_bold_italic"],
|
||||||
True,
|
True,
|
||||||
|
report_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2 lines break
|
# 2 lines break
|
||||||
self.row_pos += 2
|
report_data["row_pos"] += 2
|
||||||
else:
|
else:
|
||||||
# For each account
|
# For each account
|
||||||
for account in aged_partner_balance:
|
for account in aged_partner_balance:
|
||||||
# Write account title
|
# Write account title
|
||||||
self.write_array_title(account["code"] + " - " + account["name"])
|
self.write_array_title(
|
||||||
|
account["code"] + " - " + account["name"], report_data
|
||||||
|
)
|
||||||
|
|
||||||
# For each partner
|
# For each partner
|
||||||
for partner in account["partners"]:
|
for partner in account["partners"]:
|
||||||
# Write partner title
|
# Write partner title
|
||||||
self.write_array_title(partner["name"])
|
self.write_array_title(partner["name"], report_data)
|
||||||
|
|
||||||
# Display array header for move lines
|
# Display array header for move lines
|
||||||
self.write_array_header()
|
self.write_array_header(report_data)
|
||||||
|
|
||||||
# Display account move lines
|
# Display account move lines
|
||||||
for line in partner["move_lines"]:
|
for line in partner["move_lines"]:
|
||||||
self.write_line_from_dict(line)
|
self.write_line_from_dict(line, report_data)
|
||||||
|
|
||||||
# Display ending balance line for partner
|
# Display ending balance line for partner
|
||||||
self.write_ending_balance_from_dict(partner)
|
self.write_ending_balance_from_dict(partner, report_data)
|
||||||
|
|
||||||
# Line break
|
# Line break
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
# Display account lines
|
# Display account lines
|
||||||
self.write_account_footer_from_dict(
|
self.write_account_footer_from_dict(
|
||||||
|
@ -248,9 +255,10 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
|
||||||
account,
|
account,
|
||||||
("Total"),
|
("Total"),
|
||||||
"field_footer_total",
|
"field_footer_total",
|
||||||
self.format_header_right,
|
report_data["formats"]["format_header_right"],
|
||||||
self.format_header_amount,
|
report_data["formats"]["format_header_amount"],
|
||||||
False,
|
False,
|
||||||
|
report_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.write_account_footer_from_dict(
|
self.write_account_footer_from_dict(
|
||||||
|
@ -258,24 +266,23 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
|
||||||
account,
|
account,
|
||||||
("Percents"),
|
("Percents"),
|
||||||
"field_footer_percent",
|
"field_footer_percent",
|
||||||
self.format_right_bold_italic,
|
report_data["formats"]["format_right_bold_italic"],
|
||||||
self.format_percent_bold_italic,
|
report_data["formats"]["format_percent_bold_italic"],
|
||||||
True,
|
True,
|
||||||
|
report_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2 lines break
|
# 2 lines break
|
||||||
self.row_pos += 2
|
report_data["row_pos"] += 2
|
||||||
|
|
||||||
def write_ending_balance_from_dict(self, my_object):
|
def write_ending_balance_from_dict(self, my_object, report_data):
|
||||||
"""
|
"""
|
||||||
Specific function to write ending partner balance
|
Specific function to write ending partner balance
|
||||||
for Aged Partner Balance
|
for Aged Partner Balance
|
||||||
"""
|
"""
|
||||||
name = None
|
name = None
|
||||||
label = _("Partner cumul aged balance")
|
label = _("Partner cumul aged balance")
|
||||||
super(AgedPartnerBalanceXslx, self).write_ending_balance_from_dict(
|
super().write_ending_balance_from_dict(my_object, name, label, report_data)
|
||||||
my_object, name, label
|
|
||||||
)
|
|
||||||
|
|
||||||
def write_account_footer_from_dict(
|
def write_account_footer_from_dict(
|
||||||
self,
|
self,
|
||||||
|
@ -286,12 +293,13 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
|
||||||
string_format,
|
string_format,
|
||||||
amount_format,
|
amount_format,
|
||||||
amount_is_percent,
|
amount_is_percent,
|
||||||
|
report_data,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Specific function to write account footer for Aged Partner Balance
|
Specific function to write account footer for Aged Partner Balance
|
||||||
"""
|
"""
|
||||||
col_pos_footer_label = self._get_col_pos_footer_label(report)
|
col_pos_footer_label = self._get_col_pos_footer_label(report)
|
||||||
for col_pos, column in self.columns.items():
|
for col_pos, column in report_data["columns"].items():
|
||||||
if col_pos == col_pos_footer_label or column.get(field_name):
|
if col_pos == col_pos_footer_label or column.get(field_name):
|
||||||
if col_pos == col_pos_footer_label:
|
if col_pos == col_pos_footer_label:
|
||||||
value = label
|
value = label
|
||||||
|
@ -299,17 +307,19 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
|
||||||
value = account.get(column[field_name], False)
|
value = account.get(column[field_name], False)
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "string" or col_pos == col_pos_footer_label:
|
if cell_type == "string" or col_pos == col_pos_footer_label:
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value or "", string_format
|
report_data["row_pos"], col_pos, value or "", string_format
|
||||||
)
|
)
|
||||||
elif cell_type == "amount":
|
elif cell_type == "amount":
|
||||||
number = float(value)
|
number = float(value)
|
||||||
if amount_is_percent:
|
if amount_is_percent:
|
||||||
number /= 100
|
number /= 100
|
||||||
self.sheet.write_number(
|
report_data["sheet"].write_number(
|
||||||
self.row_pos, col_pos, number, amount_format
|
report_data["row_pos"], col_pos, number, amount_format
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.sheet.write_string(self.row_pos, col_pos, "", string_format)
|
report_data["sheet"].write_string(
|
||||||
|
report_data["row_pos"], col_pos, "", string_format
|
||||||
|
)
|
||||||
|
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Author: Damien Crier
|
# Author: Damien Crier
|
||||||
# Author: Julien Coux
|
# Author: Julien Coux
|
||||||
# Copyright 2016 Camptocamp SA
|
# Copyright 2016 Camptocamp SA
|
||||||
|
# Copyright 2021 Tecnativa - João Marques
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo import _, models
|
from odoo import _, models
|
||||||
|
@ -135,7 +136,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||||
return 5
|
return 5
|
||||||
|
|
||||||
# flake8: noqa: C901
|
# flake8: noqa: C901
|
||||||
def _generate_report_content(self, workbook, report, data):
|
def _generate_report_content(self, workbook, report, data, report_data):
|
||||||
res_data = self.env[
|
res_data = self.env[
|
||||||
"report.account_financial_report.general_ledger"
|
"report.account_financial_report.general_ledger"
|
||||||
]._get_report_values(report, data)
|
]._get_report_values(report, data)
|
||||||
|
@ -151,12 +152,13 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||||
for account in general_ledger:
|
for account in general_ledger:
|
||||||
# Write account title
|
# Write account title
|
||||||
self.write_array_title(
|
self.write_array_title(
|
||||||
account["code"] + " - " + accounts_data[account["id"]]["name"]
|
account["code"] + " - " + accounts_data[account["id"]]["name"],
|
||||||
|
report_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not account["partners"]:
|
if not account["partners"]:
|
||||||
# Display array header for move lines
|
# Display array header for move lines
|
||||||
self.write_array_header()
|
self.write_array_header(report_data)
|
||||||
|
|
||||||
# Display initial balance line for account
|
# Display initial balance line for account
|
||||||
account.update(
|
account.update(
|
||||||
|
@ -170,7 +172,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||||
account.update(
|
account.update(
|
||||||
{"initial_bal_curr": account["init_bal"]["bal_curr"]}
|
{"initial_bal_curr": account["init_bal"]["bal_curr"]}
|
||||||
)
|
)
|
||||||
self.write_initial_balance_from_dict(account)
|
self.write_initial_balance_from_dict(account, report_data)
|
||||||
|
|
||||||
# Display account move lines
|
# Display account move lines
|
||||||
for line in account["move_lines"]:
|
for line in account["move_lines"]:
|
||||||
|
@ -200,7 +202,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||||
"tags": tags,
|
"tags": tags,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.write_line_from_dict(line)
|
self.write_line_from_dict(line, report_data)
|
||||||
# Display ending balance line for account
|
# Display ending balance line for account
|
||||||
account.update(
|
account.update(
|
||||||
{
|
{
|
||||||
|
@ -215,16 +217,18 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||||
"final_bal_curr": account["fin_bal"]["bal_curr"],
|
"final_bal_curr": account["fin_bal"]["bal_curr"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.write_ending_balance_from_dict(account)
|
self.write_ending_balance_from_dict(account, report_data)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# For each partner
|
# For each partner
|
||||||
for partner in account["list_partner"]:
|
for partner in account["list_partner"]:
|
||||||
# Write partner title
|
# Write partner title
|
||||||
self.write_array_title(partners_data[partner["id"]]["name"])
|
self.write_array_title(
|
||||||
|
partners_data[partner["id"]]["name"], report_data
|
||||||
|
)
|
||||||
|
|
||||||
# Display array header for move lines
|
# Display array header for move lines
|
||||||
self.write_array_header()
|
self.write_array_header(report_data)
|
||||||
|
|
||||||
# Display initial balance line for partner
|
# Display initial balance line for partner
|
||||||
partner.update(
|
partner.update(
|
||||||
|
@ -243,7 +247,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||||
"initial_bal_curr": partner["init_bal"]["bal_curr"],
|
"initial_bal_curr": partner["init_bal"]["bal_curr"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.write_initial_balance_from_dict(partner)
|
self.write_initial_balance_from_dict(partner, report_data)
|
||||||
|
|
||||||
# Display account move lines
|
# Display account move lines
|
||||||
for line in partner["move_lines"]:
|
for line in partner["move_lines"]:
|
||||||
|
@ -275,7 +279,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||||
"tags": tags,
|
"tags": tags,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.write_line_from_dict(line)
|
self.write_line_from_dict(line, report_data)
|
||||||
|
|
||||||
# Display ending balance line for partner
|
# Display ending balance line for partner
|
||||||
partner.update(
|
partner.update(
|
||||||
|
@ -293,10 +297,10 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||||
"currency_id": partner["currency_id"].id,
|
"currency_id": partner["currency_id"].id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.write_ending_balance_from_dict(partner)
|
self.write_ending_balance_from_dict(partner, report_data)
|
||||||
|
|
||||||
# Line break
|
# Line break
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
if not filter_partner_ids:
|
if not filter_partner_ids:
|
||||||
account.update(
|
account.update(
|
||||||
|
@ -314,20 +318,22 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||||
"currency_id": account["currency_id"].id,
|
"currency_id": account["currency_id"].id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.write_ending_balance_from_dict(account)
|
self.write_ending_balance_from_dict(account, report_data)
|
||||||
|
|
||||||
# 2 lines break
|
# 2 lines break
|
||||||
self.row_pos += 2
|
report_data["row_pos"] += 2
|
||||||
|
|
||||||
def write_initial_balance_from_dict(self, my_object):
|
def write_initial_balance_from_dict(self, my_object, report_data):
|
||||||
"""Specific function to write initial balance for General Ledger"""
|
"""Specific function to write initial balance for General Ledger"""
|
||||||
if "partner" in my_object["type"]:
|
if "partner" in my_object["type"]:
|
||||||
label = _("Partner Initial balance")
|
label = _("Partner Initial balance")
|
||||||
elif "account" in my_object["type"]:
|
elif "account" in my_object["type"]:
|
||||||
label = _("Initial balance")
|
label = _("Initial balance")
|
||||||
super(GeneralLedgerXslx, self).write_initial_balance_from_dict(my_object, label)
|
super(GeneralLedgerXslx, self).write_initial_balance_from_dict(
|
||||||
|
my_object, label, report_data
|
||||||
|
)
|
||||||
|
|
||||||
def write_ending_balance_from_dict(self, my_object):
|
def write_ending_balance_from_dict(self, my_object, report_data):
|
||||||
"""Specific function to write ending balance for General Ledger"""
|
"""Specific function to write ending balance for General Ledger"""
|
||||||
if "partner" in my_object["type"]:
|
if "partner" in my_object["type"]:
|
||||||
name = my_object["name"]
|
name = my_object["name"]
|
||||||
|
@ -336,5 +342,5 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||||
name = my_object["code"] + " - " + my_object["name"]
|
name = my_object["code"] + " - " + my_object["name"]
|
||||||
label = _("Ending balance")
|
label = _("Ending balance")
|
||||||
super(GeneralLedgerXslx, self).write_ending_balance_from_dict(
|
super(GeneralLedgerXslx, self).write_ending_balance_from_dict(
|
||||||
my_object, name, label
|
my_object, name, label, report_data
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Author: Damien Crier
|
# Author: Damien Crier
|
||||||
# Author: Julien Coux
|
# Author: Julien Coux
|
||||||
# Copyright 2016 Camptocamp SA
|
# Copyright 2016 Camptocamp SA
|
||||||
|
# Copyright 2021 Tecnativa - João Marques
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo import _, models
|
from odoo import _, models
|
||||||
|
@ -149,24 +150,28 @@ class JournalLedgerXslx(models.AbstractModel):
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
def _generate_report_content(self, workbook, report, data):
|
def _generate_report_content(self, workbook, report, data, report_data):
|
||||||
res_data = self.env[
|
res_data = self.env[
|
||||||
"report.account_financial_report.journal_ledger"
|
"report.account_financial_report.journal_ledger"
|
||||||
]._get_report_values(report, data)
|
]._get_report_values(report, data)
|
||||||
group_option = report.group_option
|
group_option = report.group_option
|
||||||
if group_option == "journal":
|
if group_option == "journal":
|
||||||
for ledger in res_data["Journal_Ledgers"]:
|
for ledger in res_data["Journal_Ledgers"]:
|
||||||
self._generate_journal_content(workbook, report, res_data, ledger)
|
self._generate_journal_content(
|
||||||
|
workbook, report, res_data, ledger, report_data
|
||||||
|
)
|
||||||
elif group_option == "none":
|
elif group_option == "none":
|
||||||
self._generate_no_group_content(workbook, report, res_data)
|
self._generate_no_group_content(workbook, report, res_data, report_data)
|
||||||
|
|
||||||
def _generate_no_group_content(self, workbook, report, res_data):
|
def _generate_no_group_content(self, workbook, report, res_data, report_data):
|
||||||
self._generate_moves_content(
|
self._generate_moves_content(
|
||||||
workbook, "Report", report, res_data, res_data["Moves"]
|
workbook, "Report", report, res_data, res_data["Moves"], report_data
|
||||||
)
|
)
|
||||||
self._generate_no_group_taxes_summary(workbook, report, res_data)
|
self._generate_no_group_taxes_summary(workbook, report, res_data, report_data)
|
||||||
|
|
||||||
def _generate_journal_content(self, workbook, report, res_data, ledger):
|
def _generate_journal_content(
|
||||||
|
self, workbook, report, res_data, ledger, report_data
|
||||||
|
):
|
||||||
journal = self.env["account.journal"].browse(ledger["id"])
|
journal = self.env["account.journal"].browse(ledger["id"])
|
||||||
currency_name = (
|
currency_name = (
|
||||||
journal.currency_id
|
journal.currency_id
|
||||||
|
@ -175,14 +180,16 @@ class JournalLedgerXslx(models.AbstractModel):
|
||||||
)
|
)
|
||||||
sheet_name = "{} ({}) - {}".format(journal.code, currency_name, journal.name)
|
sheet_name = "{} ({}) - {}".format(journal.code, currency_name, journal.name)
|
||||||
self._generate_moves_content(
|
self._generate_moves_content(
|
||||||
workbook, sheet_name, report, res_data, ledger["report_moves"]
|
workbook, sheet_name, report, res_data, ledger["report_moves"], report_data
|
||||||
)
|
)
|
||||||
self._generate_journal_taxes_summary(workbook, ledger)
|
self._generate_journal_taxes_summary(workbook, ledger, report_data)
|
||||||
|
|
||||||
def _generate_no_group_taxes_summary(self, workbook, report, res_data):
|
def _generate_no_group_taxes_summary(self, workbook, report, res_data, report_data):
|
||||||
self._generate_taxes_summary(workbook, "Tax Report", res_data["tax_line_data"])
|
self._generate_taxes_summary(
|
||||||
|
workbook, "Tax Report", res_data["tax_line_data"], report_data
|
||||||
|
)
|
||||||
|
|
||||||
def _generate_journal_taxes_summary(self, workbook, ledger):
|
def _generate_journal_taxes_summary(self, workbook, ledger, report_data):
|
||||||
journal = self.env["account.journal"].browse(ledger["id"])
|
journal = self.env["account.journal"].browse(ledger["id"])
|
||||||
currency_name = (
|
currency_name = (
|
||||||
journal.currency_id
|
journal.currency_id
|
||||||
|
@ -192,19 +199,23 @@ class JournalLedgerXslx(models.AbstractModel):
|
||||||
sheet_name = "Tax - {} ({}) - {}".format(
|
sheet_name = "Tax - {} ({}) - {}".format(
|
||||||
journal.code, currency_name, journal.name
|
journal.code, currency_name, journal.name
|
||||||
)
|
)
|
||||||
self._generate_taxes_summary(workbook, sheet_name, ledger["tax_lines"])
|
self._generate_taxes_summary(
|
||||||
|
workbook, sheet_name, ledger["tax_lines"], report_data
|
||||||
|
)
|
||||||
|
|
||||||
def _generate_moves_content(self, workbook, sheet_name, report, res_data, moves):
|
def _generate_moves_content(
|
||||||
self.workbook = workbook
|
self, workbook, sheet_name, report, res_data, moves, report_data
|
||||||
self.sheet = workbook.add_worksheet(sheet_name)
|
):
|
||||||
self._set_column_width()
|
report_data["workbook"] = workbook
|
||||||
|
report_data["sheet"] = workbook.add_worksheet(sheet_name)
|
||||||
|
self._set_column_width(report_data)
|
||||||
|
|
||||||
self.row_pos = 1
|
report_data["row_pos"] = 1
|
||||||
|
|
||||||
self.write_array_title(sheet_name)
|
self.write_array_title(sheet_name, report_data)
|
||||||
self.row_pos += 2
|
report_data["row_pos"] += 2
|
||||||
|
|
||||||
self.write_array_header()
|
self.write_array_header(report_data)
|
||||||
account_ids_data = res_data["account_ids_data"]
|
account_ids_data = res_data["account_ids_data"]
|
||||||
partner_ids_data = res_data["partner_ids_data"]
|
partner_ids_data = res_data["partner_ids_data"]
|
||||||
currency_ids_data = res_data["currency_ids_data"]
|
currency_ids_data = res_data["currency_ids_data"]
|
||||||
|
@ -232,16 +243,18 @@ class JournalLedgerXslx(models.AbstractModel):
|
||||||
line["move_line_id"], False
|
line["move_line_id"], False
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.write_line_from_dict(line)
|
self.write_line_from_dict(line, report_data)
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
|
|
||||||
def _generate_taxes_summary(self, workbook, sheet_name, tax_lines_dict):
|
def _generate_taxes_summary(
|
||||||
self.workbook = workbook
|
self, workbook, sheet_name, tax_lines_dict, report_data
|
||||||
self.sheet = workbook.add_worksheet(sheet_name)
|
):
|
||||||
|
report_data["workbook"] = workbook
|
||||||
|
report_data["sheet"] = workbook.add_worksheet(sheet_name)
|
||||||
|
|
||||||
self.row_pos = 1
|
report_data["row_pos"] = 1
|
||||||
self.write_array_title(sheet_name)
|
self.write_array_title(sheet_name, report_data)
|
||||||
self.row_pos += 2
|
report_data["row_pos"] += 2
|
||||||
|
|
||||||
def _get_partner_name(self, partner_id, partner_data):
|
def _get_partner_name(self, partner_id, partner_data):
|
||||||
if partner_id in partner_data.keys():
|
if partner_id in partner_data.keys():
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Author: Julien Coux
|
# Author: Julien Coux
|
||||||
# Copyright 2016 Camptocamp SA
|
# Copyright 2016 Camptocamp SA
|
||||||
|
# Copyright 2021 Tecnativa - João Marques
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo import _, models
|
from odoo import _, models
|
||||||
|
@ -100,7 +101,7 @@ class OpenItemsXslx(models.AbstractModel):
|
||||||
def _get_col_pos_final_balance_label(self):
|
def _get_col_pos_final_balance_label(self):
|
||||||
return 5
|
return 5
|
||||||
|
|
||||||
def _generate_report_content(self, workbook, report, data):
|
def _generate_report_content(self, workbook, report, data, report_data):
|
||||||
res_data = self.env[
|
res_data = self.env[
|
||||||
"report.account_financial_report.open_items"
|
"report.account_financial_report.open_items"
|
||||||
]._get_report_values(report, data)
|
]._get_report_values(report, data)
|
||||||
|
@ -116,7 +117,8 @@ class OpenItemsXslx(models.AbstractModel):
|
||||||
self.write_array_title(
|
self.write_array_title(
|
||||||
accounts_data[account_id]["code"]
|
accounts_data[account_id]["code"]
|
||||||
+ " - "
|
+ " - "
|
||||||
+ accounts_data[account_id]["name"]
|
+ accounts_data[account_id]["name"],
|
||||||
|
report_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
# For each partner
|
# For each partner
|
||||||
|
@ -125,10 +127,12 @@ class OpenItemsXslx(models.AbstractModel):
|
||||||
for partner_id in Open_items[account_id]:
|
for partner_id in Open_items[account_id]:
|
||||||
type_object = "partner"
|
type_object = "partner"
|
||||||
# Write partner title
|
# Write partner title
|
||||||
self.write_array_title(partners_data[partner_id]["name"])
|
self.write_array_title(
|
||||||
|
partners_data[partner_id]["name"], report_data
|
||||||
|
)
|
||||||
|
|
||||||
# Display array header for move lines
|
# Display array header for move lines
|
||||||
self.write_array_header()
|
self.write_array_header(report_data)
|
||||||
|
|
||||||
# Display account move lines
|
# Display account move lines
|
||||||
for line in Open_items[account_id][partner_id]:
|
for line in Open_items[account_id][partner_id]:
|
||||||
|
@ -140,7 +144,7 @@ class OpenItemsXslx(models.AbstractModel):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.write_line_from_dict(line)
|
self.write_line_from_dict(line, report_data)
|
||||||
|
|
||||||
# Display ending balance line for partner
|
# Display ending balance line for partner
|
||||||
partners_data[partner_id].update(
|
partners_data[partner_id].update(
|
||||||
|
@ -155,15 +159,16 @@ class OpenItemsXslx(models.AbstractModel):
|
||||||
partners_data[partner_id],
|
partners_data[partner_id],
|
||||||
type_object,
|
type_object,
|
||||||
total_amount,
|
total_amount,
|
||||||
|
report_data,
|
||||||
account_id,
|
account_id,
|
||||||
partner_id,
|
partner_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Line break
|
# Line break
|
||||||
self.row_pos += 1
|
report_data["row_pos"] += 1
|
||||||
else:
|
else:
|
||||||
# Display array header for move lines
|
# Display array header for move lines
|
||||||
self.write_array_header()
|
self.write_array_header(report_data)
|
||||||
|
|
||||||
# Display account move lines
|
# Display account move lines
|
||||||
for line in Open_items[account_id]:
|
for line in Open_items[account_id]:
|
||||||
|
@ -173,19 +178,29 @@ class OpenItemsXslx(models.AbstractModel):
|
||||||
"journal": journals_data[line["journal_id"]]["code"],
|
"journal": journals_data[line["journal_id"]]["code"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.write_line_from_dict(line)
|
self.write_line_from_dict(line, report_data)
|
||||||
|
|
||||||
# Display ending balance line for account
|
# Display ending balance line for account
|
||||||
type_object = "account"
|
type_object = "account"
|
||||||
self.write_ending_balance_from_dict(
|
self.write_ending_balance_from_dict(
|
||||||
accounts_data[account_id], type_object, total_amount, account_id
|
accounts_data[account_id],
|
||||||
|
type_object,
|
||||||
|
report_data,
|
||||||
|
total_amount,
|
||||||
|
account_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2 lines break
|
# 2 lines break
|
||||||
self.row_pos += 2
|
report_data["row_pos"] += 2
|
||||||
|
|
||||||
def write_ending_balance_from_dict(
|
def write_ending_balance_from_dict(
|
||||||
self, my_object, type_object, total_amount, account_id=False, partner_id=False
|
self,
|
||||||
|
my_object,
|
||||||
|
type_object,
|
||||||
|
total_amount,
|
||||||
|
report_data,
|
||||||
|
account_id=False,
|
||||||
|
partner_id=False,
|
||||||
):
|
):
|
||||||
"""Specific function to write ending balance for Open Items"""
|
"""Specific function to write ending balance for Open Items"""
|
||||||
if type_object == "partner":
|
if type_object == "partner":
|
||||||
|
@ -197,5 +212,5 @@ class OpenItemsXslx(models.AbstractModel):
|
||||||
my_object["residual"] = total_amount[account_id]["residual"]
|
my_object["residual"] = total_amount[account_id]["residual"]
|
||||||
label = _("Ending balance")
|
label = _("Ending balance")
|
||||||
super(OpenItemsXslx, self).write_ending_balance_from_dict(
|
super(OpenItemsXslx, self).write_ending_balance_from_dict(
|
||||||
my_object, name, label
|
my_object, name, label, report_data
|
||||||
)
|
)
|
||||||
|
|
|
@ -539,7 +539,7 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
groups_data[group.id].update(
|
groups_data[group.id].update(
|
||||||
{
|
{
|
||||||
"id": group.id,
|
"id": group.id,
|
||||||
"code": group.code_prefix,
|
"code": group.code_prefix_start,
|
||||||
"name": group.name,
|
"name": group.name,
|
||||||
"parent_id": group.parent_id.id,
|
"parent_id": group.parent_id.id,
|
||||||
"parent_path": group.parent_path,
|
"parent_path": group.parent_path,
|
||||||
|
@ -573,7 +573,7 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
{
|
{
|
||||||
group.id: {
|
group.id: {
|
||||||
"id": group.id,
|
"id": group.id,
|
||||||
"code": group.code_prefix,
|
"code": group.code_prefix_start,
|
||||||
"name": group.name,
|
"name": group.name,
|
||||||
"parent_id": group.parent_id.id,
|
"parent_id": group.parent_id.id,
|
||||||
"parent_path": group.parent_path,
|
"parent_path": group.parent_path,
|
||||||
|
@ -620,12 +620,12 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
groups = self.env["account.group"].search([("id", "!=", False)])
|
groups = self.env["account.group"].search([("id", "!=", False)])
|
||||||
groups_data = {}
|
groups_data = {}
|
||||||
for group in groups:
|
for group in groups:
|
||||||
len_group_code = len(group.code_prefix)
|
len_group_code = len(group.code_prefix_start)
|
||||||
groups_data.update(
|
groups_data.update(
|
||||||
{
|
{
|
||||||
group.id: {
|
group.id: {
|
||||||
"id": group.id,
|
"id": group.id,
|
||||||
"code": group.code_prefix,
|
"code": group.code_prefix_start,
|
||||||
"name": group.name,
|
"name": group.name,
|
||||||
"parent_id": group.parent_id.id,
|
"parent_id": group.parent_id.id,
|
||||||
"parent_path": group.parent_path,
|
"parent_path": group.parent_path,
|
||||||
|
@ -644,7 +644,7 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
groups_data[group.id]["initial_currency_balance"] = 0.0
|
groups_data[group.id]["initial_currency_balance"] = 0.0
|
||||||
groups_data[group.id]["ending_currency_balance"] = 0.0
|
groups_data[group.id]["ending_currency_balance"] = 0.0
|
||||||
for account in accounts_data.values():
|
for account in accounts_data.values():
|
||||||
if group.code_prefix == account["code"][:len_group_code]:
|
if group.code_prefix_start == account["code"][:len_group_code]:
|
||||||
acc_id = account["id"]
|
acc_id = account["id"]
|
||||||
group_id = group.id
|
group_id = group.id
|
||||||
groups_data[group_id]["initial_balance"] += total_amount[acc_id][
|
groups_data[group_id]["initial_balance"] += total_amount[acc_id][
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Author: Julien Coux
|
# Author: Julien Coux
|
||||||
# Copyright 2016 Camptocamp SA
|
# Copyright 2016 Camptocamp SA
|
||||||
|
# Copyright 2021 Tecnativa - João Marques
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,7 +174,7 @@ class TrialBalanceXslx(models.AbstractModel):
|
||||||
def _get_col_count_filter_value(self):
|
def _get_col_count_filter_value(self):
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
def _generate_report_content(self, workbook, report, data):
|
def _generate_report_content(self, workbook, report, data, report_data):
|
||||||
res_data = self.env[
|
res_data = self.env[
|
||||||
"report.account_financial_report.trial_balance"
|
"report.account_financial_report.trial_balance"
|
||||||
]._get_report_values(report, data)
|
]._get_report_values(report, data)
|
||||||
|
@ -188,7 +189,7 @@ class TrialBalanceXslx(models.AbstractModel):
|
||||||
limit_hierarchy_level = res_data["limit_hierarchy_level"]
|
limit_hierarchy_level = res_data["limit_hierarchy_level"]
|
||||||
if not show_partner_details:
|
if not show_partner_details:
|
||||||
# Display array header for account lines
|
# Display array header for account lines
|
||||||
self.write_array_header()
|
self.write_array_header(report_data)
|
||||||
|
|
||||||
# For each account
|
# For each account
|
||||||
if not show_partner_details:
|
if not show_partner_details:
|
||||||
|
@ -197,29 +198,30 @@ class TrialBalanceXslx(models.AbstractModel):
|
||||||
if limit_hierarchy_level:
|
if limit_hierarchy_level:
|
||||||
if show_hierarchy_level > balance["level"]:
|
if show_hierarchy_level > balance["level"]:
|
||||||
# Display account lines
|
# Display account lines
|
||||||
self.write_line_from_dict(balance)
|
self.write_line_from_dict(balance, report_data)
|
||||||
else:
|
else:
|
||||||
self.write_line_from_dict(balance)
|
self.write_line_from_dict(balance, report_data)
|
||||||
elif hierarchy_on == "computed":
|
elif hierarchy_on == "computed":
|
||||||
if balance["type"] == "account_type":
|
if balance["type"] == "account_type":
|
||||||
if limit_hierarchy_level:
|
if limit_hierarchy_level:
|
||||||
if show_hierarchy_level > balance["level"]:
|
if show_hierarchy_level > balance["level"]:
|
||||||
# Display account lines
|
# Display account lines
|
||||||
self.write_line_from_dict(balance)
|
self.write_line_from_dict(balance, report_data)
|
||||||
else:
|
else:
|
||||||
self.write_line_from_dict(balance)
|
self.write_line_from_dict(balance, report_data)
|
||||||
else:
|
else:
|
||||||
self.write_line_from_dict(balance)
|
self.write_line_from_dict(balance, report_data)
|
||||||
else:
|
else:
|
||||||
for account_id in total_amount:
|
for account_id in total_amount:
|
||||||
# Write account title
|
# Write account title
|
||||||
self.write_array_title(
|
self.write_array_title(
|
||||||
accounts_data[account_id]["code"]
|
accounts_data[account_id]["code"]
|
||||||
+ "- "
|
+ "- "
|
||||||
+ accounts_data[account_id]["name"]
|
+ accounts_data[account_id]["name"],
|
||||||
|
report_data,
|
||||||
)
|
)
|
||||||
# Display array header for partner lines
|
# Display array header for partner lines
|
||||||
self.write_array_header()
|
self.write_array_header(report_data)
|
||||||
|
|
||||||
# For each partner
|
# For each partner
|
||||||
for partner_id in total_amount[account_id]:
|
for partner_id in total_amount[account_id]:
|
||||||
|
@ -228,6 +230,7 @@ class TrialBalanceXslx(models.AbstractModel):
|
||||||
self.write_line_from_dict_order(
|
self.write_line_from_dict_order(
|
||||||
total_amount[account_id][partner_id],
|
total_amount[account_id][partner_id],
|
||||||
partners_data[partner_id],
|
partners_data[partner_id],
|
||||||
|
report_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Display account footer line
|
# Display account footer line
|
||||||
|
@ -256,16 +259,17 @@ class TrialBalanceXslx(models.AbstractModel):
|
||||||
accounts_data[account_id]["code"]
|
accounts_data[account_id]["code"]
|
||||||
+ "- "
|
+ "- "
|
||||||
+ accounts_data[account_id]["name"],
|
+ accounts_data[account_id]["name"],
|
||||||
|
report_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Line break
|
# Line break
|
||||||
self.row_pos += 2
|
report_data["row_pos"] += 2
|
||||||
|
|
||||||
def write_line_from_dict_order(self, total_amount, partner_data):
|
def write_line_from_dict_order(self, total_amount, partner_data, report_data):
|
||||||
total_amount.update({"name": str(partner_data["name"])})
|
total_amount.update({"name": str(partner_data["name"])})
|
||||||
self.write_line_from_dict(total_amount)
|
self.write_line_from_dict(total_amount, report_data)
|
||||||
|
|
||||||
def write_line(self, line_object, type_object):
|
def write_line(self, line_object, type_object, report_data):
|
||||||
"""Write a line on current line using all defined columns field name.
|
"""Write a line on current line using all defined columns field name.
|
||||||
Columns are defined with `_get_report_columns` method.
|
Columns are defined with `_get_report_columns` method.
|
||||||
"""
|
"""
|
||||||
|
@ -273,33 +277,47 @@ class TrialBalanceXslx(models.AbstractModel):
|
||||||
line_object.currency_id = line_object.report_account_id.currency_id
|
line_object.currency_id = line_object.report_account_id.currency_id
|
||||||
elif type_object == "account":
|
elif type_object == "account":
|
||||||
line_object.currency_id = line_object.currency_id
|
line_object.currency_id = line_object.currency_id
|
||||||
super(TrialBalanceXslx, self).write_line(line_object)
|
super(TrialBalanceXslx, self).write_line(line_object, report_data)
|
||||||
|
|
||||||
def write_account_footer(self, account, name_value):
|
def write_account_footer(self, account, name_value, report_data):
|
||||||
"""Specific function to write account footer for Trial Balance"""
|
"""Specific function to write account footer for Trial Balance"""
|
||||||
format_amt = self._get_currency_amt_header_format_dict(account)
|
format_amt = self._get_currency_amt_header_format_dict(account, report_data)
|
||||||
for col_pos, column in self.columns.items():
|
for col_pos, column in report_data["columns"].items():
|
||||||
if column["field"] == "name":
|
if column["field"] == "name":
|
||||||
value = name_value
|
value = name_value
|
||||||
else:
|
else:
|
||||||
value = account[column["field"]]
|
value = account[column["field"]]
|
||||||
cell_type = column.get("type", "string")
|
cell_type = column.get("type", "string")
|
||||||
if cell_type == "string":
|
if cell_type == "string":
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value or "", self.format_header_left
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value or "",
|
||||||
|
report_data["formats"]["format_header_left"],
|
||||||
)
|
)
|
||||||
elif cell_type == "amount":
|
elif cell_type == "amount":
|
||||||
self.sheet.write_number(
|
report_data["sheet"].write_number(
|
||||||
self.row_pos, col_pos, float(value), self.format_header_amount
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
float(value),
|
||||||
|
report_data["formats"]["format_header_amount"],
|
||||||
)
|
)
|
||||||
elif cell_type == "many2one" and account["currency_id"]:
|
elif cell_type == "many2one" and account["currency_id"]:
|
||||||
self.sheet.write_string(
|
report_data["sheet"].write_string(
|
||||||
self.row_pos, col_pos, value.name or "", self.format_header_right
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
value.name or "",
|
||||||
|
report_data["formats"]["format_header_right"],
|
||||||
)
|
)
|
||||||
elif cell_type == "amount_currency" and account["currency_id"]:
|
elif cell_type == "amount_currency" and account["currency_id"]:
|
||||||
self.sheet.write_number(self.row_pos, col_pos, float(value), format_amt)
|
report_data["sheet"].write_number(
|
||||||
else:
|
report_data["row_pos"], col_pos, float(value), format_amt
|
||||||
self.sheet.write_string(
|
|
||||||
self.row_pos, col_pos, "", self.format_header_right
|
|
||||||
)
|
)
|
||||||
self.row_pos += 1
|
else:
|
||||||
|
report_data["sheet"].write_string(
|
||||||
|
report_data["row_pos"],
|
||||||
|
col_pos,
|
||||||
|
"",
|
||||||
|
report_data["formats"]["format_header_right"],
|
||||||
|
)
|
||||||
|
report_data["row_pos"] += 1
|
||||||
|
|
|
@ -65,7 +65,6 @@ class VATReport(models.AbstractModel):
|
||||||
"tax_line_id",
|
"tax_line_id",
|
||||||
"tax_ids",
|
"tax_ids",
|
||||||
"analytic_tag_ids",
|
"analytic_tag_ids",
|
||||||
"tag_ids",
|
|
||||||
]
|
]
|
||||||
tax_move_lines = self.env["account.move.line"].search_read(
|
tax_move_lines = self.env["account.move.line"].search_read(
|
||||||
domain=tax_domain,
|
domain=tax_domain,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# Copyright 2018 Forest and Biomass Romania
|
# Copyright 2018 Forest and Biomass Romania
|
||||||
|
# Copyright 2021 Tecnativa - João Marques
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo import _, models
|
from odoo import _, models
|
||||||
|
@ -42,19 +43,19 @@ class VATReportXslx(models.AbstractModel):
|
||||||
def _get_col_count_filter_value(self):
|
def _get_col_count_filter_value(self):
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
def _generate_report_content(self, workbook, report, data):
|
def _generate_report_content(self, workbook, report, data, report_data):
|
||||||
res_data = self.env[
|
res_data = self.env[
|
||||||
"report.account_financial_report.vat_report"
|
"report.account_financial_report.vat_report"
|
||||||
]._get_report_values(report, data)
|
]._get_report_values(report, data)
|
||||||
vat_report = res_data["vat_report"]
|
vat_report = res_data["vat_report"]
|
||||||
tax_detail = res_data["tax_detail"]
|
tax_detail = res_data["tax_detail"]
|
||||||
# For each tax_tag tax_group
|
# For each tax_tag tax_group
|
||||||
self.write_array_header()
|
self.write_array_header(report_data)
|
||||||
for tag_or_group in vat_report:
|
for tag_or_group in vat_report:
|
||||||
# Write taxtag line
|
# Write taxtag line
|
||||||
self.write_line_from_dict(tag_or_group)
|
self.write_line_from_dict(tag_or_group, report_data)
|
||||||
|
|
||||||
# For each tax if detail taxes
|
# For each tax if detail taxes
|
||||||
if tax_detail:
|
if tax_detail:
|
||||||
for tax in tag_or_group["taxes"]:
|
for tax in tag_or_group["taxes"]:
|
||||||
self.write_line_from_dict(tax)
|
self.write_line_from_dict(tax, report_data)
|
||||||
|
|
|
@ -1,120 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<!-- PDF/HMTL REPORTS -->
|
|
||||||
<!-- General Ledger -->
|
|
||||||
<report
|
|
||||||
id="action_print_report_general_ledger_qweb"
|
|
||||||
model="general.ledger.report.wizard"
|
|
||||||
string="General Ledger"
|
|
||||||
report_type="qweb-pdf"
|
|
||||||
menu="False"
|
|
||||||
name="account_financial_report.general_ledger"
|
|
||||||
file="account_financial_report.general_ledger"
|
|
||||||
/>
|
|
||||||
<report
|
|
||||||
id="action_print_report_general_ledger_html"
|
|
||||||
model="general.ledger.report.wizard"
|
|
||||||
string="General Ledger"
|
|
||||||
report_type="qweb-html"
|
|
||||||
menu="False"
|
|
||||||
name="account_financial_report.general_ledger"
|
|
||||||
file="account_financial_report.general_ledger"
|
|
||||||
/>
|
|
||||||
<!-- Journal Ledger -->
|
|
||||||
<report
|
|
||||||
id="action_print_journal_ledger_wizard_qweb"
|
|
||||||
model="journal.ledger.report.wizard"
|
|
||||||
report_type="qweb-pdf"
|
|
||||||
menu="False"
|
|
||||||
string="Journal Ledger"
|
|
||||||
name="account_financial_report.journal_ledger"
|
|
||||||
file="account_financial_report.journal_ledger"
|
|
||||||
/>
|
|
||||||
<report
|
|
||||||
id="action_print_journal_ledger_wizard_html"
|
|
||||||
model="journal.ledger.report.wizard"
|
|
||||||
report_type="qweb-html"
|
|
||||||
menu="False"
|
|
||||||
string="Journal Ledger"
|
|
||||||
name="account_financial_report.journal_ledger"
|
|
||||||
file="account_financial_report.journal_ledger"
|
|
||||||
/>
|
|
||||||
<!-- Trial Balance -->
|
|
||||||
<report
|
|
||||||
id="action_report_trial_balance_qweb"
|
|
||||||
model="trial.balance.report.wizard"
|
|
||||||
string="Trial Balance"
|
|
||||||
menu="False"
|
|
||||||
report_type="qweb-pdf"
|
|
||||||
name="account_financial_report.trial_balance"
|
|
||||||
file="account_financial_report.trial_balance"
|
|
||||||
/>
|
|
||||||
<report
|
|
||||||
id="action_report_trial_balance_html"
|
|
||||||
model="trial.balance.report.wizard"
|
|
||||||
string="Trial Balance"
|
|
||||||
menu="False"
|
|
||||||
report_type="qweb-html"
|
|
||||||
name="account_financial_report.trial_balance"
|
|
||||||
file="account_financial_report.trial_balance"
|
|
||||||
/>
|
|
||||||
<!-- Open Items -->
|
|
||||||
<report
|
|
||||||
id="action_print_report_open_items_qweb"
|
|
||||||
model="open.items.report.wizard"
|
|
||||||
string="Open Items"
|
|
||||||
menu="False"
|
|
||||||
report_type="qweb-pdf"
|
|
||||||
name="account_financial_report.open_items"
|
|
||||||
file="account_financial_report.open_items"
|
|
||||||
/>
|
|
||||||
<report
|
|
||||||
id="action_print_report_open_items_html"
|
|
||||||
model="open.items.report.wizard"
|
|
||||||
string="Open Items"
|
|
||||||
menu="False"
|
|
||||||
report_type="qweb-html"
|
|
||||||
name="account_financial_report.open_items"
|
|
||||||
file="account_financial_report.open_items"
|
|
||||||
/>
|
|
||||||
<!-- Aged Partner Balance -->
|
|
||||||
<report
|
|
||||||
id="action_print_report_aged_partner_balance_qweb"
|
|
||||||
model="aged.partner.balance.report.wizard"
|
|
||||||
string="Aged Partner Balance"
|
|
||||||
report_type="qweb-pdf"
|
|
||||||
menu="False"
|
|
||||||
name="account_financial_report.aged_partner_balance"
|
|
||||||
file="account_financial_report.aged_partner_balance"
|
|
||||||
/>
|
|
||||||
<report
|
|
||||||
id="action_print_report_aged_partner_balance_html"
|
|
||||||
model="aged.partner.balance.report.wizard"
|
|
||||||
string="Aged Partner Balance"
|
|
||||||
report_type="qweb-html"
|
|
||||||
menu="False"
|
|
||||||
name="account_financial_report.aged_partner_balance"
|
|
||||||
file="account_financial_report.aged_partner_balance"
|
|
||||||
/>
|
|
||||||
<!-- VAT Report -->
|
|
||||||
<report
|
|
||||||
id="action_print_report_vat_report_qweb"
|
|
||||||
model="vat.report.wizard"
|
|
||||||
string="VAT Report"
|
|
||||||
report_type="qweb-pdf"
|
|
||||||
menu="False"
|
|
||||||
name="account_financial_report.vat_report"
|
|
||||||
file="account_financial_report.vat_report"
|
|
||||||
/>
|
|
||||||
<report
|
|
||||||
id="action_print_report_vat_report_html"
|
|
||||||
model="vat.report.wizard"
|
|
||||||
string="VAT Report"
|
|
||||||
report_type="qweb-html"
|
|
||||||
menu="False"
|
|
||||||
name="account_financial_report.vat_report"
|
|
||||||
file="account_financial_report.vat_report"
|
|
||||||
/>
|
|
||||||
<!-- PDF REPORTS : paperformat -->
|
<!-- PDF REPORTS : paperformat -->
|
||||||
<record id="report_qweb_paperformat" model="report.paperformat">
|
<record id="report_qweb_paperformat" model="report.paperformat">
|
||||||
<field name="name">Account financial report qweb paperformat</field>
|
<field name="name">Account financial report qweb paperformat</field>
|
||||||
|
@ -131,27 +16,111 @@
|
||||||
<field name="header_spacing">10</field>
|
<field name="header_spacing">10</field>
|
||||||
<field name="dpi">110</field>
|
<field name="dpi">110</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- PDF/HMTL REPORTS -->
|
||||||
|
<!-- General Ledger -->
|
||||||
<record id="action_print_report_general_ledger_qweb" model="ir.actions.report">
|
<record id="action_print_report_general_ledger_qweb" model="ir.actions.report">
|
||||||
|
<field name="name">General Ledger</field>
|
||||||
|
<field name="model">general.ledger.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-pdf</field>
|
||||||
|
<field name="report_name">account_financial_report.general_ledger</field>
|
||||||
|
<field name="report_file">account_financial_report.general_ledger</field>
|
||||||
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
||||||
</record>
|
</record>
|
||||||
|
<record id="action_print_report_general_ledger_html" model="ir.actions.report">
|
||||||
|
<field name="name">General Ledger</field>
|
||||||
|
<field name="model">general.ledger.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-html</field>
|
||||||
|
<field name="report_name">account_financial_report.general_ledger</field>
|
||||||
|
<field name="report_file">account_financial_report.general_ledger</field>
|
||||||
|
</record>
|
||||||
|
<!-- Journal Ledger -->
|
||||||
<record id="action_print_journal_ledger_wizard_qweb" model="ir.actions.report">
|
<record id="action_print_journal_ledger_wizard_qweb" model="ir.actions.report">
|
||||||
|
<field name="name">ournal Ledger</field>
|
||||||
|
<field name="model">journal.ledger.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-pdf</field>
|
||||||
|
<field name="report_name">account_financial_report.journal_ledger</field>
|
||||||
|
<field name="report_file">account_financial_report.journal_ledger</field>
|
||||||
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
||||||
</record>
|
</record>
|
||||||
|
<record id="action_print_journal_ledger_wizard_html" model="ir.actions.report">
|
||||||
|
<field name="name">Journal Ledger</field>
|
||||||
|
<field name="model">journal.ledger.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-html</field>
|
||||||
|
<field name="report_name">account_financial_report.journal_ledger</field>
|
||||||
|
<field name="report_file">account_financial_report.journal_ledger</field>
|
||||||
|
</record>
|
||||||
|
<!-- Trial Balance -->
|
||||||
<record id="action_report_trial_balance_qweb" model="ir.actions.report">
|
<record id="action_report_trial_balance_qweb" model="ir.actions.report">
|
||||||
|
<field name="name">Trial Balance</field>
|
||||||
|
<field name="model">trial.balance.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-pdf</field>
|
||||||
|
<field name="report_name">account_financial_report.trial_balance</field>
|
||||||
|
<field name="report_file">account_financial_report.trial_balance</field>
|
||||||
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
||||||
</record>
|
</record>
|
||||||
|
<record id="action_report_trial_balance_html" model="ir.actions.report">
|
||||||
|
<field name="name">Trial Balance</field>
|
||||||
|
<field name="model">trial.balance.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-html</field>
|
||||||
|
<field name="report_name">account_financial_report.trial_balance</field>
|
||||||
|
<field name="report_file">account_financial_report.trial_balance</field>
|
||||||
|
</record>
|
||||||
|
<!-- Open Items -->
|
||||||
<record id="action_print_report_open_items_qweb" model="ir.actions.report">
|
<record id="action_print_report_open_items_qweb" model="ir.actions.report">
|
||||||
|
<field name="name">Open Items</field>
|
||||||
|
<field name="model">open.items.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-pdf</field>
|
||||||
|
<field name="report_name">account_financial_report.open_items</field>
|
||||||
|
<field name="report_file">account_financial_report.open_items</field>
|
||||||
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
||||||
</record>
|
</record>
|
||||||
|
<record id="action_print_report_open_items_html" model="ir.actions.report">
|
||||||
|
<field name="name">Open Items</field>
|
||||||
|
<field name="model">open.items.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-html</field>
|
||||||
|
<field name="report_name">account_financial_report.open_items</field>
|
||||||
|
<field name="report_file">account_financial_report.open_items</field>
|
||||||
|
</record>
|
||||||
|
<!-- Aged Partner Balance -->
|
||||||
<record
|
<record
|
||||||
id="action_print_report_aged_partner_balance_qweb"
|
id="action_print_report_aged_partner_balance_qweb"
|
||||||
model="ir.actions.report"
|
model="ir.actions.report"
|
||||||
>
|
>
|
||||||
|
<field name="name">Aged Partner Balance</field>
|
||||||
|
<field name="model">aged.partner.balance.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-pdf</field>
|
||||||
|
<field name="report_name">account_financial_report.aged_partner_balance</field>
|
||||||
|
<field name="report_file">account_financial_report.aged_partner_balance</field>
|
||||||
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
||||||
</record>
|
</record>
|
||||||
|
<record
|
||||||
|
id="action_print_report_aged_partner_balance_html"
|
||||||
|
model="ir.actions.report"
|
||||||
|
>
|
||||||
|
<field name="name">Aged Partner Balance</field>
|
||||||
|
<field name="model">aged.partner.balance.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-html</field>
|
||||||
|
<field name="report_name">account_financial_report.aged_partner_balance</field>
|
||||||
|
<field name="report_file">account_financial_report.aged_partner_balance</field>
|
||||||
|
</record>
|
||||||
|
<!-- VAT Report -->
|
||||||
<record id="action_print_report_vat_report_qweb" model="ir.actions.report">
|
<record id="action_print_report_vat_report_qweb" model="ir.actions.report">
|
||||||
|
<field name="name">VAT Report</field>
|
||||||
|
<field name="model">vat.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-pdf</field>
|
||||||
|
<field name="report_name">account_financial_report.vat_report</field>
|
||||||
|
<field name="report_file">account_financial_report.vat_report</field>
|
||||||
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
<field name="paperformat_id" ref="report_qweb_paperformat" />
|
||||||
</record>
|
</record>
|
||||||
|
<record id="action_print_report_vat_report_html" model="ir.actions.report">
|
||||||
|
<field name="name">VAT Report</field>
|
||||||
|
<field name="model">vat.report.wizard</field>
|
||||||
|
<field name="report_type">qweb-html</field>
|
||||||
|
<field name="report_name">account_financial_report.vat_report</field>
|
||||||
|
<field name="report_file">account_financial_report.vat_report</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<!-- XLSX REPORTS -->
|
<!-- XLSX REPORTS -->
|
||||||
<record id="action_report_general_ledger_xlsx" model="ir.actions.report">
|
<record id="action_report_general_ledger_xlsx" model="ir.actions.report">
|
||||||
<field name="name">General Ledger XLSX</field>
|
<field name="name">General Ledger XLSX</field>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
access_aged_partner_balance_report_wizard,access_aged_partner_balance_report_wizard,model_aged_partner_balance_report_wizard,base.group_user,1,1,1,1
|
||||||
|
access_general_ledger_report_wizard,access_general_ledger_report_wizard,model_general_ledger_report_wizard,base.group_user,1,1,1,1
|
||||||
|
access_journal_ledger_report_wizard,access_journal_ledger_report_wizard,model_journal_ledger_report_wizard,base.group_user,1,1,1,1
|
||||||
|
access_open_items_report_wizard,access_open_items_report_wizard,model_open_items_report_wizard,base.group_user,1,1,1,1
|
||||||
|
access_trial_balance_report_wizard,access_trial_balance_report_wizard,model_trial_balance_report_wizard,base.group_user,1,1,1,1
|
||||||
|
access_vat_report_wizard,access_vat_report_wizard,model_vat_report_wizard,base.group_user,1,1,1,1
|
|
|
@ -3,7 +3,7 @@
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
|
||||||
<title>Account Financial Reports</title>
|
<title>Account Financial Reports</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ ul.auto-toc {
|
||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/13.0/account_financial_report"><img alt="OCA/account-financial-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-reporting-13-0/account-financial-reporting-13-0-account_financial_report"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/91/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/14.0/account_financial_report"><img alt="OCA/account-financial-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-reporting-14-0/account-financial-reporting-14-0-account_financial_report"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/91/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||||
<p>This module adds a set of financial reports. They are accessible under
|
<p>This module adds a set of financial reports. They are accessible under
|
||||||
Invoicing / Reporting / OCA accounting reports.</p>
|
Invoicing / Reporting / OCA accounting reports.</p>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
|
@ -444,7 +444,7 @@ in “Target Moves” field in a wizard</li>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_financial_report%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_financial_report%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
@ -483,6 +483,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||||
<li>Pedro M. Baeza</li>
|
<li>Pedro M. Baeza</li>
|
||||||
<li>Sergio Teruel</li>
|
<li>Sergio Teruel</li>
|
||||||
<li>Ernesto Tejeda</li>
|
<li>Ernesto Tejeda</li>
|
||||||
|
<li>João Marques</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -496,7 +497,7 @@ April 2016.</p>
|
||||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.</p>
|
promote its widespread use.</p>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/13.0/account_financial_report">OCA/account-financial-reporting</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/14.0/account_financial_report">OCA/account-financial-reporting</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -86,7 +86,7 @@ class TestGeneralLedgerReport(common.TransactionCase):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
move = self.env["account.move"].create(move_vals)
|
move = self.env["account.move"].create(move_vals)
|
||||||
move.post()
|
move.action_post()
|
||||||
|
|
||||||
def _get_report_lines(self, with_partners=False):
|
def _get_report_lines(self, with_partners=False):
|
||||||
centralize = True
|
centralize = True
|
||||||
|
|
|
@ -215,15 +215,15 @@ class TestJournalReport(TransactionCase):
|
||||||
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
|
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
|
||||||
self.check_report_journal_debit_credit(res_data, 0, 0)
|
self.check_report_journal_debit_credit(res_data, 0, 0)
|
||||||
|
|
||||||
move1.post()
|
move1.action_post()
|
||||||
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
|
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
|
||||||
self.check_report_journal_debit_credit(res_data, 100, 100)
|
self.check_report_journal_debit_credit(res_data, 100, 100)
|
||||||
|
|
||||||
move2.post()
|
move2.action_post()
|
||||||
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
|
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
|
||||||
self.check_report_journal_debit_credit(res_data, 100, 100)
|
self.check_report_journal_debit_credit(res_data, 100, 100)
|
||||||
|
|
||||||
move3.post()
|
move3.action_post()
|
||||||
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
|
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
|
||||||
self.check_report_journal_debit_credit(res_data, 200, 200)
|
self.check_report_journal_debit_credit(res_data, 200, 200)
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ class TestJournalReport(TransactionCase):
|
||||||
|
|
||||||
def test_02_test_taxes_out_invoice(self):
|
def test_02_test_taxes_out_invoice(self):
|
||||||
move_form = Form(
|
move_form = Form(
|
||||||
self.env["account.move"].with_context(default_type="out_invoice")
|
self.env["account.move"].with_context(default_move_type="out_invoice")
|
||||||
)
|
)
|
||||||
move_form.partner_id = self.partner_2
|
move_form.partner_id = self.partner_2
|
||||||
move_form.journal_id = self.journal_sale
|
move_form.journal_id = self.journal_sale
|
||||||
|
@ -252,7 +252,7 @@ class TestJournalReport(TransactionCase):
|
||||||
line_form.tax_ids.add(self.tax_15_s)
|
line_form.tax_ids.add(self.tax_15_s)
|
||||||
line_form.tax_ids.add(self.tax_20_s)
|
line_form.tax_ids.add(self.tax_20_s)
|
||||||
invoice = move_form.save()
|
invoice = move_form.save()
|
||||||
invoice.post()
|
invoice.action_post()
|
||||||
|
|
||||||
wiz = self.JournalLedgerReportWizard.create(
|
wiz = self.JournalLedgerReportWizard.create(
|
||||||
{
|
{
|
||||||
|
@ -269,42 +269,8 @@ class TestJournalReport(TransactionCase):
|
||||||
self.check_report_journal_debit_credit_taxes(res_data, 0, 300, 0, 50)
|
self.check_report_journal_debit_credit_taxes(res_data, 0, 300, 0, 50)
|
||||||
|
|
||||||
def test_03_test_taxes_in_invoice(self):
|
def test_03_test_taxes_in_invoice(self):
|
||||||
# invoice_values = {
|
|
||||||
# "journal_id": self.journal_purchase.id,
|
|
||||||
# "partner_id": self.partner_2.id,
|
|
||||||
# "type": "in_invoice",
|
|
||||||
# "invoice_line_ids": [
|
|
||||||
# (
|
|
||||||
# 0,
|
|
||||||
# 0,
|
|
||||||
# {
|
|
||||||
# "quantity": 1.0,
|
|
||||||
# "price_unit": 100,
|
|
||||||
# "account_id": self.payable_account.id,
|
|
||||||
# "name": "Test",
|
|
||||||
# "tax_ids": [(6, 0, [self.tax_15_p.id])],
|
|
||||||
# },
|
|
||||||
# ),
|
|
||||||
# (
|
|
||||||
# 0,
|
|
||||||
# 0,
|
|
||||||
# {
|
|
||||||
# "quantity": 1.0,
|
|
||||||
# "price_unit": 100,
|
|
||||||
# "account_id": self.payable_account.id,
|
|
||||||
# "name": "Test",
|
|
||||||
# "tax_ids": [
|
|
||||||
# (6, 0, [self.tax_15_p.id, self.tax_20_p.id])
|
|
||||||
# ],
|
|
||||||
# },
|
|
||||||
# ),
|
|
||||||
# ],
|
|
||||||
# }
|
|
||||||
# invoice = self.InvoiceObj.create(invoice_values)
|
|
||||||
# invoice.post()
|
|
||||||
|
|
||||||
move_form = Form(
|
move_form = Form(
|
||||||
self.env["account.move"].with_context(default_type="in_invoice")
|
self.env["account.move"].with_context(default_move_type="in_invoice")
|
||||||
)
|
)
|
||||||
move_form.partner_id = self.partner_2
|
move_form.partner_id = self.partner_2
|
||||||
move_form.journal_id = self.journal_purchase
|
move_form.journal_id = self.journal_purchase
|
||||||
|
@ -322,7 +288,7 @@ class TestJournalReport(TransactionCase):
|
||||||
line_form.tax_ids.add(self.tax_15_p)
|
line_form.tax_ids.add(self.tax_15_p)
|
||||||
line_form.tax_ids.add(self.tax_20_p)
|
line_form.tax_ids.add(self.tax_20_p)
|
||||||
invoice = move_form.save()
|
invoice = move_form.save()
|
||||||
invoice.post()
|
invoice.action_post()
|
||||||
|
|
||||||
wiz = self.JournalLedgerReportWizard.create(
|
wiz = self.JournalLedgerReportWizard.create(
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,13 +10,12 @@ class TestTrialBalanceReport(common.TransactionCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestTrialBalanceReport, self).setUp()
|
super(TestTrialBalanceReport, self).setUp()
|
||||||
group_obj = self.env["account.group"]
|
group_obj = self.env["account.group"]
|
||||||
acc_obj = self.env["account.account"]
|
self.group1 = group_obj.create({"code_prefix_start": "1", "name": "Group 1"})
|
||||||
self.group1 = group_obj.create({"code_prefix": "1", "name": "Group 1"})
|
|
||||||
self.group11 = group_obj.create(
|
self.group11 = group_obj.create(
|
||||||
{"code_prefix": "11", "name": "Group 11", "parent_id": self.group1.id}
|
{"code_prefix_start": "11", "name": "Group 11", "parent_id": self.group1.id}
|
||||||
)
|
)
|
||||||
self.group2 = group_obj.create({"code_prefix": "2", "name": "Group 2"})
|
self.group2 = group_obj.create({"code_prefix_start": "2", "name": "Group 2"})
|
||||||
self.account100 = acc_obj.create(
|
self.account100 = self._create_account_account(
|
||||||
{
|
{
|
||||||
"code": "100",
|
"code": "100",
|
||||||
"name": "Account 100",
|
"name": "Account 100",
|
||||||
|
@ -35,7 +34,7 @@ class TestTrialBalanceReport(common.TransactionCase):
|
||||||
],
|
],
|
||||||
limit=1,
|
limit=1,
|
||||||
)
|
)
|
||||||
self.account200 = acc_obj.create(
|
self.account200 = self._create_account_account(
|
||||||
{
|
{
|
||||||
"code": "200",
|
"code": "200",
|
||||||
"name": "Account 200",
|
"name": "Account 200",
|
||||||
|
@ -45,7 +44,7 @@ class TestTrialBalanceReport(common.TransactionCase):
|
||||||
).id,
|
).id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.account300 = acc_obj.create(
|
self.account300 = self._create_account_account(
|
||||||
{
|
{
|
||||||
"code": "300",
|
"code": "300",
|
||||||
"name": "Account 300",
|
"name": "Account 300",
|
||||||
|
@ -54,7 +53,7 @@ class TestTrialBalanceReport(common.TransactionCase):
|
||||||
).id,
|
).id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.account301 = acc_obj.create(
|
self.account301 = self._create_account_account(
|
||||||
{
|
{
|
||||||
"code": "301",
|
"code": "301",
|
||||||
"name": "Account 301",
|
"name": "Account 301",
|
||||||
|
@ -82,6 +81,12 @@ class TestTrialBalanceReport(common.TransactionCase):
|
||||||
limit=1,
|
limit=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _create_account_account(self, vals):
|
||||||
|
item = self.env["account.account"].create(vals)
|
||||||
|
if "group_id" in vals:
|
||||||
|
item.group_id = vals["group_id"]
|
||||||
|
return item
|
||||||
|
|
||||||
def _add_move(
|
def _add_move(
|
||||||
self,
|
self,
|
||||||
date,
|
date,
|
||||||
|
@ -151,7 +156,7 @@ class TestTrialBalanceReport(common.TransactionCase):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
move = self.env["account.move"].create(move_vals)
|
move = self.env["account.move"].create(move_vals)
|
||||||
move.post()
|
move.action_post()
|
||||||
|
|
||||||
def _get_report_lines(self, with_partners=False, hierarchy_on="computed"):
|
def _get_report_lines(self, with_partners=False, hierarchy_on="computed"):
|
||||||
company = self.env.ref("base.main_company")
|
company = self.env.ref("base.main_company")
|
||||||
|
@ -671,7 +676,7 @@ class TestTrialBalanceReport(common.TransactionCase):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
move = self.env["account.move"].create(move_vals)
|
move = self.env["account.move"].create(move_vals)
|
||||||
move.post()
|
move.action_post()
|
||||||
# Generate the trial balance line
|
# Generate the trial balance line
|
||||||
company = self.env.ref("base.main_company")
|
company = self.env.ref("base.main_company")
|
||||||
trial_balance = self.env["trial.balance.report.wizard"].create(
|
trial_balance = self.env["trial.balance.report.wizard"].create(
|
||||||
|
@ -723,7 +728,7 @@ class TestTrialBalanceReport(common.TransactionCase):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
move = self.env["account.move"].create(move_vals)
|
move = self.env["account.move"].create(move_vals)
|
||||||
move.post()
|
move.action_post()
|
||||||
# Re Generate the trial balance line
|
# Re Generate the trial balance line
|
||||||
trial_balance = self.env["trial.balance.report.wizard"].create(
|
trial_balance = self.env["trial.balance.report.wizard"].create(
|
||||||
{
|
{
|
||||||
|
@ -775,7 +780,7 @@ class TestTrialBalanceReport(common.TransactionCase):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
move = self.env["account.move"].create(move_vals)
|
move = self.env["account.move"].create(move_vals)
|
||||||
move.post()
|
move.action_post()
|
||||||
# Re Generate the trial balance line
|
# Re Generate the trial balance line
|
||||||
trial_balance = self.env["trial.balance.report.wizard"].create(
|
trial_balance = self.env["trial.balance.report.wizard"].create(
|
||||||
{
|
{
|
||||||
|
|
|
@ -149,7 +149,7 @@ class TestVATReport(common.TransactionCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
move_form = common.Form(
|
move_form = common.Form(
|
||||||
self.env["account.move"].with_context(default_type="out_invoice")
|
self.env["account.move"].with_context(default_move_type="out_invoice")
|
||||||
)
|
)
|
||||||
move_form.partner_id = self.env.ref("base.res_partner_2")
|
move_form.partner_id = self.env.ref("base.res_partner_2")
|
||||||
move_form.invoice_date = time.strftime("%Y-%m-03")
|
move_form.invoice_date = time.strftime("%Y-%m-03")
|
||||||
|
@ -160,10 +160,10 @@ class TestVATReport(common.TransactionCase):
|
||||||
line_form.account_id = self.income_account
|
line_form.account_id = self.income_account
|
||||||
line_form.tax_ids.add(self.tax_10)
|
line_form.tax_ids.add(self.tax_10)
|
||||||
invoice = move_form.save()
|
invoice = move_form.save()
|
||||||
invoice.post()
|
invoice.action_post()
|
||||||
|
|
||||||
move_form = common.Form(
|
move_form = common.Form(
|
||||||
self.env["account.move"].with_context(default_type="out_invoice")
|
self.env["account.move"].with_context(default_move_type="out_invoice")
|
||||||
)
|
)
|
||||||
move_form.partner_id = self.env.ref("base.res_partner_2")
|
move_form.partner_id = self.env.ref("base.res_partner_2")
|
||||||
move_form.invoice_date = time.strftime("%Y-%m-04")
|
move_form.invoice_date = time.strftime("%Y-%m-04")
|
||||||
|
@ -174,7 +174,7 @@ class TestVATReport(common.TransactionCase):
|
||||||
line_form.account_id = self.income_account
|
line_form.account_id = self.income_account
|
||||||
line_form.tax_ids.add(self.tax_20)
|
line_form.tax_ids.add(self.tax_20)
|
||||||
invoice = move_form.save()
|
invoice = move_form.save()
|
||||||
invoice.post()
|
invoice.action_post()
|
||||||
|
|
||||||
def _get_report_lines(self, taxgroups=False):
|
def _get_report_lines(self, taxgroups=False):
|
||||||
based_on = "taxtags"
|
based_on = "taxtags"
|
||||||
|
|
|
@ -86,12 +86,11 @@
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<act_window
|
<record id="action_aged_partner_balance_wizard" model="ir.actions.act_window">
|
||||||
id="action_aged_partner_balance_wizard"
|
<field name="name">Aged Partner Balance</field>
|
||||||
name="Aged Partner Balance"
|
<field name="res_model">aged.partner.balance.report.wizard</field>
|
||||||
res_model="aged.partner.balance.report.wizard"
|
<field name="view_mode">form</field>
|
||||||
view_mode="form"
|
<field name="view_id" ref="aged_partner_balance_wizard" />
|
||||||
view_id="aged_partner_balance_wizard"
|
<field name="target">new</field>
|
||||||
target="new"
|
</record>
|
||||||
/>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
@ -12,6 +12,7 @@ from ast import literal_eval
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
from odoo.tools import date_utils
|
||||||
|
|
||||||
|
|
||||||
class GeneralLedgerReportWizard(models.TransientModel):
|
class GeneralLedgerReportWizard(models.TransientModel):
|
||||||
|
@ -146,8 +147,12 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||||
def _compute_fy_start_date(self):
|
def _compute_fy_start_date(self):
|
||||||
for wiz in self:
|
for wiz in self:
|
||||||
if wiz.date_from:
|
if wiz.date_from:
|
||||||
res = self.company_id.compute_fiscalyear_dates(wiz.date_from)
|
date_from, date_to = date_utils.get_fiscal_year(
|
||||||
wiz.fy_start_date = res["date_from"]
|
wiz.date_from,
|
||||||
|
day=self.company_id.fiscalyear_last_day,
|
||||||
|
month=int(self.company_id.fiscalyear_last_month),
|
||||||
|
)
|
||||||
|
wiz.fy_start_date = date_from
|
||||||
else:
|
else:
|
||||||
wiz.fy_start_date = False
|
wiz.fy_start_date = False
|
||||||
|
|
||||||
|
|
|
@ -153,26 +153,31 @@
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<act_window
|
<record id="action_general_ledger_wizard" model="ir.actions.act_window">
|
||||||
id="action_general_ledger_wizard"
|
<field name="name">General Ledger</field>
|
||||||
name="General Ledger"
|
<field name="res_model">general.ledger.report.wizard</field>
|
||||||
res_model="general.ledger.report.wizard"
|
<field name="view_mode">form</field>
|
||||||
view_mode="form"
|
<field name="view_id" ref="general_ledger_wizard" />
|
||||||
view_id="general_ledger_wizard"
|
<field name="target">new</field>
|
||||||
target="new"
|
</record>
|
||||||
/>
|
|
||||||
<!--Add to res.partner action-->
|
<!--Add to res.partner action-->
|
||||||
<act_window
|
<record
|
||||||
id="act_action_general_ledger_wizard_partner_relation"
|
id="act_action_general_ledger_wizard_partner_relation"
|
||||||
name="General Ledger"
|
model="ir.actions.act_window"
|
||||||
res_model="general.ledger.report.wizard"
|
>
|
||||||
binding_model="res.partner"
|
<field name="name">General Ledger</field>
|
||||||
view_mode="form"
|
<field name="res_model">general.ledger.report.wizard</field>
|
||||||
context="{
|
<field name="binding_model_id" ref="base.model_res_partner" />
|
||||||
'default_receivable_accounts_only':1,
|
<field name="view_mode">form</field>
|
||||||
'default_payable_accounts_only':1,
|
<field name="view_id" ref="general_ledger_wizard" />
|
||||||
}"
|
<field
|
||||||
groups="account.group_account_manager"
|
name="context"
|
||||||
target="new"
|
eval="{
|
||||||
/>
|
'default_receivable_accounts_only':1,
|
||||||
|
'default_payable_accounts_only':1,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<field name="groups_id" eval="[(4, ref('account.group_account_manager'))]" />
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
@ -64,12 +64,11 @@
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<act_window
|
<record id="action_journal_ledger_wizard" model="ir.actions.act_window">
|
||||||
id="action_journal_ledger_wizard"
|
<field name="name">Journal Ledger</field>
|
||||||
name="Journal Ledger"
|
<field name="res_model">journal.ledger.report.wizard</field>
|
||||||
res_model="journal.ledger.report.wizard"
|
<field name="view_mode">form</field>
|
||||||
view_mode="form"
|
<field name="view_id" ref="journal_ledger_wizard" />
|
||||||
view_id="journal_ledger_wizard"
|
<field name="target">new</field>
|
||||||
target="new"
|
</record>
|
||||||
/>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
@ -87,26 +87,31 @@
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<act_window
|
<record id="action_open_items_wizard" model="ir.actions.act_window">
|
||||||
id="action_open_items_wizard"
|
<field name="name">Open Itemsr</field>
|
||||||
name="Open Items"
|
<field name="res_model">open.items.report.wizard</field>
|
||||||
res_model="open.items.report.wizard"
|
<field name="view_mode">form</field>
|
||||||
view_mode="form"
|
<field name="view_id" ref="open_items_wizard" />
|
||||||
view_id="open_items_wizard"
|
<field name="target">new</field>
|
||||||
target="new"
|
</record>
|
||||||
/>
|
|
||||||
<!--Add to res.partner action-->
|
<!--Add to res.partner action-->
|
||||||
<act_window
|
<record
|
||||||
id="act_action_open_items_wizard_partner_relation"
|
id="act_action_open_items_wizard_partner_relation"
|
||||||
name="Open Items Partner"
|
model="ir.actions.act_window"
|
||||||
res_model="open.items.report.wizard"
|
>
|
||||||
binding_model="res.partner"
|
<field name="name">Open Items Partner</field>
|
||||||
view_mode="form"
|
<field name="res_model">open.items.report.wizard</field>
|
||||||
context="{
|
<field name="binding_model_id" ref="base.model_res_partner" />
|
||||||
'default_receivable_accounts_only':1,
|
<field name="view_mode">form</field>
|
||||||
'default_payable_accounts_only':1,
|
<field name="view_id" ref="general_ledger_wizard" />
|
||||||
}"
|
<field
|
||||||
groups="account.group_account_manager"
|
name="context"
|
||||||
target="new"
|
eval="{
|
||||||
/>
|
'default_receivable_accounts_only':1,
|
||||||
|
'default_payable_accounts_only':1,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<field name="groups_id" eval="[(4, ref('account.group_account_manager'))]" />
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import UserError, ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
|
from odoo.tools import date_utils
|
||||||
|
|
||||||
|
|
||||||
class TrialBalanceReportWizard(models.TransientModel):
|
class TrialBalanceReportWizard(models.TransientModel):
|
||||||
|
@ -118,8 +119,12 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||||
def _compute_fy_start_date(self):
|
def _compute_fy_start_date(self):
|
||||||
for wiz in self:
|
for wiz in self:
|
||||||
if wiz.date_from:
|
if wiz.date_from:
|
||||||
res = self.company_id.compute_fiscalyear_dates(wiz.date_from)
|
date_from, date_to = date_utils.get_fiscal_year(
|
||||||
wiz.fy_start_date = res["date_from"]
|
wiz.date_from,
|
||||||
|
day=self.company_id.fiscalyear_last_day,
|
||||||
|
month=int(self.company_id.fiscalyear_last_month),
|
||||||
|
)
|
||||||
|
wiz.fy_start_date = date_from
|
||||||
else:
|
else:
|
||||||
wiz.fy_start_date = False
|
wiz.fy_start_date = False
|
||||||
|
|
||||||
|
|
|
@ -147,12 +147,11 @@
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<act_window
|
<record id="action_trial_balance_wizard" model="ir.actions.act_window">
|
||||||
id="action_trial_balance_wizard"
|
<field name="name">Trial Balance</field>
|
||||||
name="Trial Balance"
|
<field name="res_model">trial.balance.report.wizard</field>
|
||||||
res_model="trial.balance.report.wizard"
|
<field name="view_mode">form</field>
|
||||||
view_mode="form"
|
<field name="view_id" ref="trial_balance_wizard" />
|
||||||
view_id="trial_balance_wizard"
|
<field name="target">new</field>
|
||||||
target="new"
|
</record>
|
||||||
/>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
@ -50,12 +50,11 @@
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<act_window
|
<record id="action_vat_report_wizard" model="ir.actions.act_window">
|
||||||
id="action_vat_report_wizard"
|
<field name="name">VAT Report</field>
|
||||||
name="VAT Report"
|
<field name="res_model">vat.report.wizard</field>
|
||||||
res_model="vat.report.wizard"
|
<field name="view_mode">form</field>
|
||||||
view_mode="form"
|
<field name="view_id" ref="vat_report_wizard" />
|
||||||
view_id="vat_report_wizard"
|
<field name="target">new</field>
|
||||||
target="new"
|
</record>
|
||||||
/>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
Loading…
Reference in New Issue