Modified fields up to m2o
bzr revid: nicolas.vanhoren@openerp.com-20121011152140-c4edgpmamqgiwx9s
This commit is contained in:
parent
3da22818fa
commit
4757e5287e
|
@ -159,7 +159,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
this.rendering_engine.set_fields_view(data);
|
this.rendering_engine.set_fields_view(data);
|
||||||
var $dest = this.$el.hasClass("oe_form_container") ? this.$el : this.$el.find('.oe_form_container');
|
var $dest = this.$el.hasClass("oe_form_container") ? this.$el : this.$el.find('.oe_form_container');
|
||||||
this.rendering_engine.render_to($dest);
|
this.rendering_engine.render_to($dest);
|
||||||
this.rendering_engine.init_fields();
|
|
||||||
|
|
||||||
this.$el.on('mousedown.formBlur', function () {
|
this.$el.on('mousedown.formBlur', function () {
|
||||||
self.__clicked_inside = true;
|
self.__clicked_inside = true;
|
||||||
|
@ -335,6 +334,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
self.on_form_changed();
|
self.on_form_changed();
|
||||||
|
this.rendering_engine.init_fields();
|
||||||
self.is_initialized.resolve();
|
self.is_initialized.resolve();
|
||||||
self.do_update_pager(record.id == null);
|
self.do_update_pager(record.id == null);
|
||||||
if (self.sidebar) {
|
if (self.sidebar) {
|
||||||
|
@ -1204,6 +1204,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt
|
||||||
_.each(this.to_replace, function(el) {
|
_.each(this.to_replace, function(el) {
|
||||||
defs.push(el[0].replace(el[1]));
|
defs.push(el[0].replace(el[1]));
|
||||||
});
|
});
|
||||||
|
this.to_replace = [];
|
||||||
return $.when.apply($, defs);
|
return $.when.apply($, defs);
|
||||||
},
|
},
|
||||||
render_element: function(template /* dictionaries */) {
|
render_element: function(template /* dictionaries */) {
|
||||||
|
@ -2066,6 +2067,14 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w
|
||||||
this.field_manager.on("change:display_invalid_fields", this, this._check_css_flags);
|
this.field_manager.on("change:display_invalid_fields", this, this._check_css_flags);
|
||||||
this._check_css_flags();
|
this._check_css_flags();
|
||||||
},
|
},
|
||||||
|
start: function() {
|
||||||
|
var tmp = this._super();
|
||||||
|
this.on("change:value", this, function() {
|
||||||
|
if (! this.no_rerender)
|
||||||
|
this.render();
|
||||||
|
});
|
||||||
|
this.render();
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Private. Do not use.
|
* Private. Do not use.
|
||||||
*/
|
*/
|
||||||
|
@ -2078,6 +2087,20 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w
|
||||||
get_value: function() {
|
get_value: function() {
|
||||||
return this.get('value');
|
return this.get('value');
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
Utility method that all implementations should use to change the
|
||||||
|
value without triggering a re-rendering.
|
||||||
|
*/
|
||||||
|
internal_set_value: function(value_) {
|
||||||
|
var tmp = this.no_render;
|
||||||
|
this.no_rerender = true;
|
||||||
|
this.set({'value': value_});
|
||||||
|
this.no_rerender = tmp;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
This method is called each time the value is modified.
|
||||||
|
*/
|
||||||
|
render_value: function() {},
|
||||||
is_valid: function() {
|
is_valid: function() {
|
||||||
return this.is_syntax_valid() && !(this.get('required') && this.is_false());
|
return this.is_syntax_valid() && !(this.get('required') && this.is_false());
|
||||||
},
|
},
|
||||||
|
@ -2161,10 +2184,6 @@ instance.web.form.ReinitializeFieldMixin = _.extend({}, instance.web.form.Reini
|
||||||
instance.web.form.ReinitializeWidgetMixin.reinitialize.call(this);
|
instance.web.form.ReinitializeWidgetMixin.reinitialize.call(this);
|
||||||
this.render_value();
|
this.render_value();
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Called to render the value. Should also be explicitly called at the end of a set_value().
|
|
||||||
*/
|
|
||||||
render_value: function() {},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
|
instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
|
||||||
|
@ -2178,14 +2197,10 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we
|
||||||
var self = this;
|
var self = this;
|
||||||
var $input = this.$el.find('input');
|
var $input = this.$el.find('input');
|
||||||
$input.change(function() {
|
$input.change(function() {
|
||||||
self.set({'value': self.parse_value($input.val())});
|
self.internal_set_value(self.parse_value($input.val()));
|
||||||
});
|
});
|
||||||
this.setupFocus($input);
|
this.setupFocus($input);
|
||||||
},
|
},
|
||||||
set_value: function(value_) {
|
|
||||||
this._super(value_);
|
|
||||||
this.render_value();
|
|
||||||
},
|
|
||||||
render_value: function() {
|
render_value: function() {
|
||||||
var show_value = this.format_value(this.get('value'), '');
|
var show_value = this.format_value(this.get('value'), '');
|
||||||
if (!this.get("effective_readonly")) {
|
if (!this.get("effective_readonly")) {
|
||||||
|
@ -2289,7 +2304,7 @@ instance.web.form.FieldFloat = instance.web.form.FieldChar.extend({
|
||||||
widget_class: 'oe_form_field_float',
|
widget_class: 'oe_form_field_float',
|
||||||
init: function (field_manager, node) {
|
init: function (field_manager, node) {
|
||||||
this._super(field_manager, node);
|
this._super(field_manager, node);
|
||||||
this.set({'value': 0});
|
this.internal_set_value(0);
|
||||||
if (this.node.attrs.digits) {
|
if (this.node.attrs.digits) {
|
||||||
this.digits = this.node.attrs.digits;
|
this.digits = this.node.attrs.digits;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2415,16 +2430,12 @@ instance.web.form.FieldDatetime = instance.web.form.AbstractField.extend(instanc
|
||||||
if (!this.get("effective_readonly")) {
|
if (!this.get("effective_readonly")) {
|
||||||
this.datewidget = this.build_widget();
|
this.datewidget = this.build_widget();
|
||||||
this.datewidget.on_change.add_last(_.bind(function() {
|
this.datewidget.on_change.add_last(_.bind(function() {
|
||||||
this.set({'value': this.datewidget.get_value()});
|
this.internal_set_value(this.datewidget.get_value());
|
||||||
}, this));
|
}, this));
|
||||||
this.datewidget.appendTo(this.$el);
|
this.datewidget.appendTo(this.$el);
|
||||||
this.setupFocus(this.datewidget.$input);
|
this.setupFocus(this.datewidget.$input);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
set_value: function(value_) {
|
|
||||||
this._super(value_);
|
|
||||||
this.render_value();
|
|
||||||
},
|
|
||||||
render_value: function() {
|
render_value: function() {
|
||||||
if (!this.get("effective_readonly")) {
|
if (!this.get("effective_readonly")) {
|
||||||
this.datewidget.set_value(this.get('value'));
|
this.datewidget.set_value(this.get('value'));
|
||||||
|
@ -2466,7 +2477,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
|
||||||
this.default_height = this.$textarea.css('height');
|
this.default_height = this.$textarea.css('height');
|
||||||
if (!this.get("effective_readonly")) {
|
if (!this.get("effective_readonly")) {
|
||||||
this.$textarea.change(_.bind(function() {
|
this.$textarea.change(_.bind(function() {
|
||||||
self.set({'value': instance.web.parse_value(self.$textarea.val(), self)});
|
self.internal_set_value(instance.web.parse_value(self.$textarea.val(), self));
|
||||||
}, this));
|
}, this));
|
||||||
} else {
|
} else {
|
||||||
this.$textarea.attr('disabled', 'disabled');
|
this.$textarea.attr('disabled', 'disabled');
|
||||||
|
@ -2478,12 +2489,8 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
|
||||||
});
|
});
|
||||||
this.setupFocus(this.$textarea);
|
this.setupFocus(this.$textarea);
|
||||||
},
|
},
|
||||||
set_value: function(value_) {
|
|
||||||
this._super(value_);
|
|
||||||
this.render_value();
|
|
||||||
$(window).resize();
|
|
||||||
},
|
|
||||||
render_value: function() {
|
render_value: function() {
|
||||||
|
$(window).resize();
|
||||||
var show_value = instance.web.format_value(this.get('value'), this, '');
|
var show_value = instance.web.format_value(this.get('value'), this, '');
|
||||||
if (show_value === '') {
|
if (show_value === '') {
|
||||||
this.$textarea.css('height', parseInt(this.default_height)+"px");
|
this.$textarea.css('height', parseInt(this.default_height)+"px");
|
||||||
|
@ -2543,15 +2550,11 @@ instance.web.form.FieldTextHtml = instance.web.form.AbstractField.extend(instanc
|
||||||
this.$cleditor.change(function() {
|
this.$cleditor.change(function() {
|
||||||
if (! self._updating_editor) {
|
if (! self._updating_editor) {
|
||||||
self.$cleditor.updateTextArea();
|
self.$cleditor.updateTextArea();
|
||||||
self.set({'value': self.$textarea.val()});
|
self.internal_set_value(self.$textarea.val());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
set_value: function(value_) {
|
|
||||||
this._super.apply(this, arguments);
|
|
||||||
this.render_value();
|
|
||||||
},
|
|
||||||
render_value: function() {
|
render_value: function() {
|
||||||
if (! this.get("effective_readonly")) {
|
if (! this.get("effective_readonly")) {
|
||||||
this.$textarea.val(this.get('value') || '');
|
this.$textarea.val(this.get('value') || '');
|
||||||
|
@ -2572,7 +2575,7 @@ instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({
|
||||||
this.$checkbox = $("input", this.$el);
|
this.$checkbox = $("input", this.$el);
|
||||||
this.setupFocus(this.$checkbox);
|
this.setupFocus(this.$checkbox);
|
||||||
this.$el.click(_.bind(function() {
|
this.$el.click(_.bind(function() {
|
||||||
this.set({'value': this.$checkbox.is(':checked')});
|
this.internal_set_value(this.$checkbox.is(':checked'));
|
||||||
}, this));
|
}, this));
|
||||||
var check_readonly = function() {
|
var check_readonly = function() {
|
||||||
self.$checkbox.prop('disabled', self.get("effective_readonly"));
|
self.$checkbox.prop('disabled', self.get("effective_readonly"));
|
||||||
|
@ -2580,10 +2583,9 @@ instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({
|
||||||
this.on("change:effective_readonly", this, check_readonly);
|
this.on("change:effective_readonly", this, check_readonly);
|
||||||
check_readonly.call(this);
|
check_readonly.call(this);
|
||||||
},
|
},
|
||||||
set_value: function(value_) {
|
render_value: function() {
|
||||||
this._super.apply(this, arguments);
|
this.$checkbox[0].checked = this.get('value');
|
||||||
this.$checkbox[0].checked = value_;
|
}
|
||||||
},
|
|
||||||
focus: function() {
|
focus: function() {
|
||||||
this.$checkbox.focus();
|
this.$checkbox.focus();
|
||||||
}
|
}
|
||||||
|
@ -2598,9 +2600,8 @@ instance.web.form.FieldProgressBar = instance.web.form.AbstractField.extend({
|
||||||
disabled: this.get("effective_readonly")
|
disabled: this.get("effective_readonly")
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
set_value: function(value_) {
|
render_value: function() {
|
||||||
this._super.apply(this, arguments);
|
var show_value = Number(this.get('value'));
|
||||||
var show_value = Number(value_);
|
|
||||||
if (isNaN(show_value)) {
|
if (isNaN(show_value)) {
|
||||||
show_value = 0;
|
show_value = 0;
|
||||||
}
|
}
|
||||||
|
@ -2638,7 +2639,7 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan
|
||||||
var ischanging = false;
|
var ischanging = false;
|
||||||
var $select = this.$el.find('select')
|
var $select = this.$el.find('select')
|
||||||
.change(_.bind(function() {
|
.change(_.bind(function() {
|
||||||
this.set({'value': this.values[this.$el.find('select')[0].selectedIndex][0]});
|
this.internal_set_value(this.values[this.$el.find('select')[0].selectedIndex][0]);
|
||||||
}, this))
|
}, this))
|
||||||
.change(function () { ischanging = true; })
|
.change(function () { ischanging = true; })
|
||||||
.click(function () { ischanging = false; })
|
.click(function () { ischanging = false; })
|
||||||
|
@ -2653,7 +2654,6 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan
|
||||||
value_ = value_ === null ? false : value_;
|
value_ = value_ === null ? false : value_;
|
||||||
value_ = value_ instanceof Array ? value_[0] : value_;
|
value_ = value_ instanceof Array ? value_[0] : value_;
|
||||||
this._super(value_);
|
this._super(value_);
|
||||||
this.render_value();
|
|
||||||
},
|
},
|
||||||
render_value: function() {
|
render_value: function() {
|
||||||
if (!this.get("effective_readonly")) {
|
if (!this.get("effective_readonly")) {
|
||||||
|
|
Loading…
Reference in New Issue