|
@ -3,8 +3,10 @@ |
|
|
|
|
|
|
|
|
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.tools.safe_eval import safe_eval |
|
|
|
|
|
|
|
|
import json |
|
|
import json |
|
|
|
|
|
import time |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ReportController(report.ReportController): |
|
|
class ReportController(report.ReportController): |
|
@ -29,13 +31,18 @@ class ReportController(report.ReportController): |
|
|
xlsx = report.with_context(context).render_xlsx( |
|
|
xlsx = report.with_context(context).render_xlsx( |
|
|
docids, data=data |
|
|
docids, data=data |
|
|
)[0] |
|
|
)[0] |
|
|
|
|
|
report_name = report.report_file |
|
|
|
|
|
if report.print_report_name and not len(docids) > 1: |
|
|
|
|
|
obj = request.env[report.model].browse(docids[0]) |
|
|
|
|
|
report_name = safe_eval(report.print_report_name, |
|
|
|
|
|
{'object': obj, 'time': time}) |
|
|
xlsxhttpheaders = [ |
|
|
xlsxhttpheaders = [ |
|
|
('Content-Type', 'application/vnd.openxmlformats-' |
|
|
('Content-Type', 'application/vnd.openxmlformats-' |
|
|
'officedocument.spreadsheetml.sheet'), |
|
|
'officedocument.spreadsheetml.sheet'), |
|
|
('Content-Length', len(xlsx)), |
|
|
('Content-Length', len(xlsx)), |
|
|
( |
|
|
( |
|
|
'Content-Disposition', |
|
|
'Content-Disposition', |
|
|
content_disposition(report.report_file + '.xlsx') |
|
|
|
|
|
|
|
|
content_disposition(report_name + '.xlsx') |
|
|
) |
|
|
) |
|
|
] |
|
|
] |
|
|
return request.make_response(xlsx, headers=xlsxhttpheaders) |
|
|
return request.make_response(xlsx, headers=xlsxhttpheaders) |
|
|