[FIX] edi: temptative fix for edi controllers (wip)
bzr revid: odo@openerp.com-20111013145912-zru7msgt9aodsdir
This commit is contained in:
parent
25a5eee6fc
commit
adbe3bf5ef
|
@ -7,8 +7,8 @@ class EDIGet(openerpweb.Controller):
|
|||
_cp_path = "/web/get_edi"
|
||||
|
||||
@openerpweb.httprequest
|
||||
def index(self, req, token, db):
|
||||
result = req.session.proxy('edi').get_edi_document(token, db)
|
||||
def index(self, req, db, token):
|
||||
result = req.session.proxy('edi').get_edi_document(db, token)
|
||||
response = werkzeug.wrappers.Response(
|
||||
result, headers=[('Content-Type', 'text/html; charset=utf-8'),
|
||||
('Content-Length', len(result))])
|
||||
|
@ -16,11 +16,10 @@ class EDIGet(openerpweb.Controller):
|
|||
return response
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
def get_edi_document(self, req, token, db):
|
||||
result = req.session.proxy('edi').get_edi_document(token, db)
|
||||
def get_edi_document(self, req, db, token):
|
||||
result = req.session.proxy('edi').get_edi_document(db, token)
|
||||
document = json.loads(result)
|
||||
model = document and document[0].get('__model')
|
||||
return {'token': token, 'db': db, 'model':model.replace('.','_'), 'document':document}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@ import web.controllers.main as web
|
|||
import json
|
||||
import textwrap
|
||||
|
||||
|
||||
|
||||
edi_import_template = textwrap.dedent("""<!DOCTYPE html>
|
||||
<html style="height: 100%%">
|
||||
<head>
|
||||
|
@ -15,17 +13,13 @@ edi_import_template = textwrap.dedent("""<!DOCTYPE html>
|
|||
|
||||
%(css)s
|
||||
%(javascript)s
|
||||
<script type="text/javascript" src="/web_edi/static/src/js/edi_import.js"></script>
|
||||
<script type="text/javascript" src="/edi/static/src/js/edi_import.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var c = new openerp.init();
|
||||
|
||||
openerp.web.edi_import(c)
|
||||
|
||||
var import_engine = new c.web.EdiImport("oe");
|
||||
import_engine.import_edi('%(edi_url)s');
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -33,7 +33,10 @@ edi_view_template = textwrap.dedent("""<!DOCTYPE html>
|
|||
""")
|
||||
|
||||
def edi_addons():
|
||||
_addons = ['web', 'edi']
|
||||
#FIXME: hardcoded to be able to test
|
||||
return 'web,edi,sale,purchase'
|
||||
|
||||
_addons = ['web', 'edi', 'sale', 'purchase']
|
||||
for addon in openerpweb.addons_module:
|
||||
if addon in _addons:
|
||||
continue
|
||||
|
@ -50,14 +53,14 @@ class EDIView(web.WebClient):
|
|||
@openerpweb.httprequest
|
||||
def css(self, req):
|
||||
files = self.manifest_glob(req, edi_addons(), 'css')
|
||||
content,timestamp = web.concat_files(req.config.addons_path, files)
|
||||
content,timestamp = web.concat_files(req.config.addons_path[0], files)
|
||||
# TODO request set the Date of last modif and Etag
|
||||
return req.make_response(content, [('Content-Type', 'text/css')])
|
||||
|
||||
@openerpweb.httprequest
|
||||
def js(self, req):
|
||||
files = self.manifest_glob(req, edi_addons(), 'js')
|
||||
content,timestamp = web.concat_files(req.config.addons_path, files)
|
||||
content,timestamp = web.concat_files(req.config.addons_path[0], files)
|
||||
# TODO request set the Date of last modif and Etag
|
||||
return req.make_response(content, [('Content-Type', 'application/javascript')])
|
||||
|
||||
|
|
|
@ -31,13 +31,13 @@ class edi(netsvc.ExportService):
|
|||
netsvc.ExportService.__init__(self, name)
|
||||
|
||||
def _edi_dispatch(self, db_name, method_name, *method_args):
|
||||
registry = openerp.modules.registry.RegistryManager.get(db_name)
|
||||
assert registry, 'Unknown database %s' % db_name
|
||||
edi_document = registry['edi.document']
|
||||
cr = registry.db.cursor()
|
||||
try:
|
||||
registry = openerp.modules.registry.RegistryManager.get(db_name)
|
||||
assert registry, 'Unknown database %s' % db_name
|
||||
edi_document = registry['edi.document']
|
||||
cr = registry.db.cursor()
|
||||
res = None
|
||||
res = getattr(edi_document,method_name)(cr, *method_args)
|
||||
res = getattr(edi_document, method_name)(cr, *method_args)
|
||||
cr.commit()
|
||||
except Exception:
|
||||
_logger.exception('Failed to execute EDI method %s with args %r', method_name, method_args)
|
||||
|
@ -49,11 +49,11 @@ class edi(netsvc.ExportService):
|
|||
def exp_get_edi_document(self, db_name, edi_token):
|
||||
return self._edi_dispatch(db_name, 'get_document', 1, edi_token)
|
||||
|
||||
def exp_import_edi_document(self, db, uid, passwd, edi_document, context=None):
|
||||
return self._edi_dispatch(db_name, 'import_edi', 1, edi_document, None)
|
||||
def exp_import_edi_document(self, db_name, uid, passwd, edi_document, context=None):
|
||||
return self._edi_dispatch(db_name, 'import_edi', uid, edi_document, None)
|
||||
|
||||
def exp_import_edi_url(self, db, uid, passwd, edi_url, context=None):
|
||||
return self._edi_dispatch(db_name, 'import_edi', 1, None, edi_url)
|
||||
def exp_import_edi_url(self, db_name, uid, passwd, edi_url, context=None):
|
||||
return self._edi_dispatch(db_name, 'import_edi', uid, None, edi_url)
|
||||
|
||||
def dispatch(self, method, params):
|
||||
if method in ['import_edi_document', 'import_edi_url']:
|
||||
|
|
|
@ -9,7 +9,7 @@ openerp.web.edi_view = function(openerp) {
|
|||
this.template = "EdiView";
|
||||
this.element_id = element_id;
|
||||
this.$element = $('#' + element_id);
|
||||
QWeb.add_template("/web_edi/static/src/xml/edi.xml");
|
||||
QWeb.add_template("/edi/static/src/xml/edi.xml");
|
||||
|
||||
},
|
||||
start: function() {
|
||||
|
@ -69,7 +69,7 @@ openerp.web.EdiViewCenter = openerp.web.Class.extend({
|
|||
var self = this;
|
||||
this.edi_document = edi.document;
|
||||
this.$element = element;
|
||||
QWeb.add_template("/web_edi/static/src/xml/edi.xml");
|
||||
QWeb.add_template("/edi/static/src/xml/edi.xml");
|
||||
},
|
||||
start: function() {
|
||||
},
|
||||
|
@ -85,7 +85,7 @@ openerp.web.EdiViewRightTop = openerp.web.Class.extend({
|
|||
var self = this;
|
||||
this.edi_document = edi.document;
|
||||
this.$element = element;
|
||||
QWeb.add_template("/web_edi/static/src/xml/edi.xml");
|
||||
QWeb.add_template("/edi/static/src/xml/edi.xml");
|
||||
this.$_element = $('<div>')
|
||||
.appendTo(document.body)
|
||||
.delegate('button.oe_edi_button_import', 'click', {'edi': edi} , this.do_import)
|
||||
|
@ -135,7 +135,7 @@ openerp.web.EdiViewRightBottom = openerp.web.Class.extend({
|
|||
var self = this;
|
||||
this.edi_document = edi.document;
|
||||
this.$element = element;
|
||||
QWeb.add_template("/web_edi/static/src/xml/edi.xml");
|
||||
QWeb.add_template("/edi/static/src/xml/edi.xml");
|
||||
},
|
||||
start: function() {
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue