[MERGE] customizable web logo by chs

bzr revid: al@openerp.com-20121215192659-g5psibisxvyl8adw
This commit is contained in:
Antony Lesuisse
2012-12-15 20:26:59 +01:00
5 changed files with 37 additions and 12 deletions
+31 -3
View File
@@ -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"
-4
View File
@@ -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;
}
-4
View File
@@ -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
+5
View File
@@ -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) {
+1 -1
View File
@@ -439,7 +439,7 @@
<tr>
<td class="oe_leftbar" valign="top">
<t t-set="debug" t-value="__debug__ ? '&amp;debug' : ''"/>
<a class="oe_logo" t-attf-href="/?ts=#{Date.now()}#{debug}"><img t-att-src='_s + "/web/static/src/img/logo.png"'/></a>
<a class="oe_logo" t-attf-href="/?ts=#{Date.now()}#{debug}"><img t-att-src='widget.session.url("/web/binary/company_logo")'/></a>
<div class="oe_secondary_menus_container"/>
<div class="oe_footer">
Powered by <a href="http://www.openerp.com" target="_blank"><span>OpenERP</span></a>