2012-08-14 12:16:10 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import simplejson
|
|
|
|
|
2012-10-10 20:46:17 +00:00
|
|
|
import openerp
|
2012-08-14 12:16:10 +00:00
|
|
|
|
2012-10-10 20:46:17 +00:00
|
|
|
class ImportController(openerp.addons.web.http.Controller):
|
2012-08-14 12:16:10 +00:00
|
|
|
_cp_path = '/base_import'
|
|
|
|
|
2012-10-10 20:46:17 +00:00
|
|
|
@openerp.addons.web.http.httprequest
|
2012-08-14 12:16:10 +00:00
|
|
|
def set_file(self, req, file, import_id, jsonp='callback'):
|
|
|
|
import_id = int(import_id)
|
|
|
|
|
|
|
|
written = req.session.model('base_import.import').write(import_id, {
|
2012-08-30 10:32:15 +00:00
|
|
|
'file': file.read(),
|
2012-08-14 12:16:10 +00:00
|
|
|
'file_name': file.filename,
|
|
|
|
'file_type': file.content_type,
|
2012-11-27 16:45:43 +00:00
|
|
|
}, req.context)
|
2012-08-14 12:16:10 +00:00
|
|
|
|
|
|
|
return 'window.top.%s(%s)' % (
|
|
|
|
jsonp, simplejson.dumps({'result': written}))
|