From 0e6f152ea4a8e897dfd490bc19ecf567a0c0a08f Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 25 Mar 2022 14:06:29 +0000 Subject: [PATCH] [REF] web: orm service: export x2many commands magic numbers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit renames the `Commands` object exported by the orm service into `x2manyCommands`, and adds the magic numbers in that object. closes odoo/odoo#87582 Related: odoo/enterprise#25750 Signed-off-by: Géry Debongnie --- addons/web/static/src/core/orm_service.js | 36 ++++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/addons/web/static/src/core/orm_service.js b/addons/web/static/src/core/orm_service.js index 8c3024c487d..efe349ad013 100644 --- a/addons/web/static/src/core/orm_service.js +++ b/addons/web/static/src/core/orm_service.js @@ -34,35 +34,43 @@ function assignOptions(kwargs, options, whileList) { * and update) either the new ``ids`` list of related records (command set), * either 0 (commands delete, unlink, link, and clear). */ -export const Commands = { +export const x2ManyCommands = { + // (0, virtualID | false, { values }) + CREATE: 0, create(virtualID, values) { delete values.id; - return [0, virtualID || false, values]; + return [x2ManyCommands.CREATE, virtualID || false, values]; }, - + // (1, id, { values }) + UPDATE: 1, update(id, values) { delete values.id; - return [1, id, values]; + return [x2ManyCommands.UPDATE, id, values]; }, - + // (2, id[, _]) + DELETE: 2, delete(id) { - return [2, id, false]; + return [x2ManyCommands.DELETE, id, false]; }, - + // (3, id[, _]) removes relation, but not linked record itself + FORGET: 3, forget(id) { - return [3, id, false]; + return [x2ManyCommands.FORGET, id, false]; }, - + // (4, id[, _]) + LINK_TO: 4, linkTo(id) { - return [4, id, false]; + return [x2ManyCommands.LINK_TO, id, false]; }, - + // (5[, _[, _]]) + DELETE_ALL: 5, deleteAll() { - return [5, false, false]; + return [x2ManyCommands.DELETE_ALL, false, false]; }, - + // (6, _, ids) replaces all linked records with provided ids + REPLACE_WITH: 6, replaceWith(ids) { - return [6, false, ids]; + return [x2ManyCommands.REPLACE_WITH, false, ids]; }, };