Hello
I have create one wizard and take a field binary file for store file name.
While opening wizard, the file name appears from default_get method.
My Code is shown below:-
class wiz_print_excel(models.TransientModel):
_name = 'wiz.print.excel'
@api.model
def default_get(self, fields):
rec = super(wiz_print_excel, self).default_get(fields)
rec['name'] = 'Presentation.xls'
rec['file'] = 'file'
return rec
file = fields.Binary('File')
name = fields.Char(string='File Name', size=32)
@api.multi
def print_excel_report(self):
workbook = xlwt.Workbook()
worksheet = workbook.add_sheet('Sheet 1')
worksheet.write_merge(0, 0, 2, 8, 'Lucent Jewels Inc', GREEN_TABLE_HEADER)
workbook.save('/Downloads/Presentation.xls')
Click on Print button of wizard, File saved this location. But when i click on download, errors was occurred.
It gives different error front end as well as back end.
Front End Error:-
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
http://0.0.0.0:8069/web/static/src/js/framework/ajax.js:230 Traceback: get_file/$target<@http://0.0.0.0:8069/web/static/src/js/framework/ajax.js:230:35 jQuery.event.dispatch@http://0.0.0.0:8069/web/static/lib/jquery/jquery.js:4640:50 jQuery.event.add/elemData.handle@http://0.0.0.0:8069/web/static/lib/jquery/jquery.js:4309:41
Back End Error :-
File "/usr/share/pyshared/werkzeug/serving.py", line 159, in run_wsgi
execute(app)
File "/usr/share/pyshared/werkzeug/serving.py", line 146, in execute
application_iter = app(environ, start_response)
File "/home/jigneshm/workspace/odoo/openerp/service/server.py", line 245, in app
return self.app(e, s)
File "/home/jigneshm/workspace/odoo/openerp/service/wsgi_server.py", line 184, in application
return application_unproxied(environ, start_response)
File "/home/jigneshm/workspace/odoo/openerp/service/wsgi_server.py", line 170, in application_unproxied
result = handler(environ, start_response)
File "/home/jigneshm/workspace/odoo/openerp/http.py", line 1422, in __call__
return self.dispatch(environ, start_response)
File "/home/jigneshm/workspace/odoo/openerp/http.py", line 1396, in __call__
return self.app(environ, start_wrapped)
File "/usr/share/pyshared/werkzeug/wsgi.py", line 411, in __call__
return self.app(environ, start_response)
File "/home/jigneshm/workspace/odoo/openerp/http.py", line 1586, in dispatch
result = ir_http._dispatch()
File "/home/jigneshm/workspace/odoo/addons/web_editor/models/ir_http.py", line 16, in _dispatch
return super(ir_http, self)._dispatch()
File "/home/jigneshm/workspace/odoo/openerp/addons/base/ir/ir_http.py", line 186, in _dispatch
return self._handle_exception(e)
File "/home/jigneshm/workspace/odoo/openerp/addons/base/ir/ir_http.py", line 157, in _handle_exception
return request._handle_exception(exception)
File "/home/jigneshm/workspace/odoo/openerp/http.py", line 743, in _handle_exception
return super(HttpRequest, self)._handle_exception(exception)
File "/home/jigneshm/workspace/odoo/openerp/addons/base/ir/ir_http.py", line 182, in _dispatch
result = request.dispatch()
File "/home/jigneshm/workspace/odoo/openerp/http.py", line 774, in dispatch
r = self._call_function(**self.params)
File "/home/jigneshm/workspace/odoo/openerp/http.py", line 316, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/jigneshm/workspace/odoo/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/home/jigneshm/workspace/odoo/openerp/http.py", line 309, in checked_call
result = self.endpoint(*a, **kw)
File "/home/jigneshm/workspace/odoo/openerp/http.py", line 893, in __call__
return self.method(*args, **kw)
File "/home/jigneshm/workspace/odoo/openerp/http.py", line 471, in response_wrap
response = f(*args, **kw)
File "/home/jigneshm/key_concept_jc/web/controllers/main.py", line 1049, in content_common
response.set_cookie('fileToken', token)
AttributeError: 'NotFound' object has no attribute 'set_cookie'
Hope you understand my question.
Thanks in advance.