-
-
Notifications
You must be signed in to change notification settings - Fork 787
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
963 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Addons modules by CLEARCORP S.A. | ||
# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>). | ||
# | ||
# 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 | ||
from . import controllers | ||
from . import ir_actions_report_xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Addons modules by CLEARCORP S.A. | ||
# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>). | ||
# | ||
# 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': 'XLS Reports', | ||
'version': '1.0', | ||
'category': 'Base', | ||
'sequence': 16, | ||
'summary': 'XLS format QWeb Reports', | ||
'description': """ | ||
Reports in XLS format | ||
===================== | ||
Allow you to print reports on xls format. | ||
Main Features | ||
------------- | ||
* Uses QWeb templates | ||
* Allows the creation of worksheets | ||
* Supports base 64 encoded 24 bits True Color bitmaps""", | ||
'author': 'ClearCorp', | ||
'website': 'http://clearcorp.co.cr', | ||
'complexity': 'normal', | ||
'images': [], | ||
'depends': ['report'], | ||
'data': [ | ||
'report_xls_view.xml', | ||
'views/assets.xml', | ||
], | ||
'test': [], | ||
'demo': [], | ||
'installable': True, | ||
'auto_install': False, | ||
'application': False, | ||
'license': 'AGPL-3', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Addons modules by CLEARCORP S.A. | ||
# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>). | ||
# | ||
# 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 main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Addons modules by CLEARCORP S.A. | ||
# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>). | ||
# | ||
# 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/>. | ||
# | ||
############################################################################## | ||
# Code inspired by OpenERP SA report module | ||
############################################################################## | ||
|
||
import simplejson | ||
from werkzeug import exceptions, url_decode | ||
from openerp.osv import osv | ||
from openerp.addons.web.http import Controller, route, request | ||
from openerp.addons.web.controllers.main import _serialize_exception | ||
|
||
|
||
class ReportXLSController(Controller): | ||
|
||
@route([ | ||
'/reportxlstemplate/<path:converter>/<reportname>', | ||
'/reportxlstemplate/<path:converter>/<reportname>/<docids>', | ||
], type='http', auth='user', website=True) | ||
def report_routes(self, reportname, docids=None, converter=None, **data): | ||
report_obj = request.registry['report'] | ||
cr, uid, context = request.cr, request.uid, request.context | ||
|
||
if docids: | ||
docids = [int(i) for i in docids.split(',')] | ||
options_data = None | ||
if data.get('options'): | ||
options_data = simplejson.loads(data['options']) | ||
if data.get('context'): | ||
# Ignore 'lang' here, because the context in data is the | ||
# one from the webclient *but* if the user explicitely | ||
# wants to change the lang, this mechanism overwrites it. | ||
data_context = simplejson.loads(data['context']) | ||
if data_context.get('lang'): | ||
del data_context['lang'] | ||
context.update(data_context) | ||
|
||
if converter == 'xls': | ||
xls = report_obj.get_xls(cr, uid, docids, reportname, | ||
data=options_data, context=context) | ||
xlshttpheaders = [('Content-Type', 'application/vnd.ms-excel'), | ||
('Content-Length', len(xls))] | ||
return request.make_response(xls, headers=xlshttpheaders) | ||
elif converter == 'ods': | ||
ods = report_obj.get_ods(cr, uid, docids, reportname, | ||
data=options_data, context=context) | ||
odshttpheaders = [ | ||
('Content-Type', | ||
'application/vnd.oasis.opendocument.spreadsheet'), | ||
('Content-Length', len(ods))] | ||
return request.make_response(ods, headers=odshttpheaders) | ||
else: | ||
raise exceptions.HTTPException( | ||
description='Converter %s not implemented.' % converter) | ||
|
||
@route(['/reportxlstemplate/download'], type='http', auth="user") | ||
def report_download(self, data, token): | ||
"""This function is used by 'report_xls.js' in order to | ||
trigger the download of xls/ods report. | ||
:param data: a javascript array JSON.stringified containg | ||
report internal url ([0]) and type [1] | ||
:returns: Response with a filetoken cookie and an attachment header | ||
""" | ||
requestcontent = simplejson.loads(data) | ||
url, report_type = requestcontent[0], requestcontent[1] | ||
try: | ||
if report_type == 'qweb-xls': | ||
reportname = url.split( | ||
'/reportxlstemplate/xls/')[1].split('?')[0] | ||
docids = None | ||
if '/' in reportname: | ||
reportname, docids = reportname.split('/') | ||
if docids: | ||
# Generic report: | ||
response = self.report_routes( | ||
reportname, docids=docids, converter='xls') | ||
else: | ||
# Particular report: | ||
# Decoding the args represented in JSON | ||
data = url_decode(url.split('?')[1]).items() | ||
response = self.report_routes( | ||
reportname, converter='xls', **dict(data)) | ||
|
||
response.headers.add( | ||
'Content-Disposition', | ||
'attachment; filename=%s.xls;' % reportname) | ||
response.set_cookie('fileToken', token) | ||
return response | ||
elif report_type == 'qweb-ods': | ||
reportname = url.split( | ||
'/reportxlstemplate/ods/')[1].split('?')[0] | ||
docids = None | ||
if '/' in reportname: | ||
reportname, docids = reportname.split('/') | ||
if docids: | ||
# Generic report: | ||
response = self.report_routes( | ||
reportname, docids=docids, converter='ods') | ||
else: | ||
# Particular report: | ||
# Decoding the args represented in JSON | ||
data = url_decode(url.split('?')[1]).items() | ||
response = self.report_routes( | ||
reportname, converter='ods', **dict(data)) | ||
|
||
response.headers.add( | ||
'Content-Disposition', | ||
'attachment; filename=%s.ods;' % reportname) | ||
response.set_cookie('fileToken', token) | ||
return response | ||
else: | ||
return | ||
except osv.except_osv, e: | ||
se = _serialize_exception(e) | ||
error = { | ||
'code': 200, | ||
'message': "Odoo Server Error", | ||
'data': se | ||
} | ||
return request.make_response(simplejson.dumps(error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * report_xls_template | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2015-07-10 16:48+0000\n" | ||
"PO-Revision-Date: 2015-07-10 16:48+0000\n" | ||
"Last-Translator: Glen Sojo <glen.sojo@clearcorp.co.cr>\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_xls_template | ||
#: code:addons/report_xls_template/report.py:343 | ||
#, python-format | ||
msgid "An error occurred while parsing the view into file." | ||
msgstr "Un error ocurrió mientras se convertía la vista en un archivo." | ||
|
||
#. module: report_xls_template | ||
#: code:addons/report_xls_template/report.py:289 | ||
#: code:addons/report_xls_template/report.py:292 | ||
#, python-format | ||
msgid "Data" | ||
msgstr "Datos" | ||
|
||
#. module: report_xls_template | ||
#: code:addons/report_xls_template/report.py:290 | ||
#, python-format | ||
msgid "Invalid worksheet name." | ||
msgstr "Nombre de hoja de cálculo inválido." | ||
|
||
#. module: report_xls_template | ||
#: model:ir.model,name:report_xls_template.model_report | ||
msgid "Report" | ||
msgstr "Informe" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * report_xls_template | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2015-07-10 16:48+0000\n" | ||
"PO-Revision-Date: 2015-07-10 16:48+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_xls_template | ||
#: code:addons/report_xls_template/report.py:343 | ||
#, python-format | ||
msgid "An error occurred while parsing the view into file." | ||
msgstr "" | ||
|
||
#. module: report_xls_template | ||
#: code:addons/report_xls_template/report.py:289 | ||
#: code:addons/report_xls_template/report.py:292 | ||
#, python-format | ||
msgid "Data" | ||
msgstr "" | ||
|
||
#. module: report_xls_template | ||
#: code:addons/report_xls_template/report.py:290 | ||
#, python-format | ||
msgid "Invalid worksheet name." | ||
msgstr "" | ||
|
||
#. module: report_xls_template | ||
#: model:ir.model,name:report_xls_template.model_report | ||
msgid "Report" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Addons modules by CLEARCORP S.A. | ||
# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>). | ||
# | ||
# 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 | ||
|
||
REPORT_TYPES = [('qweb-xls', 'XLS'), ('qweb-ods', 'ODS')] | ||
|
||
|
||
class ReportAction(models.Model): | ||
|
||
_inherit = 'ir.actions.report.xml' | ||
|
||
def _lookup_report(self, cr, name): | ||
""" | ||
Look up a report definition. | ||
""" | ||
cr.execute( | ||
'SELECT * FROM ir_act_report_xml WHERE report_name=%s', | ||
(name,)) | ||
r = cr.dictfetchone() | ||
if r: | ||
# Check if the report type fits with xls or ods reports | ||
if r['report_type'] in ['qweb-xls', 'qweb-ods']: | ||
# Return tuple (report name, report_type, module name) | ||
return (r['report_name'], | ||
r['report_type'], | ||
'report_xls_template') | ||
return super(ReportAction, self)._lookup_report(cr, name) | ||
|
||
def render_report(self, cr, uid, res_ids, name, data, context=None): | ||
""" | ||
Look up a report definition and render the report for the provided IDs. | ||
""" | ||
new_report = self._lookup_report(cr, name) | ||
|
||
if isinstance(new_report, tuple): # Check the type of object | ||
# Check if the module is report_xls_template | ||
if new_report[2] == 'report_xls_template': | ||
# Check report type | ||
if new_report[1] == 'qweb-xls': | ||
return self.pool['report'].get_xls( | ||
cr, uid, res_ids, new_report[0], | ||
data=data, context=context), 'xls' | ||
elif new_report[1] == 'qweb-ods': | ||
return self.pool['report'].get_ods( | ||
cr, uid, res_ids, new_report[0], | ||
data=data, context=context), 'xls' | ||
return super(ReportAction, self).render_report( | ||
cr, uid, res_ids, name, data, context=context) | ||
|
||
report_type = fields.Selection(selection_add=REPORT_TYPES) |
Oops, something went wrong.