Skip to Content
Menu
This question has been flagged
3853 Views

How I can load a report in a Modal div with Ajax?

I create a Route;

    @http.route(['/account/orders/<int:order>'], type='http', auth="user", website=True)

def orders_followup(self, order=None, **data):

This return a Html report:

html = request.env['report'].sudo().with_context(context).get_html(order, 'sale.report_saleorder', data=data)

return request.make_response(html)


On my side I Create a Ajax Load function:

$(document).ready(function(){

// Load Html Side

$('.openModelLoader').on('click',function(){

// Backup is something loaded in Model-Body

$('.modal-body').empty();

// Add Loading Icon

$('.modal-title').text($(this).attr("name"));

$('.modal-body').append('<div class="loaderSvg">');

$('.loaderSvg').append

(

'<img src="/theme_evologics/static/src/img/icons/loading_spinner.svg"/>',

'<h2>Loading</h2>',

);

var token = $('input[name=csrf_token]').val();

var dataURL = $(this).attr('data-href');

// dataURL = dataURL.concat('?', 'csrf_token=' + token);

$('.modal-body').load(dataURL);

});

// Unload model body

$('.ModelLoader').on('hidden.bs.modal', function () {

$('.modal-body').empty();

})

});


The Problem is Odoo give me a weard Error:

2018-04-06 15:34:25,502 9220 INFO evo werkzeug: 192.168.3.116 - - [06/Apr/2018 15:34:25] "GET /web/content/357-21e5012/web.assets_common.js?_=1523028860751 HTTP/1.1" 500 -

2018-04-06 15:34:25,522 9220 ERROR evo werkzeug: Error on request:

Traceback (most recent call last):

File "/home/dima/.local/lib/python2.7/site-packages/werkzeug/serving.py", line 193, in run_wsgi

execute(self.server.app)

File "/home/dima/.local/lib/python2.7/site-packages/werkzeug/serving.py", line 181, in execute

application_iter = app(environ, start_response)

File "/media/sf_ShareFolder/odoo/odoo/service/server.py", line 246, in app

return self.app(e, s)

File "/media/sf_ShareFolder/odoo/odoo/service/wsgi_server.py", line 186, in application

return application_unproxied(environ, start_response)

File "/media/sf_ShareFolder/odoo/odoo/service/wsgi_server.py", line 172, in application_unproxied

result = handler(environ, start_response)

File "/media/sf_ShareFolder/odoo/odoo/http.py", line 1314, in __call__

return self.dispatch(environ, start_response)

File "/media/sf_ShareFolder/odoo/odoo/http.py", line 1288, in __call__

return self.app(environ, start_wrapped)

File "/home/dima/.local/lib/python2.7/site-packages/werkzeug/wsgi.py", line 599, in __call__

return self.app(environ, start_response)

File "/media/sf_ShareFolder/odoo/odoo/http.py", line 1487, in dispatch

result = ir_http._dispatch()

File "/media/sf_ShareFolder/odoo/addons/website/models/ir_http.py", line 218, in _dispatch

resp = super(Http, cls)._dispatch()

File "/media/sf_ShareFolder/odoo/addons/web_editor/models/ir_http.py", line 21, in _dispatch

return super(IrHttp, cls)._dispatch()

File "/media/sf_ShareFolder/odoo/addons/utm/models/ir_http.py", line 20, in _dispatch

response = super(IrHttp, cls)._dispatch()

File "/media/sf_ShareFolder/odoo/odoo/addons/base/ir/ir_http.py", line 199, in _dispatch

return cls._handle_exception(e)

File "/media/sf_ShareFolder/odoo/addons/website/models/ir_http.py", line 270, in _handle_exception

return super(Http, cls)._handle_exception(exception)

File "/media/sf_ShareFolder/odoo/odoo/addons/base/ir/ir_http.py", line 169, in _handle_exception

return request._handle_exception(exception)

File "/media/sf_ShareFolder/odoo/odoo/http.py", line 774, in _handle_exception

return super(HttpRequest, self)._handle_exception(exception)

File "/media/sf_ShareFolder/odoo/odoo/addons/base/ir/ir_http.py", line 195, in _dispatch

result = request.dispatch()

File "/media/sf_ShareFolder/odoo/odoo/http.py", line 833, in dispatch

r = self._call_function(**self.params)

File "/media/sf_ShareFolder/odoo/odoo/http.py", line 333, in _call_function

return checked_call(self.db, *args, **kwargs)

File "/media/sf_ShareFolder/odoo/odoo/service/model.py", line 101, in wrapper

return f(dbname, *args, **kwargs)

File "/media/sf_ShareFolder/odoo/odoo/http.py", line 326, in checked_call

result = self.endpoint(*a, **kw)

File "/media/sf_ShareFolder/odoo/odoo/http.py", line 941, in __call__

return self.method(*args, **kw)

File "/media/sf_ShareFolder/odoo/odoo/http.py", line 506, in response_wrap

response = f(*args, **kw)

I not understand why Odoo create this line:

  "GET /web/content/357-21e5012/web.assets_common.js?_=1523028860751 HTTP/1.1" 500 


Can someone help me?  

Avatar
Discard
Related Posts Replies Views Activity
0
Jul 21
1098
2
Sep 23
2484
5
Dec 24
6986
0
Dec 24
56
0
Dec 24
39