[IMP] mail: prevent "already in update cycle" loop after crash

task-2620828

closes odoo/odoo#75661

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Sébastien Theys
2021-08-26 16:25:19 +00:00
parent f71484fdae
commit c685fc18c1
+15 -12
View File
@@ -815,21 +815,24 @@ export class ModelManager {
if (this._isInUpdateCycle) {
throw Error('Already in update cycle. You are probably trying to manually create/update/delete a record from inside a compute method, which is not supported.');
}
this._isInUpdateCycle = true;
this._notifyListenersInUpdateCycle();
// Verify the existence of value for required fields (of non-deleted records).
for (const record of this._updatedRecords) {
if (!record.exists()) {
continue;
}
for (const required of record.constructor.__requiredFieldsList) {
if (record[required.fieldName] === undefined) {
throw Error(`Field ${required.fieldName} of ${record.localId} is required.`);
try {
this._isInUpdateCycle = true;
this._notifyListenersInUpdateCycle();
// Verify the existence of value for required fields (of non-deleted records).
for (const record of this._updatedRecords) {
if (!record.exists()) {
continue;
}
for (const required of record.constructor.__requiredFieldsList) {
if (record[required.fieldName] === undefined) {
throw Error(`Field ${required.fieldName} of ${record.localId} is required.`);
}
}
}
this._updatedRecords.clear();
} finally {
this._isInUpdateCycle = false;
}
this._updatedRecords.clear();
this._isInUpdateCycle = false;
// Execution of `_created` and "on change" (after the update cycle itself).
while (this._createdRecords.size > 0) {
for (const record of this._createdRecords) {