From 4ce75b1f7a60406523137680c1edbb5399a574f4 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 10 Nov 2011 11:21:53 +0100 Subject: [PATCH] [FIX] adpat web modules to changes in webclient [FIX] enable some web module only when there is a webclient (prepare embed) bzr revid: chs@openerp.com-20111110102153-pgktyws0gdgyq4f5 --- addons/pad/__openerp__.py | 3 ++ addons/pad/static/src/js/pad.js | 3 -- addons/share/__openerp__.py | 3 ++ addons/share/static/src/js/share.js | 9 ++-- addons/web_livechat/__openerp__.py | 3 ++ .../static/src/js/web_livechat.js | 47 +++++++++---------- addons/web_uservoice/__openerp__.py | 3 ++ .../static/src/js/web_uservoice.js | 20 ++++---- 8 files changed, 46 insertions(+), 45 deletions(-) diff --git a/addons/pad/__openerp__.py b/addons/pad/__openerp__.py index 9bbeb558375..1abf8f0ebfa 100644 --- a/addons/pad/__openerp__.py +++ b/addons/pad/__openerp__.py @@ -22,5 +22,8 @@ Lets the company customize which Pad installation should be used to link to new 'web': True, 'certificate' : '001183545978470526509', 'js': ['static/src/js/pad.js'], + 'qweb' : [ + "static/src/xml/*.xml", + ], 'images': ['static/src/img/pad_link_companies.jpeg'], } diff --git a/addons/pad/static/src/js/pad.js b/addons/pad/static/src/js/pad.js index d6f2c1de26b..acc91f2273e 100644 --- a/addons/pad/static/src/js/pad.js +++ b/addons/pad/static/src/js/pad.js @@ -1,8 +1,5 @@ openerp.pad = function(instance) { -var QWeb = instance.web.qweb; -QWeb.add_template('/pad/static/src/xml/pad.xml'); - instance.web.form.SidebarAttachments = instance.web.form.SidebarAttachments.extend({ on_attachments_loaded: function(attachments) { this._super(attachments); diff --git a/addons/share/__openerp__.py b/addons/share/__openerp__.py index 954f915c885..b9077109c3c 100644 --- a/addons/share/__openerp__.py +++ b/addons/share/__openerp__.py @@ -56,6 +56,9 @@ synchronization with other companies, etc. 'certificate' : '001301246528927038493', 'js': ['static/src/js/share.js'], 'css': ['static/src/css/share.css'], + 'qweb' : [ + "static/src/xml/*.xml", + ], 'images': ['images/share_wizard.jpeg','images/sharing_wizard_step1.jpeg', 'images/sharing_wizard_step2.jpeg'], } diff --git a/addons/share/static/src/js/share.js b/addons/share/static/src/js/share.js index 6d02a39cf1f..b2abc1832a4 100644 --- a/addons/share/static/src/js/share.js +++ b/addons/share/static/src/js/share.js @@ -1,7 +1,5 @@ openerp.share = function(instance) { -var QWeb = instance.web.qweb; -QWeb.add_template('/share/static/src/xml/share.xml'); function launch_wizard(self, view) { var action = view.widget_parent.action; @@ -30,10 +28,9 @@ function if_has_share(yes, no) { if (!_has_share) { _has_share = $.Deferred(function() { var self = this; - var session = instance.webclient.session; - session.on_session_invalid.add_last(function() { _has_share = null; }); - var func = new instance.web.Model(session, "share.wizard").get_func("has_share"); - func(session.uid).pipe(function(res) { + instance.connection.on_session_invalid.add_last(function() { _has_share = null; }); + var func = new instance.web.Model(null, "share.wizard").get_func("has_share"); + func(instance.connection.uid).pipe(function(res) { if(res) { self.resolve(); } else { diff --git a/addons/web_livechat/__openerp__.py b/addons/web_livechat/__openerp__.py index 0731b003dbc..750c4ca7ec5 100644 --- a/addons/web_livechat/__openerp__.py +++ b/addons/web_livechat/__openerp__.py @@ -39,6 +39,9 @@ Add "Support" button in header from where you can access OpenERP Support. 'css' : [ 'static/src/css/lc.css', ], + 'qweb' : [ + "static/src/xml/*.xml", + ], 'installable': True, 'active': False, 'certificate': '0013762192410413', diff --git a/addons/web_livechat/static/src/js/web_livechat.js b/addons/web_livechat/static/src/js/web_livechat.js index 6fed859449c..13c4bbe28d4 100644 --- a/addons/web_livechat/static/src/js/web_livechat.js +++ b/addons/web_livechat/static/src/js/web_livechat.js @@ -22,29 +22,6 @@ var __lc_buttons = []; openerp.web_livechat = function (openerp) { -var QWeb = openerp.web.qweb; -QWeb.add_template('/web_livechat/static/src/xml/web_livechat.xml'); - - -// tracking code from LiveChat -var license = '1035052', - params = '', - lang = 'en', - skill = '0'; -__lc_load = function (p) { if (typeof __lc_loaded != 'function') - if (p) { var d = document, l = d.createElement('script'), s = - d.getElementsByTagName('script')[0], a = unescape('%26'), - h = ('https:' == d.location.protocol ? 'https://' : 'http://'); l.type = 'text/javascript'; l.async = true; - l.src = h + 'gis' + p +'.livechatinc.com/gis.cgi?serverType=control'+a+'licenseID='+license+a+'jsonp=__lc_load'; - if (!(typeof p['server'] !== 'string' || typeof __lc_serv === 'string')) { - l.src = h + (__lc_serv = p['server']) + '/licence/'+license+'/script.cgi?lang='+lang+a+'groups='+skill; - l.src += (params == '') ? '' : a+'params='+encodeURIComponent(encodeURIComponent(params)); s.parentNode.insertBefore(l, s); - } else setTimeout(__lc_load, 1000); if(typeof __lc_serv != 'string'){ s.parentNode.insertBefore(l, s);} - } else __lc_load(Math.ceil(Math.random()*5)); } -__lc_load(); - - - openerp.web_livechat.Livechat = openerp.web.Widget.extend({ template: 'Header-LiveChat', @@ -94,7 +71,27 @@ openerp.web_livechat.Livechat = openerp.web.Widget.extend({ } }); -openerp.webclient.livechat = new openerp.web_livechat.Livechat(openerp.webclient); -openerp.webclient.livechat.prependTo('div.header_corner'); +if (openerp.webclient) { + // tracking code from LiveChat + var license = '1035052', + params = '', + lang = 'en', + skill = '0'; + __lc_load = function (p) { if (typeof __lc_loaded != 'function') + if (p) { var d = document, l = d.createElement('script'), s = + d.getElementsByTagName('script')[0], a = unescape('%26'), + h = ('https:' == d.location.protocol ? 'https://' : 'http://'); l.type = 'text/javascript'; l.async = true; + l.src = h + 'gis' + p +'.livechatinc.com/gis.cgi?serverType=control'+a+'licenseID='+license+a+'jsonp=__lc_load'; + if (!(typeof p['server'] !== 'string' || typeof __lc_serv === 'string')) { + l.src = h + (__lc_serv = p['server']) + '/licence/'+license+'/script.cgi?lang='+lang+a+'groups='+skill; + l.src += (params == '') ? '' : a+'params='+encodeURIComponent(encodeURIComponent(params)); s.parentNode.insertBefore(l, s); + } else setTimeout(__lc_load, 1000); if(typeof __lc_serv != 'string'){ s.parentNode.insertBefore(l, s);} + } else __lc_load(Math.ceil(Math.random()*5)); } + __lc_load(); + + // and add widget to webclient + openerp.webclient.livechat = new openerp.web_livechat.Livechat(openerp.webclient); + openerp.webclient.livechat.prependTo('div.header_corner'); +} }; diff --git a/addons/web_uservoice/__openerp__.py b/addons/web_uservoice/__openerp__.py index 65f953ed3d1..64b443be3e2 100644 --- a/addons/web_uservoice/__openerp__.py +++ b/addons/web_uservoice/__openerp__.py @@ -39,5 +39,8 @@ Invite OpenERP user feedback, powered by uservoice. 'js': ['static/src/js/web_uservoice.js'], 'css': ['static/src/css/uservoice.css'], + 'qweb' : [ + "static/src/xml/*.xml", + ], 'images': ['static/src/img/submit_an_idea.jpeg', 'static/src/img/web_uservoice_feedback.jpeg'], } diff --git a/addons/web_uservoice/static/src/js/web_uservoice.js b/addons/web_uservoice/static/src/js/web_uservoice.js index a574652686f..4110f149300 100644 --- a/addons/web_uservoice/static/src/js/web_uservoice.js +++ b/addons/web_uservoice/static/src/js/web_uservoice.js @@ -1,15 +1,6 @@ openerp.web_uservoice = function(instance) { -var QWeb = instance.web.qweb; -QWeb.add_template('/web_uservoice/static/src/xml/web_uservoice.xml'); - -$(function() { - var src = ("https:" == document.location.protocol ? "https://" : "http://") + "cdn.uservoice.com/javascripts/widgets/tab.js"; - $.getScript(src); -}); - - instance.web_uservoice.UserVoice = instance.web.Widget.extend({ template: 'Header-UserVoice', default_forum: '77459', @@ -73,8 +64,15 @@ instance.web_uservoice.UserVoice = instance.web.Widget.extend({ }); -instance.webclient.uservoice = new instance.web_uservoice.UserVoice(instance.webclient); -instance.webclient.uservoice.prependTo('div.header_corner'); +if (instance.webclient) { + $(function() { + var src = ("https:" == document.location.protocol ? "https://" : "http://") + "cdn.uservoice.com/javascripts/widgets/tab.js"; + $.getScript(src); + }); + + instance.webclient.uservoice = new instance.web_uservoice.UserVoice(instance.webclient); + instance.webclient.uservoice.prependTo('div.header_corner'); +} };