mirror of
https://github.com/NaN-tic/sao-base.git
synced 2023-12-14 03:13:01 +01:00
Set parent field only if changed is requested
When set_on_change adds a record, we don't need to trigger the parent on_change, otherwise it can lead to an infinite loop. issue5278 review17781002
This commit is contained in:
parent
1bfe803fe7
commit
61c52e1523
29
src/model.js
29
src/model.js
|
@ -168,10 +168,13 @@
|
|||
}
|
||||
return record;
|
||||
};
|
||||
array.add = function(record, position) {
|
||||
array.add = function(record, position, changed) {
|
||||
if ((position === undefined) || (position == -1)) {
|
||||
position = this.length;
|
||||
}
|
||||
if (changed === undefined) {
|
||||
changed = true;
|
||||
}
|
||||
if (record.group != this) {
|
||||
record.group = this;
|
||||
}
|
||||
|
@ -189,17 +192,19 @@
|
|||
}
|
||||
}
|
||||
record._changed.id = true;
|
||||
this.changed();
|
||||
// Set parent field to trigger on_change
|
||||
if (this.parent && this.model.fields[this.parent_name]) {
|
||||
var field = this.model.fields[this.parent_name];
|
||||
if ((field instanceof Sao.field.Many2One) ||
|
||||
field instanceof Sao.field.Reference) {
|
||||
var value = [this.parent.id, ''];
|
||||
if (field instanceof Sao.field.Reference) {
|
||||
value = [this.parent.model.name, value];
|
||||
if (changed) {
|
||||
this.changed();
|
||||
// Set parent field to trigger on_change
|
||||
if (this.parent && this.model.fields[this.parent_name]) {
|
||||
var field = this.model.fields[this.parent_name];
|
||||
if ((field instanceof Sao.field.Many2One) ||
|
||||
field instanceof Sao.field.Reference) {
|
||||
var value = [this.parent.id, ''];
|
||||
if (field instanceof Sao.field.Reference) {
|
||||
value = [this.parent.model.name, value];
|
||||
}
|
||||
field.set_client(record, value);
|
||||
}
|
||||
field.set_client(record, value);
|
||||
}
|
||||
}
|
||||
return record;
|
||||
|
@ -1974,7 +1979,7 @@
|
|||
var index = vals[0];
|
||||
var data = vals[1];
|
||||
var new_record = group.new_(false);
|
||||
group.add(new_record, index);
|
||||
group.add(new_record, index, false);
|
||||
new_record.set_on_change(data);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue