[FIX] web: on editable list save, valid all records

opw-617036:
In my current timesheet, if you add a a required field on the timesheet ids lines, and add data in the summary tab, it was possible to validate the timesheet lines while requried fields were missing.
This commit is contained in:
Denis Ledoux 2014-10-31 17:40:56 +01:00
parent 8af9fdfa06
commit df845940ed
1 changed files with 14 additions and 19 deletions

View File

@ -3881,28 +3881,23 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
this.o2m.trigger_on_change();
},
is_valid: function () {
var editor = this.editor;
var form = editor.form;
// If no edition is pending, the listview can not be invalid (?)
if (!editor.record) {
return true
}
// If the form has not been modified, the view can only be valid
// NB: is_dirty will also be set on defaults/onchanges/whatever?
// oe_form_dirty seems to only be set on actual user actions
if (!form.$el.is('.oe_form_dirty')) {
var self = this;
if (!this.editable()){
return true;
}
this.o2m._dirty_flag = true;
// Otherwise validate internal form
return _(form.fields).chain()
.invoke(function () {
this._check_css_flags();
return this.is_valid();
})
.all(_.identity)
.value();
var r;
return _.every(this.records.records, function(record){
r = record;
_.each(self.editor.form.fields, function(field){
field.set_value(r.attributes[field.name]);
});
return _.every(self.editor.form.fields, function(field){
field.process_modifiers();
field._check_css_flags();
return field.is_valid();
});
});
},
do_add_record: function () {
if (this.editable()) {