[FIX] web: prevent crash in rare case with status field

Current behavior before PR: if you create a new record within a one2many
field and the model's form has a clickable status bar defined, clicking
this status bar will raise an exception because the virtual id
(one2many_v_XXXX) will be passed to the model's write method

Desired behavior after PR is merged: clicking just changes the cached
value
This commit is contained in:
Holger Brunn 2016-03-23 14:50:46 +01:00 committed by Géry Debongnie
parent bf163700e4
commit b25c054c93
1 changed files with 13 additions and 6 deletions

View File

@ -6145,13 +6145,20 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
val = $li.data("id");
}
if (val != self.get('value')) {
this.view.recursive_save().done(function() {
var change = {};
change[self.name] = val;
self.view.dataset.write(self.view.datarecord.id, change).done(function() {
self.view.reload();
if(!this.view.datarecord.id ||
this.view.datarecord.id.toString().match(instance.web.BufferedDataSet.virtual_id_regex)) {
// don't save, only set value for not-yet-saved many2ones
self.set_value(val);
}
else {
this.view.recursive_save().done(function() {
var change = {};
change[self.name] = val;
self.view.dataset.write(self.view.datarecord.id, change).done(function() {
self.view.reload();
});
});
});
}
}
},
});