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