[IMP] Improve M2OButton.

bzr revid: vta@openerp.com-20121203151525-j464860k1ueqztp6
This commit is contained in:
vta vta@openerp.com 2012-12-03 16:15:25 +01:00
parent 6c00237919
commit 44f27eca8e
5 changed files with 12 additions and 14 deletions

View File

@ -481,7 +481,7 @@
box-shadow: none;
}
.openerp .oe_button.oe_link img {
display: none;
display: inline-block;
}
.openerp .oe_button.oe_link span {
border: none;

View File

@ -435,7 +435,7 @@ $sheet-padding: 16px
.oe_button.oe_link
@include reset()
img
display: none
display: inline-block
span
@include reset()
color: $link-color

View File

@ -3244,17 +3244,10 @@ instance.web.form.Many2OneButton = instance.web.form.AbstractField.extend({
if (this.$button) {
this.$button.remove();
}
var options = {};
try {
options = py.eval(this.node.attrs.options);
} catch (e) {}
if (options.label) {
this.string = this.get('value') ? _t(options.label.edit) : _t(options.label.create);
} else {
this.string = '';
}
this.string = '';
this.node.attrs.icon = this.get('value') ? '/web/static/src/img/icons/gtk-yes.png' : '/web/static/src/img/icons/gtk-no.png';
this.$button = $(QWeb.render('WidgetButton', {'widget': this}));
this.$button.addClass('oe_link').css({'padding':'4px'});
this.$el.append(this.$button);
this.$button.on('click', self.on_click);
},

View File

@ -2223,7 +2223,12 @@ instance.web.list.Handle = instance.web.list.Column.extend({
instance.web.list.Many2OneButton = instance.web.list.Column.extend({
_format: function (row_data, options) {
this.has_value = !!row_data[this.id].value;
return QWeb.render('Many2OneButton.cell', {'widget': this});
this.icon = this.has_value ? 'gtk-yes' : 'gtk-no';
this.string = this.has_value ? _t('View') : _t('Create');
return QWeb.render('Many2OneButton.cell', {
'widget': this,
'prefix': instance.session.prefix,
});
},
});
instance.web.list.Many2Many = instance.web.list.Column.extend({

View File

@ -760,7 +760,7 @@
t-att-title="widget.string" t-att-disabled="disabled || undefined"
t-att-class="disabled ? 'oe_list_button_disabled' : undefined"
><img t-attf-src="#{prefix}/web/static/src/img/icons/#{widget.icon}.png"
t-att-alt="widget.string" /></button>
t-att-alt="widget.string"/></button>
<t t-extend="ListView.row">
<!-- adds back padding to row being rendered after edition, if necessary
(if not deletable add back padding), otherwise the row being added is
@ -1088,7 +1088,7 @@
</span>
</t>
<t t-name="Many2OneButton.cell"
><img t-attf-src="#{_s}/web/static/src/img/icons/gtk-#{widget.has_value ? 'yes' : 'no'}.png" width="16" height="16"/>
><img t-attf-src="#{prefix}/web/static/src/img/icons/#{widget.icon}.png" t-att-alt="widget.string" width="16" height="16"/>
</t>
<t t-name="FieldMany2ManyTags">
<div class="oe_form_field oe_tags" t-att-style="widget.node.attrs.style">