diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index e47a716b2bc..48e188930a0 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -28,6 +28,7 @@ except ImportError: xlwt = None import openerp +import openerp.modules.registry from openerp.tools.translate import _ from .. import http @@ -169,7 +170,6 @@ def module_installed_bypass_session(dbname): loadable = openerpweb.addons_manifest.keys() modules = {} try: - import openerp.modules.registry registry = openerp.modules.registry.RegistryManager.get(dbname) with registry.cursor() as cr: m = registry.get('ir.module.module') @@ -1201,9 +1201,10 @@ class Binary(openerpweb.Controller): except: pass return req.make_response(image_data, headers) - def placeholder(self, req): + + def placeholder(self, req, image='placeholder.png'): addons_path = openerpweb.addons_manifest['web']['addons_path'] - return open(os.path.join(addons_path, 'web', 'static', 'src', 'img', 'placeholder.png'), 'rb').read() + return open(os.path.join(addons_path, 'web', 'static', 'src', 'img', image), 'rb').read() @openerpweb.httprequest def saveas(self, req, model, field, id=None, filename_field=None, **kw): @@ -1311,6 +1312,33 @@ class Binary(openerpweb.Controller): args = {'error':e.faultCode } return out % (simplejson.dumps(callback), simplejson.dumps(args)) + @openerpweb.httprequest + def company_logo(self, req, dbname=None): + # TODO add etag, refactor to use /image code for etag + uid = None + if req.session._db: + dbname = req.session._db + uid = req.session._uid + elif dbname is None: + dbname = db_monodb(req) + + if uid is None: + uid = openerp.SUPERUSER_ID + + if not dbname: + image_data = self.placeholder(req, 'logo.png') + else: + registry = openerp.modules.registry.RegistryManager.get(dbname) + with registry.cursor() as cr: + user = registry.get('res.users').browse(cr, uid, uid) + image_data = user.company_id.logo_web.decode('base64') + + headers = [ + ('Content-Type', 'image/png'), + ('Content-Length', len(image_data)), + ] + return req.make_response(image_data, headers) + class Action(openerpweb.Controller): _cp_path = "/web/action" diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 77ab4239a0d..9d0221e7082 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1152,12 +1152,8 @@ width: 220px; display: block; text-align: center; - height: 70px; - line-height: 70px; } .openerp a.oe_logo img { - height: 40px; - width: 157px; margin: 14px 0; border: 0; } diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 1e0d45407e7..5ad6da28bda 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -943,11 +943,7 @@ $sheet-padding: 16px width: 220px display: block text-align: center - height: 70px - line-height: 70px img - height: 40px - width: 157px margin: 14px 0 border: 0 .oe_footer diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index fbe7fbde795..17116f18d3f 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1175,6 +1175,7 @@ instance.web.WebClient = instance.web.Client.extend({ show_application: function() { var self = this; self.toggle_bars(true); + self.update_logo(); self.menu = new instance.web.Menu(self); self.menu.replace(this.$el.find('.oe_menu_placeholder')); self.menu.on('menu_click', this, this.on_menu_action); @@ -1186,6 +1187,10 @@ instance.web.WebClient = instance.web.Client.extend({ self.set_title(); self.check_timezone(); }, + update_logo: function() { + var img = this.session.url('/web/binary/company_logo'); + this.$el.find('.oe_logo img').attr('src', '').attr('src', img); + }, check_timezone: function() { var self = this; return new instance.web.Model('res.users').call('read', [[this.session.uid], ['tz_offset']]).then(function(result) { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 0cd9e48b885..dc31a24dc31 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -439,7 +439,7 @@