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;
|
return record;
|
||||||
};
|
};
|
||||||
array.add = function(record, position) {
|
array.add = function(record, position, changed) {
|
||||||
if ((position === undefined) || (position == -1)) {
|
if ((position === undefined) || (position == -1)) {
|
||||||
position = this.length;
|
position = this.length;
|
||||||
}
|
}
|
||||||
|
if (changed === undefined) {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
if (record.group != this) {
|
if (record.group != this) {
|
||||||
record.group = this;
|
record.group = this;
|
||||||
}
|
}
|
||||||
|
@ -189,17 +192,19 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
record._changed.id = true;
|
record._changed.id = true;
|
||||||
this.changed();
|
if (changed) {
|
||||||
// Set parent field to trigger on_change
|
this.changed();
|
||||||
if (this.parent && this.model.fields[this.parent_name]) {
|
// Set parent field to trigger on_change
|
||||||
var field = this.model.fields[this.parent_name];
|
if (this.parent && this.model.fields[this.parent_name]) {
|
||||||
if ((field instanceof Sao.field.Many2One) ||
|
var field = this.model.fields[this.parent_name];
|
||||||
field instanceof Sao.field.Reference) {
|
if ((field instanceof Sao.field.Many2One) ||
|
||||||
var value = [this.parent.id, ''];
|
field instanceof Sao.field.Reference) {
|
||||||
if (field instanceof Sao.field.Reference) {
|
var value = [this.parent.id, ''];
|
||||||
value = [this.parent.model.name, value];
|
if (field instanceof Sao.field.Reference) {
|
||||||
|
value = [this.parent.model.name, value];
|
||||||
|
}
|
||||||
|
field.set_client(record, value);
|
||||||
}
|
}
|
||||||
field.set_client(record, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return record;
|
return record;
|
||||||
|
@ -1974,7 +1979,7 @@
|
||||||
var index = vals[0];
|
var index = vals[0];
|
||||||
var data = vals[1];
|
var data = vals[1];
|
||||||
var new_record = group.new_(false);
|
var new_record = group.new_(false);
|
||||||
group.add(new_record, index);
|
group.add(new_record, index, false);
|
||||||
new_record.set_on_change(data);
|
new_record.set_on_change(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue