From 4787bc7553f31377822648d5f67de0a3bba0e0a2 Mon Sep 17 00:00:00 2001 From: Toufik Benjaa Date: Thu, 22 Mar 2018 15:33:18 +0100 Subject: [PATCH] [FIX] reports: Remove dead code for non qweb reports --- addons/web/controllers/main.py | 61 ------------------- .../static/src/js/chrome/action_manager.js | 39 ------------ .../static/src/js/report/qwebactionmanager.js | 3 +- 3 files changed, 2 insertions(+), 101 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 77076101a0c..6b73f28ca7d 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -44,7 +44,6 @@ from odoo.http import content_disposition, dispatch_rpc, request, \ from odoo.exceptions import AccessError, UserError from odoo.models import check_method_name from odoo.service import db -from odoo.service.report import exp_report, exp_report_get _logger = logging.getLogger(__name__) @@ -1495,66 +1494,6 @@ class ExcelExport(ExportFormat, http.Controller): fp.close() return data -class Reports(http.Controller): - POLLING_DELAY = 0.25 - TYPES_MAPPING = { - 'doc': 'application/vnd.ms-word', - 'html': 'text/html', - 'odt': 'application/vnd.oasis.opendocument.text', - 'pdf': 'application/pdf', - 'sxw': 'application/vnd.sun.xml.writer', - 'xls': 'application/vnd.ms-excel', - } - - @http.route('/web/report', type='http', auth="user") - @serialize_exception - def index(self, action, token): - action = json.loads(action) - - context = dict(request.context) - context.update(action["context"]) - - report_data = {} - report_ids = context.get("active_ids", None) - if 'report_type' in action: - report_data['report_type'] = action['report_type'] - if 'datas' in action: - if 'ids' in action['datas']: - report_ids = action['datas'].pop('ids') - report_data.update(action['datas']) - - report_id = exp_report(request.session.db, request.session.uid, action["report_name"], report_ids, report_data, context) - - report_struct = None - while True: - report_struct = exp_report_get(request.session.db, request.session.uid, report_id) - if report_struct["state"]: - break - - time.sleep(self.POLLING_DELAY) - - report = base64.b64decode(report_struct['result']) - if report_struct.get('code') == 'zlib': - report = zlib.decompress(report) - report_mimetype = self.TYPES_MAPPING.get( - report_struct['format'], 'octet-stream') - file_name = action.get('name', 'report') - if 'name' not in action: - reports = request.env['ir.actions.report'] - reports = reports.search([('report_name', '=', action['report_name'])]) - if reports: - file_name = reports[0].name - else: - file_name = action['report_name'] - file_name = '%s.%s' % (file_name, report_struct['format']) - - return request.make_response(report, - headers=[ - ('Content-Disposition', content_disposition(file_name)), - ('Content-Type', report_mimetype), - ('Content-Length', len(report))], - cookies={'fileToken': token}) - class Apps(http.Controller): @http.route('/apps/', auth='user') def get_app_url(self, req, app): diff --git a/addons/web/static/src/js/chrome/action_manager.js b/addons/web/static/src/js/chrome/action_manager.js index 905d9c1c3b9..df4221771d6 100644 --- a/addons/web/static/src/js/chrome/action_manager.js +++ b/addons/web/static/src/js/chrome/action_manager.js @@ -903,45 +903,6 @@ var ActionManager = Widget.extend({ return self.do_action(action, options); }); }, - ir_actions_report: function(action, options) { - var self = this; - framework.blockUI(); - action = _.clone(action); - var eval_contexts = ([session.user_context] || []).concat([action.context]); - action.context = pyeval.eval('contexts',eval_contexts); - - // iOS devices doesn't allow iframe use the way we do it, - // opening a new window seems the best way to workaround - if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) { - var params = { - action: JSON.stringify(action), - token: new Date().getTime() - }; - var url = session.url('/web/report', params); - framework.unblockUI(); - $('')[0].click(); - return; - } - var c = crash_manager; - return $.Deferred(function (d) { - session.get_file({ - url: '/web/report', - data: {action: JSON.stringify(action)}, - complete: framework.unblockUI, - success: function(){ - if (!self.dialog) { - options.on_close(); - } - self.dialog_stop(); - d.resolve(); - }, - error: function () { - c.rpc_error.apply(c, arguments); - d.reject(); - } - }); - }); - }, ir_actions_act_url: function (action, options) { var url = action.url; if (session.debug && url && url.length && url[0] === '/') { diff --git a/addons/web/static/src/js/report/qwebactionmanager.js b/addons/web/static/src/js/report/qwebactionmanager.js index cc875882ce2..1c9e6803f43 100644 --- a/addons/web/static/src/js/report/qwebactionmanager.js +++ b/addons/web/static/src/js/report/qwebactionmanager.js @@ -135,7 +135,8 @@ ActionManager.include({ } }); } else { - return self._super(action, options); + self.do_warn(_t('Error'), _t('Non qweb reports are not anymore supported.'), true); + return; } } });