Browse Source

[IMP] format xlsx to global files

14.0
Saran440 4 years ago
parent
commit
97e530adeb
  1. 10
      report_xlsx_helper/README.rst
  2. 5
      report_xlsx_helper/controllers/main.py
  3. 1
      report_xlsx_helper/report/__init__.py
  4. 373
      report_xlsx_helper/report/report_xlsx_abstract.py
  5. 164
      report_xlsx_helper/report/report_xlsx_format.py
  6. 11
      report_xlsx_helper/report/test_partner_report_xlsx.py
  7. 6
      report_xlsx_helper/static/description/index.html

10
report_xlsx_helper/README.rst

@ -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|
@ -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.
@ -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
report_xlsx_helper/controllers/main.py

@ -28,12 +28,7 @@ class ReportController(ReportController):
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

1
report_xlsx_helper/report/__init__.py

@ -1,2 +1,3 @@
from . import report_xlsx_format
from . import report_xlsx_abstract
from . import test_partner_report_xlsx

373
report_xlsx_helper/report/report_xlsx_abstract.py

@ -10,7 +10,7 @@ from xlsxwriter.utility import xl_rowcol_to_cell
from odoo import _, fields, models
from odoo.exceptions import UserError
_xxx = {}
from .report_xlsx_format import FORMATS, XLS_HEADERS
class ReportXlsxAbstract(models.AbstractModel):
@ -79,11 +79,11 @@ class ReportXlsxAbstract(models.AbstractModel):
"font_size": 8,
"font_style": "I", # B: Bold, I: Italic, U: Underline
}
self.xls_headers = {"standard": ""}
XLS_HEADERS["xls_headers"] = {"standard": ""}
report_date = fields.Datetime.context_timestamp(
self.env.user, datetime.now()
).strftime("%Y-%m-%d %H:%M")
self.xls_footers = {
XLS_HEADERS["xls_footers"] = {
"standard": (
"&L&%(font_size)s&%(font_style)s"
+ report_date
@ -103,6 +103,7 @@ class ReportXlsxAbstract(models.AbstractModel):
border_grey = "#D3D3D3"
border = {"border": True, "border_color": border_grey}
theader = dict(border, bold=True)
bg_grey = "#CCCCCC"
bg_yellow = "#FFFFCC"
bg_blue = "#CCFFFF"
num_format = "#,##0.00"
@ -112,411 +113,495 @@ class ReportXlsxAbstract(models.AbstractModel):
int_format = "#,##0"
int_format_conditional = "{0};[Red]-{0};{0}".format(int_format)
date_format = "YYYY-MM-DD"
theader_grey = dict(theader, bg_color=bg_grey)
theader_yellow = dict(theader, bg_color=bg_yellow)
theader_blue = dict(theader, bg_color=bg_blue)
# format for worksheet title
self.format_ws_title = workbook.add_format({"bold": True, "font_size": 14})
FORMATS["format_ws_title"] = workbook.add_format(
{"bold": True, "font_size": 14}
)
# no border formats
self.format_left = workbook.add_format({"align": "left"})
self.format_center = workbook.add_format({"align": "center"})
self.format_right = workbook.add_format({"align": "right"})
self.format_amount_left = workbook.add_format(
FORMATS["format_left"] = workbook.add_format({"align": "left"})
FORMATS["format_center"] = workbook.add_format({"align": "center"})
FORMATS["format_right"] = workbook.add_format({"align": "right"})
FORMATS["format_amount_left"] = workbook.add_format(
{"align": "left", "num_format": num_format}
)
self.format_amount_center = workbook.add_format(
FORMATS["format_amount_center"] = workbook.add_format(
{"align": "center", "num_format": num_format}
)
self.format_amount_right = workbook.add_format(
FORMATS["format_amount_right"] = workbook.add_format(
{"align": "right", "num_format": num_format}
)
self.format_amount_conditional_left = workbook.add_format(
FORMATS["format_amount_conditional_left"] = workbook.add_format(
{"align": "left", "num_format": num_format_conditional}
)
self.format_amount_conditional_center = workbook.add_format(
FORMATS["format_amount_conditional_center"] = workbook.add_format(
{"align": "center", "num_format": num_format_conditional}
)
self.format_amount_conditional_right = workbook.add_format(
FORMATS["format_amount_conditional_right"] = workbook.add_format(
{"align": "right", "num_format": num_format_conditional}
)
self.format_percent_left = workbook.add_format(
FORMATS["format_percent_left"] = workbook.add_format(
{"align": "left", "num_format": pct_format}
)
self.format_percent_center = workbook.add_format(
FORMATS["format_percent_center"] = workbook.add_format(
{"align": "center", "num_format": pct_format}
)
self.format_percent_right = workbook.add_format(
FORMATS["format_percent_right"] = workbook.add_format(
{"align": "right", "num_format": pct_format}
)
self.format_percent_conditional_left = workbook.add_format(
FORMATS["format_percent_conditional_left"] = workbook.add_format(
{"align": "left", "num_format": pct_format_conditional}
)
self.format_percent_conditional_center = workbook.add_format(
FORMATS["format_percent_conditional_center"] = workbook.add_format(
{"align": "center", "num_format": pct_format_conditional}
)
self.format_percent_conditional_right = workbook.add_format(
FORMATS["format_percent_conditional_right"] = workbook.add_format(
{"align": "right", "num_format": pct_format_conditional}
)
self.format_integer_left = workbook.add_format(
FORMATS["format_integer_left"] = workbook.add_format(
{"align": "left", "num_format": int_format}
)
self.format_integer_center = workbook.add_format(
FORMATS["format_integer_center"] = workbook.add_format(
{"align": "center", "num_format": int_format}
)
self.format_integer_right = workbook.add_format(
FORMATS["format_integer_right"] = workbook.add_format(
{"align": "right", "num_format": int_format}
)
self.format_integer_conditional_left = workbook.add_format(
FORMATS["format_integer_conditional_left"] = workbook.add_format(
{"align": "right", "num_format": int_format_conditional}
)
self.format_integer_conditional_center = workbook.add_format(
FORMATS["format_integer_conditional_center"] = workbook.add_format(
{"align": "center", "num_format": int_format_conditional}
)
self.format_integer_conditional_right = workbook.add_format(
FORMATS["format_integer_conditional_right"] = workbook.add_format(
{"align": "right", "num_format": int_format_conditional}
)
self.format_date_left = workbook.add_format(
FORMATS["format_date_left"] = workbook.add_format(
{"align": "left", "num_format": date_format}
)
self.format_date_center = workbook.add_format(
FORMATS["format_date_center"] = workbook.add_format(
{"align": "center", "num_format": date_format}
)
self.format_date_right = workbook.add_format(
FORMATS["format_date_right"] = workbook.add_format(
{"align": "right", "num_format": date_format}
)
self.format_left_bold = workbook.add_format({"align": "left", "bold": True})
self.format_center_bold = workbook.add_format({"align": "center", "bold": True})
self.format_right_bold = workbook.add_format({"align": "right", "bold": True})
self.format_amount_left_bold = workbook.add_format(
FORMATS["format_left_bold"] = workbook.add_format(
{"align": "left", "bold": True}
)
FORMATS["format_center_bold"] = workbook.add_format(
{"align": "center", "bold": True}
)
FORMATS["format_right_bold"] = workbook.add_format(
{"align": "right", "bold": True}
)
FORMATS["format_amount_left_bold"] = workbook.add_format(
{"align": "left", "bold": True, "num_format": num_format}
)
self.format_amount_center_bold = workbook.add_format(
FORMATS["format_amount_center_bold"] = workbook.add_format(
{"align": "center", "bold": True, "num_format": num_format}
)
self.format_amount_right_bold = workbook.add_format(
FORMATS["format_amount_right_bold"] = workbook.add_format(
{"align": "right", "bold": True, "num_format": num_format}
)
self.format_amount_conditional_left_bold = workbook.add_format(
FORMATS["format_amount_conditional_left_bold"] = workbook.add_format(
{"align": "left", "bold": True, "num_format": num_format_conditional}
)
self.format_amount_conditional_center_bold = workbook.add_format(
FORMATS["format_amount_conditional_center_bold"] = workbook.add_format(
{"align": "center", "bold": True, "num_format": num_format_conditional}
)
self.format_amount_conditional_right_bold = workbook.add_format(
FORMATS["format_amount_conditional_right_bold"] = workbook.add_format(
{"align": "right", "bold": True, "num_format": num_format_conditional}
)
self.format_percent_left_bold = workbook.add_format(
FORMATS["format_percent_left_bold"] = workbook.add_format(
{"align": "left", "bold": True, "num_format": pct_format}
)
self.format_percent_center_bold = workbook.add_format(
FORMATS["format_percent_center_bold"] = workbook.add_format(
{"align": "center", "bold": True, "num_format": pct_format}
)
self.format_percent_right_bold = workbook.add_format(
FORMATS["format_percent_right_bold"] = workbook.add_format(
{"align": "right", "bold": True, "num_format": pct_format}
)
self.format_percent_conditional_left_bold = workbook.add_format(
FORMATS["format_percent_conditional_left_bold"] = workbook.add_format(
{"align": "left", "bold": True, "num_format": pct_format_conditional}
)
self.format_percent_conditional_center_bold = workbook.add_format(
FORMATS["format_percent_conditional_center_bold"] = workbook.add_format(
{"align": "center", "bold": True, "num_format": pct_format_conditional}
)
self.format_percent_conditional_right_bold = workbook.add_format(
FORMATS["format_percent_conditional_right_bold"] = workbook.add_format(
{"align": "right", "bold": True, "num_format": pct_format_conditional}
)
self.format_integer_left_bold = workbook.add_format(
FORMATS["format_integer_left_bold"] = workbook.add_format(
{"align": "left", "bold": True, "num_format": int_format}
)
self.format_integer_center_bold = workbook.add_format(
FORMATS["format_integer_center_bold"] = workbook.add_format(
{"align": "center", "bold": True, "num_format": int_format}
)
self.format_integer_right_bold = workbook.add_format(
FORMATS["format_integer_right_bold"] = workbook.add_format(
{"align": "right", "bold": True, "num_format": int_format}
)
self.format_integer_conditional_left_bold = workbook.add_format(
FORMATS["format_integer_conditional_left_bold"] = workbook.add_format(
{"align": "left", "bold": True, "num_format": int_format_conditional}
)
self.format_integer_conditional_center_bold = workbook.add_format(
FORMATS["format_integer_conditional_center_bold"] = workbook.add_format(
{"align": "center", "bold": True, "num_format": int_format_conditional}
)
self.format_integer_conditional_right_bold = workbook.add_format(
FORMATS["format_integer_conditional_right_bold"] = workbook.add_format(
{"align": "right", "bold": True, "num_format": int_format_conditional}
)
self.format_date_left_bold = workbook.add_format(
FORMATS["format_date_left_bold"] = workbook.add_format(
{"align": "left", "bold": True, "num_format": date_format}
)
self.format_date_center_bold = workbook.add_format(
FORMATS["format_date_center_bold"] = workbook.add_format(
{"align": "center", "bold": True, "num_format": date_format}
)
self.format_date_right_bold = workbook.add_format(
FORMATS["format_date_right_bold"] = workbook.add_format(
{"align": "right", "bold": True, "num_format": date_format}
)
# formats for worksheet table column headers
self.format_theader_yellow_left = workbook.add_format(theader_yellow)
self.format_theader_yellow_center = workbook.add_format(
FORMATS["format_theader_grey_left"] = workbook.add_format(theader_grey)
FORMATS["format_theader_grey_center"] = workbook.add_format(
dict(theader_grey, align="center")
)
FORMATS["format_theader_grey_right"] = workbook.add_format(
dict(theader_grey, align="right")
)
FORMATS["format_theader_grey_amount_left"] = workbook.add_format(
dict(theader_grey, num_format=num_format, align="left")
)
FORMATS["format_theader_grey_amount_center"] = workbook.add_format(
dict(theader_grey, num_format=num_format, align="center")
)
FORMATS["format_theader_grey_amount_right"] = workbook.add_format(
dict(theader_grey, num_format=num_format, align="right")
)
FORMATS["format_theader_grey_amount_conditional_left"] = workbook.add_format(
dict(theader_grey, num_format=num_format_conditional, align="left")
)
FORMATS["format_theader_grey_amount_conditional_center"] = workbook.add_format(
dict(theader_grey, num_format=num_format_conditional, align="center")
)
FORMATS["format_theader_grey_amount_conditional_right"] = workbook.add_format(
dict(theader_grey, num_format=num_format_conditional, align="right")
)
FORMATS["format_theader_grey_percent_left"] = workbook.add_format(
dict(theader_grey, num_format=pct_format, align="left")
)
FORMATS["format_theader_grey_percent_center"] = workbook.add_format(
dict(theader_grey, num_format=pct_format, align="center")
)
FORMATS["format_theader_grey_percent_right"] = workbook.add_format(
dict(theader_grey, num_format=pct_format, align="right")
)
FORMATS["format_theader_grey_percent_conditional_left"] = workbook.add_format(
dict(theader_grey, num_format=pct_format_conditional, align="left")
)
FORMATS["format_theader_grey_percent_conditional_center"] = workbook.add_format(
dict(theader_grey, num_format=pct_format_conditional, align="center")
)
FORMATS["format_theader_grey_percent_conditional_right"] = workbook.add_format(
dict(theader_grey, num_format=pct_format_conditional, align="right")
)
FORMATS["format_theader_grey_integer_left"] = workbook.add_format(
dict(theader_grey, num_format=int_format, align="left")
)
FORMATS["format_theader_grey_integer_center"] = workbook.add_format(
dict(theader_grey, num_format=int_format, align="center")
)
FORMATS["format_theader_grey_integer_right"] = workbook.add_format(
dict(theader_grey, num_format=int_format, align="right")
)
FORMATS["format_theader_grey_integer_conditional_left"] = workbook.add_format(
dict(theader_grey, num_format=int_format_conditional, align="left")
)
FORMATS["format_theader_grey_integer_conditional_center"] = workbook.add_format(
dict(theader_grey, num_format=int_format_conditional, align="center")
)
FORMATS["format_theader_grey_integer_conditional_right"] = workbook.add_format(
dict(theader_grey, num_format=int_format_conditional, align="right")
)
FORMATS["format_theader_yellow_left"] = workbook.add_format(theader_yellow)
FORMATS["format_theader_yellow_center"] = workbook.add_format(
dict(theader_yellow, align="center")
)
self.format_theader_yellow_right = workbook.add_format(
FORMATS["format_theader_yellow_right"] = workbook.add_format(
dict(theader_yellow, align="right")
)
self.format_theader_yellow_amount_left = workbook.add_format(
FORMATS["format_theader_yellow_amount_left"] = workbook.add_format(
dict(theader_yellow, num_format=num_format, align="left")
)
self.format_theader_yellow_amount_center = workbook.add_format(
FORMATS["format_theader_yellow_amount_center"] = workbook.add_format(
dict(theader_yellow, num_format=num_format, align="center")
)
self.format_theader_yellow_amount_right = workbook.add_format(
FORMATS["format_theader_yellow_amount_right"] = workbook.add_format(
dict(theader_yellow, num_format=num_format, align="right")
)
self.format_theader_yellow_amount_conditional_left = workbook.add_format(
FORMATS["format_theader_yellow_amount_conditional_left"] = workbook.add_format(
dict(theader_yellow, num_format=num_format_conditional, align="left")
)
self.format_theader_yellow_amount_conditional_center = workbook.add_format(
FORMATS[
"format_theader_yellow_amount_conditional_center"
] = workbook.add_format(
dict(theader_yellow, num_format=num_format_conditional, align="center")
)
self.format_theader_yellow_amount_conditional_right = workbook.add_format(
FORMATS["format_theader_yellow_amount_conditional_right"] = workbook.add_format(
dict(theader_yellow, num_format=num_format_conditional, align="right")
)
self.format_theader_yellow_percent_left = workbook.add_format(
FORMATS["format_theader_yellow_percent_left"] = workbook.add_format(
dict(theader_yellow, num_format=pct_format, align="left")
)
self.format_theader_yellow_percent_center = workbook.add_format(
FORMATS["format_theader_yellow_percent_center"] = workbook.add_format(
dict(theader_yellow, num_format=pct_format, align="center")
)
self.format_theader_yellow_percent_right = workbook.add_format(
FORMATS["format_theader_yellow_percent_right"] = workbook.add_format(
dict(theader_yellow, num_format=pct_format, align="right")
)
self.format_theader_yellow_percent_conditional_left = workbook.add_format(
FORMATS["format_theader_yellow_percent_conditional_left"] = workbook.add_format(
dict(theader_yellow, num_format=pct_format_conditional, align="left")
)
self.format_theader_yellow_percent_conditional_center = workbook.add_format(
FORMATS[
"format_theader_yellow_percent_conditional_center"
] = workbook.add_format(
dict(theader_yellow, num_format=pct_format_conditional, align="center")
)
self.format_theader_yellow_percent_conditional_right = workbook.add_format(
FORMATS[
"format_theader_yellow_percent_conditional_right"
] = workbook.add_format(
dict(theader_yellow, num_format=pct_format_conditional, align="right")
)
self.format_theader_yellow_integer_left = workbook.add_format(
FORMATS["format_theader_yellow_integer_left"] = workbook.add_format(
dict(theader_yellow, num_format=int_format, align="left")
)
self.format_theader_yellow_integer_center = workbook.add_format(
FORMATS["format_theader_yellow_integer_center"] = workbook.add_format(
dict(theader_yellow, num_format=int_format, align="center")
)
self.format_theader_yellow_integer_right = workbook.add_format(
FORMATS["format_theader_yellow_integer_right"] = workbook.add_format(
dict(theader_yellow, num_format=int_format, align="right")
)
self.format_theader_yellow_integer_conditional_left = workbook.add_format(
FORMATS["format_theader_yellow_integer_conditional_left"] = workbook.add_format(
dict(theader_yellow, num_format=int_format_conditional, align="left")
)
self.format_theader_yellow_integer_conditional_center = workbook.add_format(
FORMATS[
"format_theader_yellow_integer_conditional_center"
] = workbook.add_format(
dict(theader_yellow, num_format=int_format_conditional, align="center")
)
self.format_theader_yellow_integer_conditional_right = workbook.add_format(
FORMATS[
"format_theader_yellow_integer_conditional_right"
] = workbook.add_format(
dict(theader_yellow, num_format=int_format_conditional, align="right")
)
self.format_theader_blue_left = workbook.add_format(theader_blue)
self.format_theader_blue_center = workbook.add_format(
FORMATS["format_theader_blue_left"] = workbook.add_format(theader_blue)
FORMATS["format_theader_blue_center"] = workbook.add_format(
dict(theader_blue, align="center")
)
self.format_theader_blue_right = workbook.add_format(
FORMATS["format_theader_blue_right"] = workbook.add_format(
dict(theader_blue, align="right")
)
self.format_theader_blue_amount_left = workbook.add_format(
FORMATS["format_theader_blue_amount_left"] = workbook.add_format(
dict(theader_blue, num_format=num_format, align="left")
)
self.format_theader_blue_amount_center = workbook.add_format(
FORMATS["format_theader_blue_amount_center"] = workbook.add_format(
dict(theader_blue, num_format=num_format, align="center")
)
self.format_theader_blue_amount_right = workbook.add_format(
FORMATS["format_theader_blue_amount_right"] = workbook.add_format(
dict(theader_blue, num_format=num_format, align="right")
)
self.format_theader_blue_amount_conditional_left = workbook.add_format(
FORMATS["format_theader_blue_amount_conditional_left"] = workbook.add_format(
dict(theader_blue, num_format=num_format_conditional, align="left")
)
self.format_theader_blue_amount_conditional_center = workbook.add_format(
FORMATS["format_theader_blue_amount_conditional_center"] = workbook.add_format(
dict(theader_blue, num_format=num_format_conditional, align="center")
)
self.format_theader_blue_amount_conditional_right = workbook.add_format(
FORMATS["format_theader_blue_amount_conditional_right"] = workbook.add_format(
dict(theader_blue, num_format=num_format_conditional, align="right")
)
self.format_theader_blue_percent_left = workbook.add_format(
FORMATS["format_theader_blue_percent_left"] = workbook.add_format(
dict(theader_blue, num_format=pct_format, align="left")
)
self.format_theader_blue_percent_center = workbook.add_format(
FORMATS["format_theader_blue_percent_center"] = workbook.add_format(
dict(theader_blue, num_format=pct_format, align="center")
)
self.format_theader_blue_percent_right = workbook.add_format(
FORMATS["format_theader_blue_percent_right"] = workbook.add_format(
dict(theader_blue, num_format=pct_format, align="right")
)
self.format_theader_blue_percent_conditional_left = workbook.add_format(
FORMATS["format_theader_blue_percent_conditional_left"] = workbook.add_format(
dict(theader_blue, num_format=pct_format_conditional, align="left")
)
self.format_theader_blue_percent_conditional_center = workbook.add_format(
FORMATS["format_theader_blue_percent_conditional_center"] = workbook.add_format(
dict(theader_blue, num_format=pct_format_conditional, align="center")
)
self.format_theader_blue_percent_conditional_right = workbook.add_format(
FORMATS["format_theader_blue_percent_conditional_right"] = workbook.add_format(
dict(theader_blue, num_format=pct_format_conditional, align="right")
)
self.format_theader_blue_integer_left = workbook.add_format(
FORMATS["format_theader_blue_integer_left"] = workbook.add_format(
dict(theader_blue, num_format=int_format, align="left")
)
self.format_theader_blue_integer_center = workbook.add_format(
FORMATS["format_theader_blue_integer_center"] = workbook.add_format(
dict(theader_blue, num_format=int_format, align="center")
)
self.format_theader_blue_integer_right = workbook.add_format(
FORMATS["format_theader_blue_integer_right"] = workbook.add_format(
dict(theader_blue, num_format=int_format, align="right")
)
self.format_theader_blue_integer_conditional_left = workbook.add_format(
FORMATS["format_theader_blue_integer_conditional_left"] = workbook.add_format(
dict(theader_blue, num_format=int_format_conditional, align="left")
)
self.format_theader_blue_integer_conditional_center = workbook.add_format(
FORMATS["format_theader_blue_integer_conditional_center"] = workbook.add_format(
dict(theader_blue, num_format=int_format_conditional, align="center")
)
self.format_theader_blue_integer_conditional_right = workbook.add_format(
FORMATS["format_theader_blue_integer_conditional_right"] = workbook.add_format(
dict(theader_blue, num_format=int_format_conditional, align="right")
)
# formats for worksheet table cells
self.format_tcell_left = workbook.add_format(dict(border, align="left"))
self.format_tcell_center = workbook.add_format(dict(border, align="center"))
self.format_tcell_right = workbook.add_format(dict(border, align="right"))
self.format_tcell_amount_left = workbook.add_format(
FORMATS["format_tcell_left"] = workbook.add_format(dict(border, align="left"))
FORMATS["format_tcell_center"] = workbook.add_format(
dict(border, align="center")
)
FORMATS["format_tcell_right"] = workbook.add_format(dict(border, align="right"))
FORMATS["format_tcell_amount_left"] = workbook.add_format(
dict(border, num_format=num_format, align="left")
)
self.format_tcell_amount_center = workbook.add_format(
FORMATS["format_tcell_amount_center"] = workbook.add_format(
dict(border, num_format=num_format, align="center")
)
self.format_tcell_amount_right = workbook.add_format(
FORMATS["format_tcell_amount_right"] = workbook.add_format(
dict(border, num_format=num_format, align="right")
)
self.format_tcell_amount_conditional_left = workbook.add_format(
FORMATS["format_tcell_amount_conditional_left"] = workbook.add_format(
dict(border, num_format=num_format_conditional, align="left")
)
self.format_tcell_amount_conditional_center = workbook.add_format(
FORMATS["format_tcell_amount_conditional_center"] = workbook.add_format(
dict(border, num_format=num_format_conditional, align="center")
)
self.format_tcell_amount_conditional_right = workbook.add_format(
FORMATS["format_tcell_amount_conditional_right"] = workbook.add_format(
dict(border, num_format=num_format_conditional, align="right")
)
self.format_tcell_percent_left = workbook.add_format(
FORMATS["format_tcell_percent_left"] = workbook.add_format(
dict(border, num_format=pct_format, align="left")
)
self.format_tcell_percent_center = workbook.add_format(
FORMATS["format_tcell_percent_center"] = workbook.add_format(
dict(border, num_format=pct_format, align="center")
)
self.format_tcell_percent_right = workbook.add_format(
FORMATS["format_tcell_percent_right"] = workbook.add_format(
dict(border, num_format=pct_format, align="right")
)
self.format_tcell_percent_conditional_left = workbook.add_format(
FORMATS["format_tcell_percent_conditional_left"] = workbook.add_format(
dict(border, num_format=pct_format_conditional, align="left")
)
self.format_tcell_percent_conditional_center = workbook.add_format(
FORMATS["format_tcell_percent_conditional_center"] = workbook.add_format(
dict(border, num_format=pct_format_conditional, align="center")
)
self.format_tcell_percent_conditional_right = workbook.add_format(
FORMATS["format_tcell_percent_conditional_right"] = workbook.add_format(
dict(border, num_format=pct_format_conditional, align="right")
)
self.format_tcell_integer_left = workbook.add_format(
FORMATS["format_tcell_integer_left"] = workbook.add_format(
dict(border, num_format=int_format, align="left")
)
self.format_tcell_integer_center = workbook.add_format(
FORMATS["format_tcell_integer_center"] = workbook.add_format(
dict(border, num_format=int_format, align="center")
)
self.format_tcell_integer_right = workbook.add_format(
FORMATS["format_tcell_integer_right"] = workbook.add_format(
dict(border, num_format=int_format, align="right")
)
self.format_tcell_integer_conditional_left = workbook.add_format(
FORMATS["format_tcell_integer_conditional_left"] = workbook.add_format(
dict(border, num_format=int_format_conditional, align="left")
)
self.format_tcell_integer_conditional_center = workbook.add_format(
FORMATS["format_tcell_integer_conditional_center"] = workbook.add_format(
dict(border, num_format=int_format_conditional, align="center")
)
self.format_tcell_integer_conditional_right = workbook.add_format(
FORMATS["format_tcell_integer_conditional_right"] = workbook.add_format(
dict(border, num_format=int_format_conditional, align="right")
)
self.format_tcell_date_left = workbook.add_format(
FORMATS["format_tcell_date_left"] = workbook.add_format(
dict(border, num_format=date_format, align="left")
)
self.format_tcell_date_center = workbook.add_format(
FORMATS["format_tcell_date_center"] = workbook.add_format(
dict(border, num_format=date_format, align="center")
)
self.format_tcell_date_right = workbook.add_format(
FORMATS["format_tcell_date_right"] = workbook.add_format(
dict(border, num_format=date_format, align="right")
)
self.format_tcell_left_bold = workbook.add_format(
FORMATS["format_tcell_left_bold"] = workbook.add_format(
dict(border, align="left", bold=True)
)
self.format_tcell_center_bold = workbook.add_format(
FORMATS["format_tcell_center_bold"] = workbook.add_format(
dict(border, align="center", bold=True)
)
self.format_tcell_right_bold = workbook.add_format(
FORMATS["format_tcell_right_bold"] = workbook.add_format(
dict(border, align="right", bold=True)
)
self.format_tcell_amount_left_bold = workbook.add_format(
FORMATS["format_tcell_amount_left_bold"] = workbook.add_format(
dict(border, num_format=num_format, align="left", bold=True)
)
self.format_tcell_amount_center_bold = workbook.add_format(
FORMATS["format_tcell_amount_center_bold"] = workbook.add_format(
dict(border, num_format=num_format, align="center", bold=True)
)
self.format_tcell_amount_right_bold = workbook.add_format(
FORMATS["format_tcell_amount_right_bold"] = workbook.add_format(
dict(border, num_format=num_format, align="right", bold=True)
)
self.format_tcell_amount_conditional_left_bold = workbook.add_format(
FORMATS["format_tcell_amount_conditional_left_bold"] = workbook.add_format(
dict(border, num_format=num_format_conditional, align="left", bold=True)
)
self.format_tcell_amount_conditional_center_bold = workbook.add_format(
FORMATS["format_tcell_amount_conditional_center_bold"] = workbook.add_format(
dict(border, num_format=num_format_conditional, align="center", bold=True)
)
self.format_tcell_amount_conditional_right_bold = workbook.add_format(
FORMATS["format_tcell_amount_conditional_right_bold"] = workbook.add_format(
dict(border, num_format=num_format_conditional, align="right", bold=True)
)
self.format_tcell_percent_left_bold = workbook.add_format(
FORMATS["format_tcell_percent_left_bold"] = workbook.add_format(
dict(border, num_format=pct_format, align="left", bold=True)
)
self.format_tcell_percent_center_bold = workbook.add_format(
FORMATS["format_tcell_percent_center_bold"] = workbook.add_format(
dict(border, num_format=pct_format, align="center", bold=True)
)
self.format_tcell_percent_right_bold = workbook.add_format(
FORMATS["format_tcell_percent_right_bold"] = workbook.add_format(
dict(border, num_format=pct_format, align="right", bold=True)
)
self.format_tcell_percent_conditional_left_bold = workbook.add_format(
FORMATS["format_tcell_percent_conditional_left_bold"] = workbook.add_format(
dict(border, num_format=pct_format_conditional, align="left", bold=True)
)
self.format_tcell_percent_conditional_center_bold = workbook.add_format(
FORMATS["format_tcell_percent_conditional_center_bold"] = workbook.add_format(
dict(border, num_format=pct_format_conditional, align="center", bold=True)
)
self.format_tcell_percent_conditional_right_bold = workbook.add_format(
FORMATS["format_tcell_percent_conditional_right_bold"] = workbook.add_format(
dict(border, num_format=pct_format_conditional, align="right", bold=True)
)
self.format_tcell_integer_left_bold = workbook.add_format(
FORMATS["format_tcell_integer_left_bold"] = workbook.add_format(
dict(border, num_format=int_format, align="left", bold=True)
)
self.format_tcell_integer_center_bold = workbook.add_format(
FORMATS["format_tcell_integer_center_bold"] = workbook.add_format(
dict(border, num_format=int_format, align="center", bold=True)
)
self.format_tcell_integer_right_bold = workbook.add_format(
FORMATS["format_tcell_integer_right_bold"] = workbook.add_format(
dict(border, num_format=int_format, align="right", bold=True)
)
self.format_tcell_integer_conditional_left_bold = workbook.add_format(
FORMATS["format_tcell_integer_conditional_left_bold"] = workbook.add_format(
dict(border, num_format=int_format_conditional, align="left", bold=True)
)
self.format_tcell_integer_conditional_center_bold = workbook.add_format(
FORMATS["format_tcell_integer_conditional_center_bold"] = workbook.add_format(
dict(border, num_format=int_format_conditional, align="center", bold=True)
)
self.format_tcell_integer_conditional_right_bold = workbook.add_format(
FORMATS["format_tcell_integer_conditional_right_bold"] = workbook.add_format(
dict(border, num_format=int_format_conditional, align="right", bold=True)
)
self.format_tcell_date_left_bold = workbook.add_format(
FORMATS["format_tcell_date_left_bold"] = workbook.add_format(
dict(border, num_format=date_format, align="left", bold=True)
)
self.format_tcell_date_center_bold = workbook.add_format(
FORMATS["format_tcell_date_center_bold"] = workbook.add_format(
dict(border, num_format=date_format, align="center", bold=True)
)
self.format_tcell_date_right_bold = workbook.add_format(
FORMATS["format_tcell_date_right_bold"] = workbook.add_format(
dict(border, num_format=date_format, align="right", bold=True)
)
@ -557,10 +642,10 @@ class ReportXlsxAbstract(models.AbstractModel):
wl = ws_params.get("wanted_list")
if wl and len(wl) > 1:
ws.merge_range(
row_pos, 0, row_pos, len(wl) - 1, title, self.format_ws_title
row_pos, 0, row_pos, len(wl) - 1, title, FORMATS["format_ws_title"]
)
else:
ws.write_string(row_pos, 0, title, self.format_ws_title)
ws.write_string(row_pos, 0, title, FORMATS["format_ws_title"])
return row_pos + 2
def _write_line(

164
report_xlsx_helper/report/report_xlsx_format.py

@ -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
report_xlsx_helper/report/test_partner_report_xlsx.py

@ -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
@ -47,9 +49,8 @@ class TestPartnerXlsx(models.AbstractModel):
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
@ -59,7 +60,7 @@ class TestPartnerXlsx(models.AbstractModel):
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)
@ -70,5 +71,5 @@ class TestPartnerXlsx(models.AbstractModel):
ws_params,
col_specs_section="data",
render_space={"partner": partner},
default_format=self.format_tcell_left,
default_format=FORMATS["format_tcell_left"],
)

6
report_xlsx_helper/static/description/index.html

@ -367,7 +367,7 @@ ul.auto-toc {
!! 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">
@ -424,7 +424,7 @@ from <a class="reference external" href="http://apps.odoo.com">http://apps.odoo.
<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">
@ -450,7 +450,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<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>

Loading…
Cancel
Save