[FIX] reports: Remove dead code for non qweb reports

This commit is contained in:
Toufik Benjaa
2018-03-22 15:33:18 +01:00
parent 2a9d3812a6
commit 4787bc7553
3 changed files with 2 additions and 101 deletions
-61
View File
@@ -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/<app>', auth='user')
def get_app_url(self, req, app):
@@ -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();
$('<a href="'+url+'" target="_blank"></a>')[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] === '/') {
@@ -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;
}
}
});