Skip to content

Commit

Permalink
[IMP] format xlsx to global files
Browse files Browse the repository at this point in the history
  • Loading branch information
Saran440 committed Nov 23, 2020
1 parent e928294 commit 97e530a
Show file tree
Hide file tree
Showing 7 changed files with 408 additions and 162 deletions.
10 changes: 5 additions & 5 deletions report_xlsx_helper/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Report xlsx helpers
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
:target: https://github.com/OCA/reporting-engine/tree/13.0/report_xlsx_helper
:target: https://github.com/OCA/reporting-engine/tree/14.0/report_xlsx_helper
:alt: OCA/reporting-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/reporting-engine-13-0/reporting-engine-13-0-report_xlsx_helper
:target: https://translation.odoo-community.org/projects/reporting-engine-14-0/reporting-engine-14-0-report_xlsx_helper
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/143/13.0
:target: https://runbot.odoo-community.org/runbot/143/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -79,7 +79,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_xlsx_helper%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_xlsx_helper%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.

Expand Down Expand Up @@ -111,6 +111,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/13.0/report_xlsx_helper>`_ project on GitHub.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/14.0/report_xlsx_helper>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 0 additions & 5 deletions report_xlsx_helper/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ def report_routes(self, reportname, docids=None, converter=None, **data):
if data.get("options"):
data.update(json.loads(data.pop("options")))
if data.get("context"):
# Ignore 'lang' here, because the context in data is the one
# from the webclient *but* if the user explicitely wants to
# change the lang, this mechanism overwrites it.
data["context"] = json.loads(data["context"])
if data["context"].get("lang"):
del data["context"]["lang"]
context.update(data["context"])
context["report_name"] = reportname

Expand Down
1 change: 1 addition & 0 deletions report_xlsx_helper/report/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import report_xlsx_format
from . import report_xlsx_abstract
from . import test_partner_report_xlsx
373 changes: 229 additions & 144 deletions report_xlsx_helper/report/report_xlsx_abstract.py

Large diffs are not rendered by default.

164 changes: 164 additions & 0 deletions report_xlsx_helper/report/report_xlsx_format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# Global Formatting
XLS_HEADERS = {"xls_headers": "", "xls_footers": ""}
FORMATS = {
"format_ws_title": False,
"format_left": False,
"format_center": False,
"format_right": False,
"format_amount_left": False,
"format_amount_center": False,
"format_amount_right": False,
"format_amount_conditional_left": False,
"format_amount_conditional_center": False,
"format_amount_conditional_right": False,
"format_percent_left": False,
"format_percent_center": False,
"format_percent_right": False,
"format_percent_conditional_left": False,
"format_percent_conditional_center": False,
"format_percent_conditional_right": False,
"format_integer_left": False,
"format_integer_center": False,
"format_integer_right": False,
"format_integer_conditional_left": False,
"format_integer_conditional_center": False,
"format_integer_conditional_right": False,
"format_date_left": False,
"format_date_center": False,
"format_date_right": False,
"format_left_bold": False,
"format_center_bold": False,
"format_right_bold": False,
"format_amount_left_bold": False,
"format_amount_center_bold": False,
"format_amount_right_bold": False,
"format_amount_conditional_left_bold": False,
"format_amount_conditional_center_bold": False,
"format_amount_conditional_right_bold": False,
"format_percent_left_bold": False,
"format_percent_center_bold": False,
"format_percent_right_bold": False,
"format_percent_conditional_left_bold": False,
"format_percent_conditional_center_bold": False,
"format_percent_conditional_right_bold": False,
"format_integer_left_bold": False,
"format_integer_center_bold": False,
"format_integer_right_bold": False,
"format_integer_conditional_left_bold": False,
"format_integer_conditional_center_bold": False,
"format_integer_conditional_right_bold": False,
"format_date_left_bold": False,
"format_date_center_bold": False,
"format_date_right_bold": False,
"format_theader_grey_left": False,
"format_theader_grey_center": False,
"format_theader_grey_right": False,
"format_theader_grey_amount_left": False,
"format_theader_grey_amount_center": False,
"format_theader_grey_amount_right": False,
"format_theader_grey_amount_conditional_left": False,
"format_theader_grey_amount_conditional_center": False,
"format_theader_grey_amount_conditional_right": False,
"format_theader_grey_percent_left": False,
"format_theader_grey_percent_center": False,
"format_theader_grey_percent_right": False,
"format_theader_grey_percent_conditional_left": False,
"format_theader_grey_percent_conditional_center": False,
"format_theader_grey_percent_conditional_right": False,
"format_theader_grey_integer_left": False,
"format_theader_grey_integer_center": False,
"format_theader_grey_integer_right": False,
"format_theader_grey_integer_conditional_left": False,
"format_theader_grey_integer_conditional_center": False,
"format_theader_grey_integer_conditional_right": False,
"format_theader_yellow_left": False,
"format_theader_yellow_center": False,
"format_theader_yellow_right": False,
"format_theader_yellow_amount_left": False,
"format_theader_yellow_amount_center": False,
"format_theader_yellow_amount_right": False,
"format_theader_yellow_amount_conditional_left": False,
"format_theader_yellow_amount_conditional_center": False,
"format_theader_yellow_amount_conditional_right": False,
"format_theader_yellow_percent_left": False,
"format_theader_yellow_percent_center": False,
"format_theader_yellow_percent_right": False,
"format_theader_yellow_percent_conditional_left": False,
"format_theader_yellow_percent_conditional_center": False,
"format_theader_yellow_percent_conditional_right": False,
"format_theader_yellow_integer_left": False,
"format_theader_yellow_integer_center": False,
"format_theader_yellow_integer_right": False,
"format_theader_yellow_integer_conditional_left": False,
"format_theader_yellow_integer_conditional_center": False,
"format_theader_yellow_integer_conditional_right": False,
"format_theader_blue_left": False,
"format_theader_blue_center": False,
"format_theader_blue_right": False,
"format_theader_blue_amount_left": False,
"format_theader_blue_amount_center": False,
"format_theader_blue_amount_right": False,
"format_theader_blue_amount_conditional_left": False,
"format_theader_blue_amount_conditional_center": False,
"format_theader_blue_amount_conditional_right": False,
"format_theader_blue_percent_left": False,
"format_theader_blue_percent_center": False,
"format_theader_blue_percent_right": False,
"format_theader_blue_percent_conditional_left": False,
"format_theader_blue_percent_conditional_center": False,
"format_theader_blue_percent_conditional_right": False,
"format_theader_blue_integer_left": False,
"format_theader_blue_integer_center": False,
"format_theader_blue_integer_right": False,
"format_theader_blue_integer_conditional_left": False,
"format_theader_blue_integer_conditional_center": False,
"format_theader_blue_integer_conditional_right": False,
"format_tcell_left": False,
"format_tcell_center": False,
"format_tcell_right": False,
"format_tcell_amount_left": False,
"format_tcell_amount_center": False,
"format_tcell_amount_right": False,
"format_tcell_amount_conditional_left": False,
"format_tcell_amount_conditional_center": False,
"format_tcell_amount_conditional_right": False,
"format_tcell_percent_left": False,
"format_tcell_percent_center": False,
"format_tcell_percent_right": False,
"format_tcell_percent_conditional_left": False,
"format_tcell_percent_conditional_center": False,
"format_tcell_percent_conditional_right": False,
"format_tcell_integer_left": False,
"format_tcell_integer_center": False,
"format_tcell_integer_right": False,
"format_tcell_integer_conditional_left": False,
"format_tcell_integer_conditional_center": False,
"format_tcell_integer_conditional_right": False,
"format_tcell_date_left": False,
"format_tcell_date_center": False,
"format_tcell_date_right": False,
"format_tcell_left_bold": False,
"format_tcell_center_bold": False,
"format_tcell_right_bold": False,
"format_tcell_amount_left_bold": False,
"format_tcell_amount_center_bold": False,
"format_tcell_amount_right_bold": False,
"format_tcell_amount_conditional_left_bold": False,
"format_tcell_amount_conditional_center_bold": False,
"format_tcell_amount_conditional_right_bold": False,
"format_tcell_percent_left_bold": False,
"format_tcell_percent_center_bold": False,
"format_tcell_percent_right_bold": False,
"format_tcell_percent_conditional_left_bold": False,
"format_tcell_percent_conditional_center_bold": False,
"format_tcell_percent_conditional_right_bold": False,
"format_tcell_integer_left_bold": False,
"format_tcell_integer_center_bold": False,
"format_tcell_integer_right_bold": False,
"format_tcell_integer_conditional_left_bold": False,
"format_tcell_integer_conditional_center_bold": False,
"format_tcell_integer_conditional_right_bold": False,
"format_tcell_date_left_bold": False,
"format_tcell_date_center_bold": False,
"format_tcell_date_right_bold": False,
}
11 changes: 6 additions & 5 deletions report_xlsx_helper/report/test_partner_report_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from odoo import models

from .report_xlsx_format import FORMATS, XLS_HEADERS


# TODO:
# make PR to move this class as well as the report_xlsx test class
Expand Down Expand Up @@ -47,9 +49,8 @@ def _partner_report(self, workbook, ws, ws_params, data, partners):

ws.set_portrait()
ws.fit_to_pages(1, 0)
ws.set_header(self.xls_headers["standard"])
ws.set_footer(self.xls_footers["standard"])

ws.set_header(XLS_HEADERS["xls_headers"]["standard"])
ws.set_footer(XLS_HEADERS["xls_footers"]["standard"])
self._set_column_width(ws, ws_params)

row_pos = 0
Expand All @@ -59,7 +60,7 @@ def _partner_report(self, workbook, ws, ws_params, data, partners):
row_pos,
ws_params,
col_specs_section="header",
default_format=self.format_theader_yellow_left,
default_format=FORMATS["format_theader_yellow_left"],
)
ws.freeze_panes(row_pos, 0)

Expand All @@ -70,5 +71,5 @@ def _partner_report(self, workbook, ws, ws_params, data, partners):
ws_params,
col_specs_section="data",
render_space={"partner": partner},
default_format=self.format_tcell_left,
default_format=FORMATS["format_tcell_left"],
)
6 changes: 3 additions & 3 deletions report_xlsx_helper/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Report xlsx helpers</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/13.0/report_xlsx_helper"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/reporting-engine-13-0/reporting-engine-13-0-report_xlsx_helper"><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/143/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/reporting-engine/tree/14.0/report_xlsx_helper"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/reporting-engine-14-0/reporting-engine-14-0-report_xlsx_helper"><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/143/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module provides a set of tools to facilitate the creation of excel reports with format xlsx.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -424,7 +424,7 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_xlsx_helper%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/reporting-engine/issues/new?body=module:%20report_xlsx_helper%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>
</div>
<div class="section" id="credits">
Expand All @@ -450,7 +450,7 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/13.0/report_xlsx_helper">OCA/reporting-engine</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/14.0/report_xlsx_helper">OCA/reporting-engine</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down

0 comments on commit 97e530a

Please sign in to comment.