diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 412e74a5b6a..0e25e098ec8 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1093,15 +1093,6 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie }, }); -openerp.currentScript = function() { - var currentScript = document.currentScript; - if (!currentScript) { - var sc = document.getElementsByTagName('script'); - currentScript = sc[sc.length-1]; - } - return currentScript; -}; - openerp.web.EmbeddedClient = openerp.web.Widget.extend({ template: 'EmptyComponent', init: function(action_id, options) { @@ -1114,9 +1105,7 @@ openerp.web.EmbeddedClient = openerp.web.Widget.extend({ start: function() { var self = this; - this.am.appendTo(this.$element.addClass('openerp')); - return this.rpc("/web/action/load", { action_id: this.action_id }, function(result) { var action = result.result; action.flags = _.extend({ @@ -1133,6 +1122,19 @@ openerp.web.EmbeddedClient = openerp.web.Widget.extend({ }); +openerp.web.embed = function (origin, dbname, login, key, action, options) { + var currentScript = document.currentScript; + if (!currentScript) { + var sc = document.getElementsByTagName('script'); + currentScript = sc[sc.length-1]; + } + openerp.connection.bind(origin).then(function () { + openerp.connection.session_authenticate(dbname, login, key).then(function () { + var client = new session.web.EmbeddedClient(action_id, options); + client.insertAfter(currentScript); + }); + }); +} };