[imp] modified m2o to use the mixin

bzr revid: nicolas.vanhoren@openerp.com-20120320102650-virv6zsj0gf0rjpw
This commit is contained in:
niv-openerp 2012-03-20 11:26:50 +01:00
parent 386d00f00f
commit cf4159c7f8
2 changed files with 27 additions and 37 deletions

View File

@ -1977,8 +1977,8 @@ openerp.web.form.dialog = function(content, options) {
return dialog.$element;
};
openerp.web.form.FieldMany2One = openerp.web.form.AbstractField.extend({
template: 'EmptyComponent',
openerp.web.form.FieldMany2One = openerp.web.form.AbstractField.extend(_.extend({}, openerp.web.form.ReinitializeFieldMixin, {
template: "FieldMany2One",
init: function(view, node) {
this._super(view, node);
this.limit = 7;
@ -1987,23 +1987,12 @@ openerp.web.form.FieldMany2One = openerp.web.form.AbstractField.extend({
this.last_search = [];
this.tmp_value = undefined;
},
start: function() {
this._super();
this.render_content();
this.on("change:effective_readonly", this, function() {
this.render_content();
});
},
render_content: function() {
this.$element.html("");
initialize_content: function() {
if (!this.get("effective_readonly"))
this.render_editable();
else
this.render_readonly();
this.render_value();
},
render_editable: function() {
this.$element.html(QWeb.render("FieldMany2One", {widget: this}));
var self = this;
this.$input = this.$element.find("input");
this.$drop_down = this.$element.find(".oe-m2o-drop-down-button");
@ -2142,9 +2131,6 @@ openerp.web.form.FieldMany2One = openerp.web.form.AbstractField.extend({
isSelecting = false;
});
},
render_readonly: function() {
this.$element.html(QWeb.render("FieldMany2One_readonly"));
},
// autocomplete component content handling
get_search_result: function(request, response) {
var search_val = request.term;
@ -2339,7 +2325,7 @@ openerp.web.form.FieldMany2One = openerp.web.form.AbstractField.extend({
focus: function ($element) {
this._super($element || this.$input);
}
});
}));
/*
# Values: (0, 0, { fields }) create

View File

@ -1037,25 +1037,29 @@
</t>
</t>
<t t-name="FieldMany2One">
<table t-attf-class="oe_form_field_#{widget.type}" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top">
<t t-call="FieldChar"/>
<span class="oe-m2o-drop-down-button">
<img t-att-src='_s + "/web/static/src/img/down-arrow.png"' /></span>
</td>
<td>
<button class="oe_button oe_field_button oe-m2o-cm-button" t-att-id="widget.name + '_open'">
<img t-att-src='_s + "/web/static/src/img/icons/STOCK_DIRECTORY_MENU.png"'/>
</button>
<div t-att-id="widget.cm_id" class="contextMenu" style="display:none">
</div>
</td>
</tr>
</table>
</t>
<t t-name="FieldMany2One_readonly">
<a href="#" class="oe_form_uri"/>
<t t-if="!widget.get('effective_readonly')">
<table t-attf-class="oe_form_field_#{widget.type}" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top">
<t t-call="FieldChar"/>
<span class="oe-m2o-drop-down-button">
<img t-att-src='_s + "/web/static/src/img/down-arrow.png"' /></span>
</td>
<td>
<button class="oe_button oe_field_button oe-m2o-cm-button" t-att-id="widget.name + '_open'">
<img t-att-src='_s + "/web/static/src/img/icons/STOCK_DIRECTORY_MENU.png"'/>
</button>
<div t-att-id="widget.cm_id" class="contextMenu" style="display:none">
</div>
</td>
</tr>
</table>
</t>
<t t-if="widget.get('effective_readonly')">
<div>
<a href="#" class="oe_form_uri"/>
</div>
</t>
</t>
<t t-name="FieldMany2One.context_menu">
<ul>