|
|
@ -3,16 +3,19 @@ |
|
|
|
|
|
|
|
from odoo.addons.web.controllers import main as report |
|
|
|
from odoo.http import content_disposition, route, request |
|
|
|
from odoo.exceptions import UserError, ValidationError |
|
|
|
from odoo.tools.safe_eval import safe_eval |
|
|
|
|
|
|
|
import json |
|
|
|
import time |
|
|
|
import werkzeug |
|
|
|
|
|
|
|
|
|
|
|
class ReportController(report.ReportController): |
|
|
|
@route() |
|
|
|
def report_routes(self, reportname, docids=None, converter=None, **data): |
|
|
|
if converter == 'xlsx': |
|
|
|
try: |
|
|
|
report = request.env['ir.actions.report']._get_report_from_name( |
|
|
|
reportname) |
|
|
|
context = dict(request.env.context) |
|
|
@ -36,6 +39,12 @@ class ReportController(report.ReportController): |
|
|
|
obj = request.env[report.model].browse(docids[0]) |
|
|
|
report_name = safe_eval(report.print_report_name, |
|
|
|
{'object': obj, 'time': time}) |
|
|
|
except (UserError, ValidationError) as odoo_error: |
|
|
|
raise werkzeug.exceptions.HTTPException( |
|
|
|
description='{error_name}. {error_value}'.format( |
|
|
|
error_name=odoo_error.name, |
|
|
|
error_value=odoo_error.value, |
|
|
|
)) |
|
|
|
xlsxhttpheaders = [ |
|
|
|
('Content-Type', 'application/vnd.openxmlformats-' |
|
|
|
'officedocument.spreadsheetml.sheet'), |
|
|
|