Browse Source

Merge pull request #1 from acsone/9.0-import_report_py3o

9.0 import report py3o
pull/80/head
Florent Aide 8 years ago
committed by GitHub
parent
commit
6e090ca2bc
  1. 56
      .gitignore
  2. 24
      .hgignore
  3. 15
      .hgtags
  4. 38
      .travis.yml
  5. 8
      LICENSE
  6. 43
      README.md
  7. 1
      __init__.py
  8. 55
      __openerp__.py
  9. 24
      base_report_assembler/__init__.py
  10. 49
      base_report_assembler/__openerp__.py
  11. 42
      base_report_assembler/assembled_report.py
  12. 36
      base_report_assembler/i18n/base_report_assembler.pot
  13. 37
      base_report_assembler/i18n/fr.po
  14. 110
      base_report_assembler/ir_report.py
  15. 126
      base_report_assembler/report_assembler.py
  16. 4
      models/__init__.py
  17. 18
      models/py3o_fusion_filetype.py
  18. 19
      models/py3o_server.py
  19. 28
      models/py3o_template.py
  20. 146
      py3o_report_modif.py
  21. 47
      report_custom_filename/README.rst
  22. 22
      report_custom_filename/__init__.py
  23. 44
      report_custom_filename/__openerp__.py
  24. 22
      report_custom_filename/controllers/__init__.py
  25. 68
      report_custom_filename/controllers/report_controller.py
  26. 53
      report_custom_filename/controllers/reports.py
  27. 34
      report_custom_filename/i18n/report_custom_filename.pot
  28. 21
      report_custom_filename/model/__init__.py
  29. 37
      report_custom_filename/model/ir_actions_report_xml.py
  30. BIN
      report_custom_filename/static/description/icon.png
  31. 14
      report_custom_filename/view/ir_actions_report_xml.xml
  32. 661
      report_py3o/LICENSE
  33. 0
      report_py3o/NEWS
  34. 18
      report_py3o/README.md
  35. 1
      report_py3o/__init__.py
  36. 35
      report_py3o/__openerp__.py
  37. 0
      report_py3o/data/py3o.fusion.filetype.csv
  38. 0
      report_py3o/i18n/fr.po
  39. 4
      report_py3o/models/__init__.py
  40. 77
      report_py3o/models/ir_report.py
  41. 13
      report_py3o/models/py3o_fusion_filetype.py
  42. 11
      report_py3o/models/py3o_server.py
  43. 19
      report_py3o/models/py3o_template.py
  44. 8
      report_py3o/py3o_parser.py
  45. 0
      report_py3o/security/ir.model.access.csv
  46. 2
      report_py3o/views/ir_report.xml
  47. 0
      report_py3o/views/menu.xml
  48. 0
      report_py3o/views/py3o_server.xml
  49. 0
      report_py3o/views/py3o_template.xml
  50. 77
      report_qweb_element_page_visibility/README.rst
  51. 3
      report_qweb_element_page_visibility/__init__.py
  52. 20
      report_qweb_element_page_visibility/__openerp__.py
  53. BIN
      report_qweb_element_page_visibility/static/description/icon.png
  54. 46
      report_qweb_element_page_visibility/views/layouts.xml
  55. 25
      report_xls/__init__.py
  56. 82
      report_xls/__openerp__.py
  57. 36
      report_xls/ir_report.py
  58. 248
      report_xls/report_xls.py
  59. BIN
      report_xls/static/description/help.png
  60. BIN
      report_xls/static/description/icon.png
  61. 84
      report_xls/static/description/index.html
  62. BIN
      report_xls/static/description/open_receivables.png
  63. 51
      report_xls/utils.py
  64. 87
      report_xlsx/README.rst
  65. 5
      report_xlsx/__init__.py
  66. 19
      report_xlsx/__openerp__.py
  67. 5
      report_xlsx/models/__init__.py
  68. 11
      report_xlsx/models/ir_report.py
  69. 4
      report_xlsx/report/__init__.py
  70. 45
      report_xlsx/report/report_xlsx.py
  71. BIN
      report_xlsx/static/description/icon.png
  72. 3
      requirements.txt
  73. 2
      setup/.setuptools-odoo-make-default-ignore
  74. 2
      setup/README
  75. 1
      setup/report_py3o/odoo_addons/__init__.py
  76. 1
      setup/report_py3o/odoo_addons/report_py3o
  77. 6
      setup/report_py3o/setup.py
  78. 1
      setup/report_qweb_element_page_visibility/odoo_addons/__init__.py
  79. 1
      setup/report_qweb_element_page_visibility/odoo_addons/report_qweb_element_page_visibility
  80. 6
      setup/report_qweb_element_page_visibility/setup.py
  81. 1
      setup/report_xlsx/odoo_addons/__init__.py
  82. 1
      setup/report_xlsx/odoo_addons/report_xlsx
  83. 6
      setup/report_xlsx/setup.py

56
.gitignore

@ -0,0 +1,56 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
# Pycharm
.idea
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# Rope
.ropeproject
# Sphinx documentation
docs/_build/
# Backup files
*~
*.swp

24
.hgignore

@ -1,24 +0,0 @@
syntax: glob
**/*.pyc
*.pyc
*.pyo
*.swp
.tmp*
*~
*.egg-info
dist/*
build/*
lib/*
output/*
*.orig
*.log
.settings/*
storage/*
.project
.idea
.pydevproject
*.db
.ropeproject/*
.mob

15
.hgtags

@ -1,15 +0,0 @@
ae59b92cb6bda5ada7fffd01d9006c800a6da9f4 TAG_1.0
392758bf61eb33256bc3a46e16ca15d6195bc8a8 TAG_1.1
b6c64ac6e39936d1ee13c58c14bf62b04c5b5202 TAG_1.2
cd840bda3fa0d8cd4290700b299a8bad2c99606d TAG_1.2.1
092018f8f6cab00d7198e0fdd2489e0d41c33f9f TAG_1.2.2
2203f0ccc2e2d728c81080d37cba4559d705917e TAG_1.2.3
d6fa2a1477bc1f7a3590eb425ab7f907779cb732 TAG_1.2.4
067b603cc82e6403b66fedd1636f50ff104c3fee TAG_1.2.5
ce6b34e125174856e86c108399dfbb0eb84a7418 TAG_1.3
a9d3f37477695c6255e7f603fa47defcfbd3a2af TAG_1.3.1
801e4bf837a28a824637570ec19bd6bc148c6837 TAG_2.0b1
2e68df0df26d1dbcb28b30f8b626d8b237650751 TAG_2.0b2
0118ec4a766ed2a279ac2d6caaf71e0c3db0023b TAG_8.0.2.0
77b8df6148164972274ab8246a56e053357d61ca TAG_8.0.2.0
65b3c62a20f1f7f06c36783bc3fa2cc52dd8a0b3 TAG_8.0.2.1

38
.travis.yml

@ -0,0 +1,38 @@
sudo: false
cache: pip
addons:
apt:
packages:
- expect-dev # provides unbuffer utility
- python-lxml # because pip installation is slow
language: python
python:
- "2.7"
env:
global:
- VERSION="9.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0"
- TRANSIFEX_USER='transbot@odoo-community.org'
- secure: NUsXwVrMntcqge1ozKW+DSkP7dq+Rla6JVvFF2c89/g+zJaIqQRi8EQBLoqNwCdMk+rjpQeZt/JPELjH+EzPcmGddhDxOgVB3nUT9LvFXGCHF+NjmHXqyba4tuc7BnpG1WDD+rSlxVCt1aIjNIhhaZ4ic0rCWpKNYu/yFTsmChc=
matrix:
- LINT_CHECK="1"
- TRANSIFEX="1"
- TESTS="1" ODOO_REPO="odoo/odoo"
- TESTS="1" ODOO_REPO="OCA/OCB"
virtualenv:
system_site_packages: true
install:
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly
script:
- travis_run_tests
after_success:
- travis_after_tests_success

8
LICENSE

@ -1,4 +1,4 @@
GNU AFFERO GENERAL PUBLIC LICENSE
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
@ -633,8 +633,8 @@ the "copyright" line and a pointer to where the full notice is found.
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@ -658,4 +658,4 @@ specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.
<http://www.gnu.org/licenses/>.

43
README.md

@ -1,18 +1,43 @@
### README ###
[![Runbot Status](https://runbot.odoo-community.org/runbot/badge/flat/143/9.0.svg)](https://runbot.odoo-community.org/runbot/repo/github-com-oca-reporting-engine-143)
[![Build Status](https://travis-ci.org/OCA/reporting-engine.svg?branch=9.0)](https://travis-ci.org/OCA/reporting-engine)
[![Coverage Status](https://img.shields.io/coveralls/OCA/reporting-engine.svg)](https://coveralls.io/r/OCA/reporting-engine?branch=9.0)
OCA alternative reporting engines and reporting utilities for Odoo
==================================================================
### LibreOffice Report Engine for Odoo/OpenERP ###
This repository hosts alternative reporting engines to the ones included on Odoo core (RML, QWeb and Webkit). It is complemented with the ones that host the reports theirself:
https://github.com/OCA/account-financial-reporting
https://github.com/OCA/purchase-reporting
https://github.com/OCA/sale-reporting
...
This module allows you to convert any type of report into LibreOffice/OpenOffice.
The benefits is that you have control over your documents and you can
modify them as needed.
The convention is to use a suffix to each module to indicate that it's for using with that report engine (for example, account_invoice_report_birt or sale_order_report_pentaho).
It can contain also another utilities directly involved with reports (like merge/split utils, checkers, signing tools and so on).
Requirements
============
[//]: # (addons)
Available addons
----------------
addon | version | summary
--- | --- | ---
[report_qweb_element_page_visibility](report_qweb_element_page_visibility/) | 9.0.1.0.0 | Report Qweb Element Page Visibility
[report_xlsx](report_xlsx/) | 9.0.1.0.0 | Base module to create xlsx report
The py3o.template package is required; install it with:
easy_install -UZ py3o.template
Unported addons
---------------
addon | version | summary
--- | --- | ---
[base_report_assembler](base_report_assembler/) | 1.0 (unported) | Base Report Assembler
[report_custom_filename](report_custom_filename/) | 8.0.1.0.0 (unported) | Configure the filename to use when downloading a report
[report_xls](report_xls/) | 8.0.0.6.1 (unported) | Excel report engine
[//]: # (end addons)
----
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.
http://odoo-community.org/

1
__init__.py

@ -1 +0,0 @@
import models

55
__openerp__.py

@ -1,55 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# LibreOffice Report Engine, for OpenERP
# Copyright (C) 2013 XCG Consulting (http://odoo.consulting)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Author: Anael LORIMIER <anael.lorimier@xcg-consulting.fr>
# Vincent Lhote-Hatakeyama <vincent.lhote@xcg-consulting.fr>
#
##############################################################################
{
'name': 'LibreOffice Report Engine',
'description': '''
Generation of LibreOffice/OpenOffice reports using LibreOffice/OpenOffice
templates.
The py3o.template package is required; install it with:
pip install py3o.template
''',
'version': '8.0.2.1',
'category': 'Reporting',
'author': 'XCG Consulting',
'website': 'http://odoo.consulting/',
'depends': [
'base',
'report'
],
'external_dependencies': {
'python': ['py3o.template']
},
'data': [
'security/ir.model.access.csv',
'views/menu.xml',
'views/py3o_template.xml',
'views/py3o_server.xml',
'views/ir_report.xml',
'data/py3o.fusion.filetype.csv',
],
'installable': True,
}

24
base_report_assembler/__init__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import report_assembler
from . import assembled_report
from . import ir_report

49
base_report_assembler/__openerp__.py

@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{'name': 'Base Report Assembler',
'version': '1.0',
'category': 'Report',
'description': """
Base Report Assembler
=====================
Defines a new type of report which is an assemblage of multiple other reports
of the same object.
For example you can merge the pdf output of a rml invoice report with the pdf
output of a webkit payment slip.
To install this assemblage option for specific object you can install
the folling module(s):
- Invoices: invoice_report_assemble (lp:account-invoice-report)
""",
'author': "Camptocamp,Odoo Community Association (OCA)",
'maintainer': 'Camptocamp',
'website': 'http://www.camptocamp.com/',
'depends': ['base'],
'data': [],
'test': [],
'installable': False,
'auto_install': False,
'application': False,
}

42
base_report_assembler/assembled_report.py

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class AssembledReport(orm.Model):
_name = 'assembled.report'
_order = 'sequence'
_columns = {
'report_id': fields.many2one(
'ir.actions.report.xml', 'Report',
domain="[('model', '=', model),"
"('report_type', '!=', 'assemblage')]", required=True),
'model': fields.char('Object model'),
'sequence': fields.integer('Sequence', required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
}
_defaults = {
'sequence': 1,
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(
cr, uid, 'assembled.report', context=c)
}

36
base_report_assembler/i18n/base_report_assembler.pot

@ -0,0 +1,36 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * base_report_assembler
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-05 14:55+0000\n"
"PO-Revision-Date: 2013-11-05 14:55+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base_report_assembler
#: field:assembled.report,model:0
msgid "Object model"
msgstr ""
#. module: base_report_assembler
#: field:assembled.report,sequence:0
msgid "Sequence"
msgstr ""
#. module: base_report_assembler
#: field:assembled.report,company_id:0
msgid "Company"
msgstr ""
#. module: base_report_assembler
#: field:assembled.report,report_id:0
msgid "Report"
msgstr ""

37
base_report_assembler/i18n/fr.po

@ -0,0 +1,37 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * base_report_assembler
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-05 14:55+0000\n"
"PO-Revision-Date: 2013-11-05 14:55+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base_report_assembler
#: field:assembled.report,model:0
msgid "Object model"
msgstr "Modèle d'object"
#. module: base_report_assembler
#: field:assembled.report,sequence:0
msgid "Sequence"
msgstr "Séquence"
#. module: base_report_assembler
#: field:assembled.report,company_id:0
msgid "Company"
msgstr "Société"
#. module: base_report_assembler
#: field:assembled.report,report_id:0
msgid "Report"
msgstr "Rapport"

110
base_report_assembler/ir_report.py

@ -0,0 +1,110 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm
from openerp import netsvc
from openerp.report.report_sxw import rml_parse
from report_assembler import PDFReportAssembler
def register_report(name, model, parser=rml_parse):
""" Register the report into the services """
name = 'report.%s' % name
if netsvc.Service._services.get(name, False):
service = netsvc.Service._services[name]
if isinstance(service, PDFReportAssembler):
#already instantiated properly, skip it
return
if hasattr(service, 'parser'):
parser = service.parser
del netsvc.Service._services[name]
PDFReportAssembler(name, model, parser=parser)
class ReportAssembleXML(orm.Model):
_name = 'ir.actions.report.xml'
_inherit = 'ir.actions.report.xml'
def __init__(self, pool, cr):
super(ReportAssembleXML, self).__init__(pool, cr)
def register_all(self, cursor):
value = super(ReportAssembleXML, self).register_all(cursor)
cursor.execute("SELECT * FROM ir_act_report_xml WHERE report_type = 'assemblage'")
records = cursor.dictfetchall()
for record in records:
register_report(record['report_name'], record['model'])
return value
def unlink(self, cursor, user, ids, context=None):
""" Delete report and unregister it """
trans_obj = self.pool.get('ir.translation')
trans_ids = trans_obj.search(
cursor,
user,
[('type', '=', 'report'), ('res_id', 'in', ids)]
)
trans_obj.unlink(cursor, user, trans_ids)
# Warning: we cannot unregister the services at the moment
# because they are shared across databases. Calling a deleted
# report will fail so it's ok.
res = super(ReportAssembleXML, self).unlink(
cursor,
user,
ids,
context)
return res
def create(self, cursor, user, vals, context=None):
""" Create report and register it """
res = super(ReportAssembleXML, self).create(cursor, user, vals, context)
if vals.get('report_type', '') == 'assemblage':
# I really look forward to virtual functions :S
register_report(
vals['report_name'],
vals['model'])
return res
def write(self, cr, uid, ids, vals, context=None):
""" Edit report and manage its registration """
if isinstance(ids, (int, long)):
ids = [ids]
for rep in self.browse(cr, uid, ids, context=context):
if rep.report_type != 'assemblage':
continue
if (vals.get('report_name', False)
and vals['report_name'] != rep.report_name):
report_name = vals['report_name']
else:
report_name = rep.report_name
register_report(
report_name,
vals.get('model', rep.model),
False
)
res = super(ReportAssembleXML, self).write(cr, uid, ids, vals, context)
return res
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

126
base_report_assembler/report_assembler.py

@ -0,0 +1,126 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
import base64
from PyPDF2 import PdfFileReader, PdfFileWriter
from StringIO import StringIO
from openerp.netsvc import ExportService
from openerp.report import report_sxw
from openerp import pooler
_POLLING_DELAY = 0.25
def assemble_pdf(pdf_list):
"""
Assemble a list of pdf
"""
# Even though we are using PyPDF2 we can't use PdfFileMerger
# as this issue still exists in mostly used wktohtml reports version
# http://code.google.com/p/wkhtmltopdf/issues/detail?id=635
#merger = PdfFileMerger()
#merger.append(fileobj=StringIO(invoice_pdf))
#merger.append(fileobj=StringIO(bvr_pdf))
#with tempfile.TemporaryFile() as merged_pdf:
#merger.write(merged_pdf)
#return merged_pdf.read(), 'pdf'
output = PdfFileWriter()
for pdf in pdf_list:
reader = PdfFileReader(StringIO(pdf))
for page in range(reader.getNumPages()):
output.addPage(reader.getPage(page))
s = StringIO()
output.write(s)
return s.getvalue()
class PDFReportAssembler(report_sxw.report_sxw):
""" PDFReportAssembler allows to put 2 pdf reports in one single pdf"""
def _generate_all_pdf(self, cr, uid, ids, data, report_ids, context=None):
"""
Return a list of pdf encoded in base64
"""
pool = pooler.get_pool(cr.dbname)
report_obj = pool.get('ir.actions.report.xml')
spool = ExportService._services['report']
pdf_reports = []
report_list = report_obj.browse(cr, uid, report_ids, context=context)
for report in report_list:
report_key = spool.exp_report(cr.dbname, uid, report.report_name,
ids, datas=data, context=context)
while 1:
res = spool.exp_report_get(cr.dbname, uid, report_key)
if res.get('state'):
break
time.sleep(_POLLING_DELAY)
pdf = base64.b64decode(res.get('result'))
pdf_reports.append(pdf)
return pdf_reports
def _get_report_ids(self, cr, uid, ids, context=None):
"""
Hook to define the list of report to print
"""
return []
def create_single_pdf(self, cr, uid, ids, data, report_xml, context=None):
"""Call both report to assemble both pdf"""
report_ids = self._get_report_ids(cr, uid, ids, context=context)
pdf_reports = self._generate_all_pdf(cr, uid, ids, data, report_ids, context=context)
pdf_assemblage = assemble_pdf(pdf_reports)
return pdf_assemblage, 'pdf'
def create(self, cr, uid, ids, data, context=None):
"""We override the create function in order to handle generator
Code taken from report openoffice. Thanks guys :) """
pool = pooler.get_pool(cr.dbname)
ir_obj = pool.get('ir.actions.report.xml')
report_xml_ids = ir_obj.search(cr, uid,
[('report_name', '=', self.name[7:])], context=context)
if report_xml_ids:
report_xml = ir_obj.browse(cr,
uid,
report_xml_ids[0],
context=context)
report_xml.report_rml = None
report_xml.report_rml_content = None
report_xml.report_sxw_content_data = None
report_xml.report_sxw_content = None
report_xml.report_sxw = None
else:
return super(PDFReportAssembler, self).create(cr, uid, ids, data, context)
if report_xml.report_type != 'assemblage':
return super(PDFReportAssembler, self).create(cr, uid, ids, data, context)
result = self.create_source_pdf(cr, uid, ids, data, report_xml, context)
if not result:
return (False, False)
return result

4
models/__init__.py

@ -1,4 +0,0 @@
import ir_report
import py3o_fusion_filetype
import py3o_template
import py3o_server

18
models/py3o_fusion_filetype.py

@ -1,18 +0,0 @@
from openerp.osv import fields, osv
class py3o_fusion_filetype(osv.Model):
_name = 'py3o.fusion.filetype'
_rec_name = 'human_ext'
_columns = {
'fusion_ext': fields.char(
u"Fusion Extension",
size=8,
),
'human_ext': fields.char(
u"Human readble extension",
size=8,
),
}

19
models/py3o_server.py

@ -1,19 +0,0 @@
from openerp.osv import fields, osv
class py3o_server(osv.Model):
_name = 'py3o.server'
_columns = {
'url': fields.char(
u"URL",
size=256,
),
'is_active': fields.boolean(
u"Active",
)
}
_defaults = {
'is_active': True,
}

28
models/py3o_template.py

@ -1,28 +0,0 @@
from openerp.osv import fields, osv
class py3o_template(osv.Model):
_name = 'py3o.template'
_columns = {
'name': fields.char(
u"Name",
),
'py3o_template_data': fields.binary(
u"LibreOffice template",
),
'filetype': fields.selection(
[
('odt', u"ODF Text Document"),
('ods', u"ODF Spreadsheet"),
],
u"LibreOffice Template File Type",
required=True,
),
}
_defaults = {
'filetype': 'odt'
}

146
py3o_report_modif.py

@ -1,146 +0,0 @@
from base64 import b64decode
from tempfile import NamedTemporaryFile as tempfile
from openerp import pooler
from openerp.report.report_sxw import *
from openerp.tools.translate import _
from openerp.osv.osv import except_osv
from py3o.template import Template
from oe_json_serializer import OESerializer
import json
import requests
import os
class py3o_report(report_sxw):
# def __init__(self, name, table):
# super(py3o_report, self).__init__(name, table)
def get_values(self, cr, uid, ids, data, context):
''' Override this function to customize the dictionary given to the
py3o.template renderer. '''
return {
'lang': self.get_lang(cr, uid, context),
'objects': self.getObjects(cr, uid, ids, context),
}
def get_lang(self, cr, uid, context):
pool = pooler.get_pool(cr.dbname)
lang_obj = pool.get('res.lang')
user_obj = pool.get('res.users')
lang_code = user_obj.browse(cr, uid, uid, context=context).lang
lang = lang_obj.search(cr, uid,
[('code', '=', lang_code)],
context=context)[0]
return lang_obj.browse(cr, uid, lang, context=context)
def format_date(self, date, values):
''' Return a date formatted according to the language extracted from
the "values" argument (which should be the result of get_values). '''
return date.strftime(values['lang'].date_format)
def create(self, cr, uid, ids, data, context=None):
# Find the report definition to get its settings.
pool = pooler.get_pool(cr.dbname)
report_xml_obj = pool.get('ir.actions.report.xml')
report_xml_ids = report_xml_obj.search(cr, uid,
[('report_name', '=', self.name[7:])], # Ignore "report."
context=context)
if not report_xml_ids:
return super(py3o_report, self).create(cr, uid, ids, data,
context=context)
report_xml = report_xml_obj.browse(cr, uid,
report_xml_ids[0],
context=context)
template = report_xml.py3o_template_id
filetype = report_xml.py3o_fusion_filetype
#Try to request fusion server:
fusion_server_obj = pool['py3o.server']
#TODO: Raise a message if no config found
fusion_server_id = fusion_server_obj.search(
cr, uid, [], context=context
)[0]
fusion_server = fusion_server_obj.browse(cr, uid, fusion_server_id)
# py3o.template operates on filenames so create temporary files.
in_temp = tempfile(suffix='.odt', prefix='py3o-template-')
in_temp.write(b64decode(template.py3o_template_data))
in_temp.seek(0)
out_temp = tempfile(suffix='.odt', prefix='py3o-report-')
# We need to get the variables used in the template
#TODO: Find a way to avoid calling Template
t = Template(in_temp.name, out_temp.name)
# Remove 'py3o.'
user_variable = [x[5:] for x in t.get_all_user_python_expression()]
print user_variable
values = self.get_values(cr, uid, ids, data, context)
t.render(values)
print values
#WARNING: We rely on the fact that there is a for loop on the report
# on objects (for object in objects) due to lack of time
val_dict = {}
for val in values:
if val == 'objects':
o = []
for obj in values[val]:
x = OESerializer.serialize(
obj,
[
v[len('object') + 1:]
for v in user_variable
if v.startswith('object')
]
)
o.append(x)
val_dict.update({val: o})
continue
x = OESerializer.serialize(
values[val],
[
v[len(val) + 1:]
for v in user_variable
if v.startswith(val)
]
)
val_dict.update({val: x})
import pprint
pprint.pprint(val_dict)
val_json = json.dumps(val_dict)
fields = {
'targetformat': filetype.fusion_ext,
'datadict': val_json,
'image_mapping': '{}',
}
print fields
r = requests.post(
fusion_server.url, data=fields, files={'tmpl_file': in_temp}
)
in_temp.close()
if r.status_code == 400:
raise Exception("Problem with fusion server: %s" % r.json())
chunk_size = 1024
ext = filetype.human_ext
for chunk in r.iter_content(chunk_size):
out_temp.write(chunk)
out_temp.seek(0)
return out_temp.read(), ext

47
report_custom_filename/README.rst

@ -0,0 +1,47 @@
Custom report filenames
=======================
This addon allows for custom filenames for reports.
Configuration
=============
To configure this module, open the report whose filename you want to change and fill in the `Download filename` field. This field is evaluated as jinja2 template with `objects` being a list of browse records of the records to print, and `o` the first record. If your model contains a name field, you might write something like `${o.name}_report.pdf` as filename.
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
`here <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_custom_filename%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/143/8.0
Credits
=======
Contributors
------------
* Holger Brunn <hbrunn@therp.nl>
Icon
----
Icon courtesy of http://www.picol.org/ (download_settings.svg)
Maintainer
----------
.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.

22
report_custom_filename/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import controllers
from . import model

44
report_custom_filename/__openerp__.py

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Custom report filenames",
"summary": "Configure the filename to use when downloading a report",
"version": "8.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"complexity": "normal",
"category": "Reporting",
"depends": [
'web',
'email_template',
],
"data": [
"view/ir_actions_report_xml.xml",
],
"test": [
],
"auto_install": False,
'installable': False,
"application": False,
"external_dependencies": {
'python': ['jinja2'],
},
}

22
report_custom_filename/controllers/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import reports
from . import report_controller

68
report_custom_filename/controllers/report_controller.py

@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2015 Therp BV (<http://therp.nl>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import http
from openerp.addons.email_template import email_template
from openerp.addons.report.controllers.main import ReportController
from openerp.addons.web.controllers.main import content_disposition
class ReportController(ReportController):
@http.route([
'/report/<path:converter>/<reportname>',
'/report/<path:converter>/<reportname>/<docids>',
])
def report_routes(self, reportname, docids=None, converter=None, **data):
response = super(ReportController, self).report_routes(
reportname, docids=docids, converter=converter, **data)
if docids:
docids = [int(i) for i in docids.split(',')]
report_xml = http.request.session.model('ir.actions.report.xml')
report_ids = report_xml.search(
[('report_name', '=', reportname)])
for report in report_xml.browse(report_ids):
if not report.download_filename:
continue
objects = http.request.session.model(report.model)\
.browse(docids or [])
generated_filename = email_template.mako_template_env\
.from_string(report.download_filename)\
.render({
'objects': objects,
'o': objects[:1],
'object': objects[:1],
'ext': report.report_type.replace('qweb-', ''),
})
response.headers['Content-Disposition'] = content_disposition(
generated_filename)
return response
@http.route(['/report/download'])
def report_download(self, data, token):
response = super(ReportController, self).report_download(data, token)
# if we got another content disposition before, ditch the one added
# by super()
last_index = None
for i in range(len(response.headers) - 1, -1, -1):
if response.headers[i][0] == 'Content-Disposition':
if last_index:
response.headers.pop(last_index)
last_index = i
return response

53
report_custom_filename/controllers/reports.py

@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import simplejson
from openerp import http
from openerp.addons.web.controllers import main
from openerp.addons.email_template import email_template
class Reports(main.Reports):
@http.route('/web/report', type='http', auth="user")
@main.serialize_exception
def index(self, action, token):
result = super(Reports, self).index(action, token)
action = simplejson.loads(action)
context = dict(http.request.context)
context.update(action["context"])
report_xml = http.request.session.model('ir.actions.report.xml')
report_ids = report_xml.search(
[('report_name', '=', action['report_name'])],
0, False, False, context)
for report in report_xml.browse(report_ids):
if not report.download_filename:
continue
objects = http.request.session.model(context['active_model'])\
.browse(context['active_ids'])
generated_filename = email_template.mako_template_env\
.from_string(report.download_filename)\
.render({
'objects': objects,
'o': objects[0],
'object': objects[0],
})
result.headers['Content-Disposition'] = main.content_disposition(
generated_filename)
return result

34
report_custom_filename/i18n/report_custom_filename.pot

@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_custom_filename
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-12-19 12:17+0000\n"
"PO-Revision-Date: 2014-12-19 12:17+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: report_custom_filename
#: field:ir.actions.report.xml,download_filename:0
msgid "Download filename"
msgstr ""
#. module: report_custom_filename
#: help:ir.actions.report.xml,download_filename:0
msgid "Fill in this field to have a custom file name when downloading this report. This string is evaluated as a jinja2 expression.\n"
"You can use python expressions, `objects` is a browse record list of the objects for which the report is being generated.\n"
"Check for this list's length to determine if it is a report being printed for multiple records or not. You also have access to `o`, which is the first record in the list"
msgstr ""
#. module: report_custom_filename
#: model:ir.model,name:report_custom_filename.model_ir_actions_report_xml
msgid "ir.actions.report.xml"
msgstr ""

21
report_custom_filename/model/__init__.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import ir_actions_report_xml

37
report_custom_filename/model/ir_actions_report_xml.py

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields
class IrActionsReportXml(models.Model):
_inherit = 'ir.actions.report.xml'
download_filename = fields.Char(
'Download filename',
help='Fill in this field to have a custom file name when downloading '
'this report. This string is evaluated as a jinja2 expression.\n'
'You can use python expressions, `objects` is a browse record list of '
'the objects for which the report is being generated.\n'
'Check for this list\'s length to determine if it is a report being '
'printed for multiple records or not. You also have access to `o`, '
'which is the first record in the list.\n'
'For qweb reports, the variable `ext` gives you the requested format'
'\'s extension')

BIN
report_custom_filename/static/description/icon.png

After

Width: 100  |  Height: 100  |  Size: 1.8 KiB

14
report_custom_filename/view/ir_actions_report_xml.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="act_report_xml_view" model="ir.ui.view">
<field name="model">ir.actions.report.xml</field>
<field name="inherit_id" ref="base.act_report_xml_view" />
<field name="arch" type="xml">
<field name="attachment" position="after">
<field name="download_filename" />
</field>
</field>
</record>
</data>
</openerp>

661
report_py3o/LICENSE

@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

0
NEWS → report_py3o/NEWS

18
report_py3o/README.md

@ -0,0 +1,18 @@
### README ###
### LibreOffice Report Engine for Odoo/OpenERP ###
This module allows you to convert any type of report into LibreOffice/OpenOffice.
The benefits is that you have control over your documents and you can
modify them as needed.
Requirements
============
The py3o.template package is required; install it with:
easy_install -UZ py3o.template

1
report_py3o/__init__.py

@ -0,0 +1 @@
from . import models

35
report_py3o/__openerp__.py

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Copyright 2013 XCG Consulting (http://odoo.consulting)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'LibreOffice Report Engine',
'description': '''
Generation of LibreOffice/OpenOffice reports using LibreOffice/OpenOffice
templates.
The py3o.template package is required; install it with:
pip install py3o.template
''',
'version': '9.0.1.0.0',
'category': 'Reporting',
'author': 'XCG Consulting',
'website': 'http://odoo.consulting/',
'depends': [
'base',
'report'
],
'external_dependencies': {
'python': ['py3o.template']
},
'data': [
'security/ir.model.access.csv',
'views/menu.xml',
'views/py3o_template.xml',
'views/py3o_server.xml',
'views/ir_report.xml',
'data/py3o.fusion.filetype.csv',
],
'installable': True,
}

0
data/py3o.fusion.filetype.csv → report_py3o/data/py3o.fusion.filetype.csv

0
i18n/fr.po → report_py3o/i18n/fr.po

4
report_py3o/models/__init__.py

@ -0,0 +1,4 @@
from . import ir_report
from . import py3o_fusion_filetype
from . import py3o_template
from . import py3o_server

77
models/ir_report.py → report_py3o/models/ir_report.py

@ -1,11 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright 2013 XCG Consulting (http://odoo.consulting)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import os
from openerp.osv import fields, osv
from openerp import api, fields, models
from openerp.report.interface import report_int
from ..py3o_parser import Py3oParser
from openerp.exceptions import ValidationError
from openerp import addons
class report_xml(osv.Model):
class ReportXml(models.Model):
""" Inherit from ir.actions.report.xml to allow customizing the template
file. The user cam chose a template from a list.
The list is configurable in the configuration tab, see py3o_template.py
@ -13,49 +17,32 @@ class report_xml(osv.Model):
_inherit = 'ir.actions.report.xml'
_columns = {
# TODO required when report_type type is py3o, add python constraint
'py3o_fusion_filetype': fields.many2one(
'py3o.fusion.filetype',
u"Output Format",
),
'py3o_template_id': fields.many2one(
'py3o.template',
u"Template",
),
'module': fields.char(
u"Module",
size=64,
help=u"The implementer module that provides this report",
),
'py3o_template_fallback': fields.char(
u"Fallback",
size=128,
help=(
u"If the user does not provide a template this will be used "
u"it should be a relative path to root of YOUR module"
)
),
'report_type': fields.selection(
[
('qweb-pdf', u"PDF"),
('qweb-html', u"HTML"),
('controller', u"Controller"),
('pdf', u"RML pdf (deprecated)"),
('sxw', u"RML sxw (deprecated)"),
('webkit', u"Webkit (deprecated)"),
('py3o', u"Py3o"),
],
string=u"Report Type",
required=True,
help=u"HTML will open the report directly in your browser, "
u"PDF will use wkhtmltopdf to render the HTML into a PDF "
u"file and let you download it, Controller allows you to "
u"define the url of a custom controller outputting "
u"any kind of report.",
)
}
@api.one
@api.constrains("py3o_fusion_filetype", "report_type")
def _check_py3o_fusion_filetype(self):
if self.report_type == "py3o" and not self.py3o_fusion_filetype:
raise ValidationError(
"Field 'Output Format' is required for Py3O report")
py3o_fusion_filetype = fields.Many2one(
'py3o.fusion.filetype',
"Output Format")
py3o_template_id = fields.Many2one(
'py3o.template',
"Template")
module = fields.Char(
"Module",
help="The implementer module that provides this report")
py3o_template_fallback = fields.Char(
"Fallback",
size=128,
help=(
"If the user does not provide a template this will be used "
"it should be a relative path to root of YOUR module"
))
report_type = fields.Selection(selection_add=[('py3o', "Py3o")])
@api.cr
def _lookup_report(self, cr, name):
"""Look up a report definition.
"""
@ -95,4 +82,4 @@ class report_xml(osv.Model):
if new_report:
return new_report
else:
return super(report_xml, self)._lookup_report(cr, name)
return super(ReportXml, self)._lookup_report(cr, name)

13
report_py3o/models/py3o_fusion_filetype.py

@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# Copyright 2013 XCG Consulting (http://odoo.consulting)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import fields, models
class Py3oFusionFiletype(models.Model):
_name = 'py3o.fusion.filetype'
_rec_name = 'human_ext'
fusion_ext = fields.Char("Fusion Extension", siez=8)
human_ext = fields.Char("Human readble extension", size=8)

11
report_py3o/models/py3o_server.py

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2013 XCG Consulting (http://odoo.consulting)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import fields, models
class Py3oServer(models.Model):
_name = 'py3o.server'
url = fields.Char("URL", required=True)
is_active = fields.Boolean("Active", default=True)

19
report_py3o/models/py3o_template.py

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2013 XCG Consulting (http://odoo.consulting)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import fields, models
class Py3oTemplate(models.Model):
_name = 'py3o.template'
name = fields.Char(required=True)
py3o_template_data = fields.Binary("LibreOffice template")
filetype = fields.Selection(
selection=[
('odt', u"ODF Text Document"),
('ods', u"ODF Spreadsheet"),
],
string="LibreOffice Template File Type",
required=True,
default='odt')

8
py3o_parser.py → report_py3o/py3o_parser.py

@ -1,4 +1,6 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
# Copyright 2013 XCG Consulting (http://odoo.consulting)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from cStringIO import StringIO
import json
import pkg_resources
@ -66,8 +68,8 @@ class Py3oParser(report_sxw):
or from the default template file provided by the implementer.
ATM this method takes a report definition recordset
to try and fetch the report template from database. If not found it will
fallback to the template file referenced in the report definition.
to try and fetch the report template from database. If not found it
will fallback to the template file referenced in the report definition.
@param report_obj: a recordset representing the report defintion
@type report_obj: openerp.model.recordset instance

0
security/ir.model.access.csv → report_py3o/security/ir.model.access.csv

2
views/ir_report.xml → report_py3o/views/ir_report.xml

@ -9,7 +9,7 @@
<field name="inherit_id" ref="base.act_report_xml_view" />
<field name="arch" type="xml">
<xpath expr="//page[@string='Security']" position="before">
<xpath expr="//page[@name='security']" position="before">
<page string="LibreOffice template"
attrs="{'invisible': [('report_type', '!=', 'py3o')]}">

0
views/menu.xml → report_py3o/views/menu.xml

0
views/py3o_server.xml → report_py3o/views/py3o_server.xml

0
views/py3o_template.xml → report_py3o/views/py3o_template.xml

77
report_qweb_element_page_visibility/README.rst

@ -0,0 +1,77 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
===================================
Report Qweb Element Page Visibility
===================================
This module allows you to use 4 classes in QWEB reports:
- not-first-page: shows element in every page but first
- not-last-page: shows element in every page but last
- first-page: shows element only on first page
- last-page: shows element only on last page
Usage
=====
To use this module, you need to:
In the QWEB ``ir.ui.views`` used by your report,
you can add an element with css class with any of the classes described above.
For example if you need to improve invoice report header with
invoice's number in every page but first, and sale order report header
with order's name in every page but last, add this code to external_layout_header::
<t t-if="o._table=='account_invoice'">
<div class="not-first-page">
<span t-esc="o.number"/>
</div>
</t>
<t t-if="o._table=='sale_order'">
<div class="not-last-page">
<span t-esc="o.name"/>
</div>
</t>
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/143/8.0
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 `here <https://github.com/OCA/reporting-engine/issues/new?body=module:%20
report_qweb_element_page_visibility%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Nicola Malcontenti <nicola.malcontenti@agilebg.com>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* Alessio Gerace <alessio.gerace@agilebg.com>
* Alex Comba <alex.comba@agilebg.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.

3
report_qweb_element_page_visibility/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

20
report_qweb_element_page_visibility/__openerp__.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Report Qweb Element Page Visibility',
'version': '9.0.1.0.0',
'author': 'Agile Business Group, Odoo Community Association (OCA)',
'category': 'Tools',
"website": "https://odoo-community.org/",
"license": "AGPL-3",
"application": False,
"installable": True,
'data': [
'views/layouts.xml',
],
'depends': [
'report',
],
}

BIN
report_qweb_element_page_visibility/static/description/icon.png

After

Width: 300  |  Height: 300  |  Size: 17 KiB

46
report_qweb_element_page_visibility/views/layouts.xml

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="minimal_layout" inherit_id="report.minimal_layout">
<xpath expr="//t[@t-if='subst is True']" position="replace">
<t t-if="subst is True">
<script>
function subst() {
var vars = {};
var x = document.location.search.substring(1).split('&amp;');
for (var i in x) {
var z = x[i].split('=', 2);
vars[z[0]] = unescape(z[1]);
}
var x=['frompage', 'topage', 'page', 'webpage', 'section', 'subsection', 'subsubsection'];
for (var i in x) {
var y = document.getElementsByClassName(x[i]);
for (var j=0; j&lt;y.length; ++j)
y[j].textContent = vars[x[i]];
}
var operations = {
'not-first-page': function (elt) {
elt.style.visibility = (vars.page === vars.frompage) ? "hidden" : "visible";
},
'not-last-page': function (elt) {
elt.style.visibility = (vars.page === vars.topage) ? "hidden" : "visible";
},
'first-page': function (elt) {
elt.style.visibility = (vars.page === vars.frompage) ? "visible" : "hidden";
},
'last-page': function (elt) {
elt.style.visibility = (vars.page === vars.topage) ? "visible" : "hidden";
},
};
for (var klass in operations) {
var y = document.getElementsByClassName(klass);
for (var j=0; j&lt;y.length; ++j)
operations[klass](y[j]);
}
}
</script>
</t>
</xpath>
</template>
</odoo>

25
report_xls/__init__.py

@ -0,0 +1,25 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import ir_report
from . import report_xls
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

82
report_xls/__openerp__.py

@ -0,0 +1,82 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Excel report engine',
'version': '8.0.0.6.1',
'license': 'AGPL-3',
'author': "Noviat,Odoo Community Association (OCA)",
'website': 'http://www.noviat.com',
'category': 'Reporting',
'description': """
Excel report engine
===================
This module adds Excel export capabilities to the standard odoo reporting
engine.
Report development
''''''''''''''''''
In order to create an Excel report you can\n
- define a report of type 'xls'
- pass ``{'xls_export': 1}`` via the context to the report create method
The ``report_xls`` class contains a number of attributes and methods to
facilitate the creation XLS reports in OpenERP.
* cell types
Supported cell types : text, number, boolean, date.
* cell styles
The predefined cell style definitions result in a consistent
look and feel of the OpenERP Excel reports.
* cell formulas
Cell formulas can be easily added with the help of the ``rowcol_to_cell()``
function which you can import from the ``utils.py`` module.
* Excel templates
It is possible to define Excel templates which can be adapted
by 'inherited' modules.
Download the ``account_move_line_report_xls`` module
from http://apps.odoo.com as example.
* XLS with multiple sheets
Download the ``account_journal_report_xls`` module
from http://apps.odoo.com as example.
Development assistance
''''''''''''''''''''''
Contact info@noviat.com for help with the development of
Excel reports in odoo.
""",
'depends': ['base'],
'external_dependencies': {'python': ['xlwt']},
'active': False,
'installable': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

36
report_xls/ir_report.py

@ -0,0 +1,36 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm
class ir_actions_report_xml(orm.Model):
_inherit = 'ir.actions.report.xml'
def _check_selection_field_value(self, cr, uid,
field, value, context=None):
if field == 'report_type' and value == 'xls':
return
return super(ir_actions_report_xml, self)._check_selection_field_value(
cr, uid, field, value, context=context)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

248
report_xls/report_xls.py

@ -0,0 +1,248 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import xlwt
from xlwt.Style import default_style
import cStringIO
from datetime import datetime
from openerp.osv.fields import datetime as datetime_field
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
import inspect
from types import CodeType
from openerp.report.report_sxw import report_sxw
from openerp import pooler
import logging
_logger = logging.getLogger(__name__)
class AttrDict(dict):
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self
class report_xls(report_sxw):
xls_types = {
'bool': xlwt.Row.set_cell_boolean,
'date': xlwt.Row.set_cell_date,
'text': xlwt.Row.set_cell_text,
'number': xlwt.Row.set_cell_number,
}
xls_types_default = {
'bool': False,
'date': None,
'text': '',
'number': 0,
}
# TO DO: move parameters infra to configurable data
# header/footer
hf_params = {
'font_size': 8,
'font_style': 'I', # B: Bold, I: Italic, U: Underline
}
# styles
_pfc = '26' # default pattern fore_color
_bc = '22' # borders color
decimal_format = '#,##0.00'
date_format = 'YYYY-MM-DD'
xls_styles = {
'xls_title': 'font: bold true, height 240;',
'bold': 'font: bold true;',
'underline': 'font: underline true;',
'italic': 'font: italic true;',
'fill': 'pattern: pattern solid, fore_color %s;' % _pfc,
'fill_blue': 'pattern: pattern solid, fore_color 27;',
'fill_grey': 'pattern: pattern solid, fore_color 22;',
'borders_all':
'borders: '
'left thin, right thin, top thin, bottom thin, '
'left_colour %s, right_colour %s, '
'top_colour %s, bottom_colour %s;'
% (_bc, _bc, _bc, _bc),
'left': 'align: horz left;',
'center': 'align: horz center;',
'right': 'align: horz right;',
'wrap': 'align: wrap true;',
'top': 'align: vert top;',
'bottom': 'align: vert bottom;',
}
# TO DO: move parameters supra to configurable data
def create(self, cr, uid, ids, data, context=None):
self.pool = pooler.get_pool(cr.dbname)
self.cr = cr
self.uid = uid
report_obj = self.pool.get('ir.actions.report.xml')
report_ids = report_obj.search(
cr, uid, [('report_name', '=', self.name[7:])], context=context)
if report_ids:
report_xml = report_obj.browse(
cr, uid, report_ids[0], context=context)
self.title = report_xml.name
if report_xml.report_type == 'xls':
return self.create_source_xls(cr, uid, ids, data, context)
elif context.get('xls_export'):
# use model from 'data' when no ir.actions.report.xml entry
self.table = data.get('model') or self.table
return self.create_source_xls(cr, uid, ids, data, context)
return super(report_xls, self).create(cr, uid, ids, data, context)
def create_source_xls(self, cr, uid, ids, data, context=None):
if not context:
context = {}
parser_instance = self.parser(cr, uid, self.name2, context)
self.parser_instance = parser_instance
self.context = context
objs = self.getObjects(cr, uid, ids, context)
parser_instance.set_context(objs, data, ids, 'xls')
objs = parser_instance.localcontext['objects']
n = cStringIO.StringIO()
wb = xlwt.Workbook(encoding='utf-8')
_p = AttrDict(parser_instance.localcontext)
_xs = self.xls_styles
self.xls_headers = {
'standard': '',
}
report_date = datetime_field.context_timestamp(
cr, uid, datetime.now(), context)
report_date = report_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
self.xls_footers = {
'standard': (
'&L&%(font_size)s&%(font_style)s' + report_date +
'&R&%(font_size)s&%(font_style)s&P / &N'
) % self.hf_params,
}
self.generate_xls_report(_p, _xs, data, objs, wb)
wb.save(n)
n.seek(0)
return (n.read(), 'xls')
def render(self, wanted, col_specs, rowtype, render_space='empty'):
"""
returns 'evaluated' col_specs
Input:
- wanted: element from the wanted_list
- col_specs : cf. specs[1:] documented in xls_row_template method
- rowtype : 'header' or 'data'
- render_space : type dict, (caller_space + localcontext)
if not specified
"""
if render_space == 'empty':
render_space = {}
caller_space = inspect.currentframe().f_back.f_back.f_locals
localcontext = self.parser_instance.localcontext
render_space.update(caller_space)
render_space.update(localcontext)
row = col_specs[wanted][rowtype][:]
for i in range(len(row)):
if isinstance(row[i], CodeType):
row[i] = eval(row[i], render_space)
row.insert(0, wanted)
return row
def generate_xls_report(self, parser, xls_styles, data, objects, wb):
""" override this method to create your excel file """
raise NotImplementedError()
def xls_row_template(self, specs, wanted_list):
"""
Returns a row template.
Input :
- 'wanted_list': list of Columns that will be returned in the
row_template
- 'specs': list with Column Characteristics
0: Column Name (from wanted_list)
1: Column Colspan
2: Column Size (unit = the width of the character 0
as it appears in the sheets default font)
3: Column Type
4: Column Data
5: Column Formula (or 'None' for Data)
6: Column Style
"""
r = []
col = 0
for w in wanted_list:
found = False
for s in specs:
if s[0] == w:
found = True
s_len = len(s)
c = list(s[:5])
# set write_cell_func or formula
if s_len > 5 and s[5] is not None:
c.append({'formula': s[5]})
else:
c.append({
'write_cell_func': report_xls.xls_types[c[3]]})
# Set custom cell style
if s_len > 6 and s[6] is not None:
c.append(s[6])
else:
c.append(None)
# Set cell formula
if s_len > 7 and s[7] is not None:
c.append(s[7])
else:
c.append(None)
r.append((col, c[1], c))
col += c[1]
break
if not found:
_logger.warn("report_xls.xls_row_template, "
"column '%s' not found in specs", w)
return r
def xls_write_row(self, ws, row_pos, row_data,
row_style=default_style, set_column_size=False):
r = ws.row(row_pos)
for col, size, spec in row_data:
data = spec[4]
formula = spec[5].get('formula') and \
xlwt.Formula(spec[5]['formula']) or None
style = spec[6] and spec[6] or row_style
if not data:
# if no data, use default values
data = report_xls.xls_types_default[spec[3]]
if size != 1:
if formula:
ws.write_merge(
row_pos, row_pos, col, col + size - 1, data, style)
else:
ws.write_merge(
row_pos, row_pos, col, col + size - 1, data, style)
else:
if formula:
ws.write(row_pos, col, formula, style)
else:
spec[5]['write_cell_func'](r, col, data, style)
if set_column_size:
ws.col(col).width = spec[2] * 256
return row_pos + 1
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
report_xls/static/description/help.png

After

Width: 300  |  Height: 235  |  Size: 30 KiB

BIN
report_xls/static/description/icon.png

After

Width: 88  |  Height: 85  |  Size: 11 KiB

84
report_xls/static/description/index.html

@ -0,0 +1,84 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Excel report engine</h2>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<img src="open_receivables.png">
</div>
</div>
<div class="oe_span6">
<p class="oe_mt32">
<br><br>This module adds Excel export capabilities to the standard odoo reporting engine.
</p>
</div>
</div>
</section>
<section class="oe_spaced oe_container oe_dark">
<div class="oe_row">
<h2 class="oe_slogan">Report development</h2>
<p class="oe_mt32">
In order to create an Excel report you can
<ul>
<li>define a report of type 'xls'</li>
<li>pass <code>{'xls_export': 1}</code> via the context to the report create method</li>
</ul>
</p>
<p class="oe_mt32">
The <code>report_xls</code> class contains a number of attributes and methods to facilitate the creation XLS reports in odoo.
<ul>
<li>
cell types
<br>Supported cell types : text, number, boolean, date.
</li>
</ul>
<ul>
<li>
cell styles
<br>The predefined cell style definitions result in a consistent look and feel of the odoo Excel reports.
</li>
</ul>
<ul>
<li>
cell formulas
<br>Cell formulas can be easily added with the help of the <code>rowcol_to_cell()</code> function which you can import from the <code>utils.py</code> module.
</li>
</ul>
<ul>
<li>
Excel templates
<br>It is possible to define Excel templates which can be adapted by 'inherited' modules.
<br>Download the <b>account_move_line_report_xls</b> module from <a href="http://apps.odoo.com">http://apps.odoo.com</a> as example.
</li>
</ul>
<ul>
<li>
XLS with multiple sheets
<br>Download the <b>account_journal_report_xls</b> module from <a href="http://apps.odoo.com">http://apps.odoo.com</a> as example.
</li>
</ul>
</p>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Development assistance</h2>
</div>
<div class="oe_span6">
<br>
<div class="oe_picture">
<center><img src="help.png" height="150"></center>
</div>
</div>
<div class="oe_span6">
<p class="oe_mt32">
<br><br>Contact <a href="mailto:info@noviat.com">info@noviat.com</a> for help with the development of Excel reports in odoo.
</p>
</div>
</div>
</section>

BIN
report_xls/static/description/open_receivables.png

After

Width: 854  |  Height: 507  |  Size: 49 KiB

51
report_xls/utils.py

@ -0,0 +1,51 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
def _render(code):
return compile(code, '<string>', 'eval')
def rowcol_to_cell(row, col, row_abs=False, col_abs=False):
# Code based upon utils from xlwt distribution
"""
Convert numeric row/col notation to an Excel cell
reference string in A1 notation.
"""
d = col // 26
m = col % 26
chr1 = "" # Most significant character in AA1
if row_abs:
row_abs = '$'
else:
row_abs = ''
if col_abs:
col_abs = '$'
else:
col_abs = ''
if d > 0:
chr1 = chr(ord('A') + d - 1)
chr2 = chr(ord('A') + m)
# Zero index to 1-index
return col_abs + chr1 + chr2 + row_abs + str(row + 1)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

87
report_xlsx/README.rst

@ -0,0 +1,87 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
================
Base report xlsx
================
This module provides a basic report class to generate xlsx report.
Installation
============
Make sure you have ``xlsxwriter`` Python module installed::
$ pip install xlsxwriter
Usage
=====
An example of XLSX report for partners:
A python class ::
from openerp.addons.report_xlsx.report.report_xlsx import ReportXlsx
class PartnerXlsx(ReportXlsx):
def generate_xlsx_report(self, workbook, data, partners):
for obj in partners:
report_name = obj.name
# One sheet by partner
sheet = workbook.add_worksheet(report_name[:31])
bold = workbook.add_format({'bold': True})
sheet.write(0, 0, obj.name, bold)
PartnerXlsx('report.res.partner.xlsx',
'res.partner')
To manipulate the ``workbook`` and ``sheet`` objects, refer to the
`documentation <http://xlsxwriter.readthedocs.org/>`_ of ``xlsxwriter``.
A report XML record ::
<report
id="partner_xlsx"
model="res.partner"
string="Print to XLSX"
report_type="xlsx"
name="res.partner.xlsx"
file="res.partner.xlsx"
attachment_use="False"
/>
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/143/9.0
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
`here <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_xlsx%0Aversion:%209.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Adrien Peiffer <adrien.peiffer@acsone.eu>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

5
report_xlsx/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from . import report

19
report_xlsx/__openerp__.py

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': "Base report xlsx",
'summary': """
Base module to create xlsx report""",
'author': 'ACSONE SA/NV,'
'Odoo Community Association (OCA)',
'website': "http://acsone.eu",
'category': 'Reporting',
'version': '9.0.1.0.0',
'license': 'AGPL-3',
'external_dependencies': {'python': ['xlsxwriter']},
'depends': [
'base',
],
}

5
report_xlsx/models/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).+
from . import ir_report

11
report_xlsx/models/ir_report.py

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import fields, models
class IrActionsReportXml(models.Model):
_inherit = 'ir.actions.report.xml'
report_type = fields.Selection(selection_add=[("xlsx", "xlsx")])

4
report_xlsx/report/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import report_xlsx

45
report_xlsx/report/report_xlsx.py

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from cStringIO import StringIO
from openerp.report.report_sxw import report_sxw
from openerp.api import Environment
import logging
_logger = logging.getLogger(__name__)
try:
import xlsxwriter
except ImportError:
_logger.debug('Can not import xlsxwriter`.')
class ReportXlsx(report_sxw):
def create(self, cr, uid, ids, data, context=None):
self.env = Environment(cr, uid, context)
report_obj = self.env['ir.actions.report.xml']
report = report_obj.search([('report_name', '=', self.name[7:])])
if report.ids:
self.title = report.name
if report.report_type == 'xlsx':
return self.create_xlsx_report(ids, data, report)
return super(ReportXlsx, self).create(cr, uid, ids, data, context)
def create_xlsx_report(self, ids, data, report):
self.parser_instance = self.parser(
self.env.cr, self.env.uid, self.name2, self.env.context)
objs = self.getObjects(
self.env.cr, self.env.uid, ids, self.env.context)
self.parser_instance.set_context(objs, data, ids, 'xlsx')
file_data = StringIO()
workbook = xlsxwriter.Workbook(file_data)
self.generate_xlsx_report(workbook, data, objs)
workbook.close()
file_data.seek(0)
return (file_data.read(), 'xlsx')
def generate_xlsx_report(self, workbook, data, objs):
raise NotImplementedError()

BIN
report_xlsx/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

3
requirements.txt

@ -0,0 +1,3 @@
xlwt
xlsxwriter
py3o.template

2
setup/.setuptools-odoo-make-default-ignore

@ -0,0 +1,2 @@
# addons listed in this file are ignored by
# setuptools-odoo-make-default (one addon per line)

2
setup/README

@ -0,0 +1,2 @@
To learn more about this directory, please visit
https://pypi.python.org/pypi/setuptools-odoo

1
setup/report_py3o/odoo_addons/__init__.py

@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)

1
setup/report_py3o/odoo_addons/report_py3o

@ -0,0 +1 @@
../../../report_py3o

6
setup/report_py3o/setup.py

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

1
setup/report_qweb_element_page_visibility/odoo_addons/__init__.py

@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)

1
setup/report_qweb_element_page_visibility/odoo_addons/report_qweb_element_page_visibility

@ -0,0 +1 @@
../../../report_qweb_element_page_visibility

6
setup/report_qweb_element_page_visibility/setup.py

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

1
setup/report_xlsx/odoo_addons/__init__.py

@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)

1
setup/report_xlsx/odoo_addons/report_xlsx

@ -0,0 +1 @@
../../../report_xlsx

6
setup/report_xlsx/setup.py

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading…
Cancel
Save