From 7925804e3975a7b95e2cfbc73b44562a88cefa5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Fri, 3 Dec 2021 18:09:34 +0000 Subject: [PATCH] [FIX] mail: ensure unlink-all properly does its job for x2many MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, unlink-all would sometimes fail to unlink more than one record. This seems to be the case in particular for x2many relations with isCausal true. Indeed, the delete from isCausal is itself calling unlink-all on the inverse relation (the same record that was being unlinked-all in the first place) which would pre-emptively remove it from the same Set that was used during the initial iteration. The solution is to make a copy of the Set before iterating it to ensure all records that were planned to be removed are actually removed. Candidate fix for task-2410314 and definitely necessary for data integrity in general. closes odoo/odoo#80913 X-original-commit: 0077b93fea6f8c39ee535f19426c3f95a0e97e9f Signed-off-by: Alexandre Kühn (aku) Signed-off-by: Sébastien Theys (seb) --- addons/mail/static/src/model/model_field.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/static/src/model/model_field.js b/addons/mail/static/src/model/model_field.js index 4e4572d824e..6fe7514166b 100644 --- a/addons/mail/static/src/model/model_field.js +++ b/addons/mail/static/src/model/model_field.js @@ -372,7 +372,7 @@ export class ModelField { } break; case 'unlink-all': - if (this._setRelationUnlink(record, this.read(record), options)) { + if (this._setRelationUnlink(record, this.get(record), options)) { hasChanged = true; } break;