[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:
parent
bf163700e4
commit
b25c054c93
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue