diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 3cda7bf1b4c..fedc602b4b1 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -247,7 +247,7 @@ instance.web.FormView = instance.web.View.extend({ } _(this.fields).each(function (field, f) { - field.reset(); + field._dirty_flag = false; var result = field.set_value(self.datarecord[f] || false); set_values.push(result); }); @@ -258,7 +258,7 @@ instance.web.FormView = instance.web.View.extend({ _.each(self.fields_order, function(field_name) { if (record[field_name] !== undefined) { var field = self.fields[field_name]; - field.dirty = true; + field._dirty_flag = true; self.do_onchange(field); } }); @@ -469,7 +469,7 @@ instance.web.FormView = instance.web.View.extend({ var value_ = result.value[f]; if (field.get_value() != value_) { field.set_value(value_); - field.dirty = true; + field._dirty_flag = true; if (!_.contains(processed, field.name)) { this.do_onchange(field, processed); } @@ -615,7 +615,7 @@ instance.web.FormView = instance.web.View.extend({ if (!first_invalid_field) { first_invalid_field = f; } - } else if (f.name !== 'id' && !f.get("readonly") && (!self.datarecord.id || f.is_dirty())) { + } else if (f.name !== 'id' && !f.get("readonly") && (!self.datarecord.id || f._dirty_flag)) { // Special case 'id' field, do not save this field // on 'create' : save all non readonly fields // on 'edit' : save non readonly modified fields @@ -754,7 +754,7 @@ instance.web.FormView = instance.web.View.extend({ }, is_dirty: function() { return _.any(this.fields, function (value_) { - return value_.is_dirty(); + return value_._dirty_flag; }); }, is_interactible_record: function() { @@ -854,9 +854,11 @@ instance.web.FormView = instance.web.View.extend({ this.translatable_fields.push(field); } field.on('changed_value', this, function() { - this.do_onchange(field); - this.on_form_changed(true); - this.do_notify_change(); + if (field.is_syntax_valid()) { + this.do_onchange(field); + this.on_form_changed(true); + this.do_notify_change(); + } }); }, get_field: function(field_name) { @@ -1628,7 +1630,11 @@ instance.web.form.FieldInterface = { * Inform the current object of the id it should use to match a html