[ADD] Allow admin to edit the company logo

bzr revid: fme@openerp.com-20121218111734-wu02xaifqyqz1g20
This commit is contained in:
Fabien Meghazi 2012-12-18 12:17:34 +01:00
parent d98b1b0ff5
commit fcf4d4040f
4 changed files with 63 additions and 2 deletions

View File

@ -1182,6 +1182,7 @@
padding-bottom: 16px;
}
.openerp a.oe_logo {
position: relative;
width: 220px;
display: block;
text-align: center;
@ -1190,6 +1191,24 @@
margin: 14px 0;
border: 0;
}
.openerp a.oe_logo .oe_logo_edit {
margin: 14px 0;
position: absolute;
top: 1px;
padding: 4px;
width: 100%;
display: none;
text-align: center;
color: #eeeeee;
background: rgba(37, 37, 37, 0.9);
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
.openerp a.oe_logo:hover .oe_logo_edit_admin {
display: block;
}
.openerp .oe_footer {
position: fixed;
bottom: 0;

View File

@ -958,12 +958,26 @@ $sheet-padding: 16px
text-shadow: 0 1px 1px white
padding-bottom: 16px
a.oe_logo
position: relative
width: 220px
display: block
text-align: center
img
margin: 14px 0
border: 0
.oe_logo_edit
margin: 14px 0
position: absolute
top: 1px
padding: 4px
width: 100%
display: none
text-align: center
color: #eee
background: rgba(37,37,37,0.9)
@include box-sizing(border)
&:hover .oe_logo_edit_admin
display: block
.oe_footer
position: fixed
bottom: 0

View File

@ -1118,6 +1118,9 @@ instance.web.Client = instance.web.Widget.extend({
instance.web.WebClient = instance.web.Client.extend({
_template: 'WebClient',
events: {
'click .oe_logo_edit_admin': 'logo_edit'
},
init: function(parent) {
this._super(parent);
this._current_state = null;
@ -1188,7 +1191,29 @@ instance.web.WebClient = instance.web.Client.extend({
},
update_logo: function() {
var img = this.session.url('/web/binary/company_logo');
this.$el.find('.oe_logo img').attr('src', '').attr('src', img);
this.$('.oe_logo img').attr('src', '').attr('src', img);
this.$('.oe_logo_edit').toggleClass('oe_logo_edit_admin', this.session.uid === 1);
},
logo_edit: function(ev) {
var self = this;
new instance.web.Model("res.users").get_func("read")(this.session.uid, ["company_id"]).then(function(res) {
self.rpc("/web/action/load", { action_id: "base.action_res_company_form" }).done(function(result) {
result.res_id = res['company_id'][0];
result.target = "new";
result.views = [[false, 'form']];
result.flags = {
action_buttons: true,
};
self.action_manager.do_action(result);
var form = self.action_manager.dialog_widget.views.form.controller;
form.on("on_button_cancel", self.action_manager.dialog, self.action_manager.dialog.close);
form.on('record_saved', self, function() {
self.action_manager.dialog.close();
self.update_logo();
});
});
});
return false;
},
check_timezone: function() {
var self = this;

View File

@ -439,7 +439,10 @@
<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='widget.session.url("/web/binary/company_logo")'/></a>
<a class="oe_logo" t-attf-href="/?ts=#{Date.now()}#{debug}">
<span class="oe_logo_edit">Edit Company data</span>
<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>