diff --git a/addons/event_booth_sale/static/src/js/sale_product_field.js b/addons/event_booth_sale/static/src/js/sale_product_field.js index 9be68a1f8ae..7c6cb6cdc32 100644 --- a/addons/event_booth_sale/static/src/js/sale_product_field.js +++ b/addons/event_booth_sale/static/src/js/sale_product_field.js @@ -64,7 +64,7 @@ patch(SaleOrderLineProductField.prototype, { this.props.record.update({ event_id, event_booth_category_id, - event_booth_pending_ids: [x2ManyCommands.replaceWith(event_booth_pending_ids)], + event_booth_pending_ids: [x2ManyCommands.set(event_booth_pending_ids)], }); } } diff --git a/addons/sale_product_configurator/static/src/js/sale_product_field.js b/addons/sale_product_configurator/static/src/js/sale_product_field.js index 4b3486b4146..d7c9e4a0c3a 100644 --- a/addons/sale_product_configurator/static/src/js/sale_product_field.js +++ b/addons/sale_product_configurator/static/src/js/sale_product_field.js @@ -33,7 +33,7 @@ async function applyProduct(record, product) { await record.update({ product_id: [product.id, product.display_name], product_uom_qty: product.quantity, - product_no_variant_attribute_value_ids: [x2ManyCommands.replaceWith(noVariantPTAVIds)], + product_no_variant_attribute_value_ids: [x2ManyCommands.set(noVariantPTAVIds)], }); }; diff --git a/addons/web/static/src/core/orm_service.js b/addons/web/static/src/core/orm_service.js index ca2bf35cb41..9b998a85bf5 100644 --- a/addons/web/static/src/core/orm_service.js +++ b/addons/web/static/src/core/orm_service.js @@ -42,24 +42,24 @@ export const x2ManyCommands = { return [x2ManyCommands.DELETE, id, false]; }, // (3, id[, _]) removes relation, but not linked record itself - FORGET: 3, - forget(id) { - return [x2ManyCommands.FORGET, id, false]; + UNLINK: 3, + unlink(id) { + return [x2ManyCommands.UNLINK, id, false]; }, // (4, id[, _]) - LINK_TO: 4, - linkTo(id) { - return [x2ManyCommands.LINK_TO, id, false]; + LINK: 4, + link(id) { + return [x2ManyCommands.LINK, id, false]; }, // (5[, _[, _]]) - DELETE_ALL: 5, - deleteAll() { - return [x2ManyCommands.DELETE_ALL, false, false]; + CLEAR: 5, + clear() { + return [x2ManyCommands.CLEAR, false, false]; }, // (6, _, ids) replaces all linked records with provided ids - REPLACE_WITH: 6, - replaceWith(ids) { - return [x2ManyCommands.REPLACE_WITH, false, ids]; + SET: 6, + set(ids) { + return [x2ManyCommands.SET, false, ids]; }, }; diff --git a/addons/web/static/src/model/relational_model/record.js b/addons/web/static/src/model/relational_model/record.js index bfb27580cc9..f06ddc66898 100644 --- a/addons/web/static/src/model/relational_model/record.js +++ b/addons/web/static/src/model/relational_model/record.js @@ -754,7 +754,7 @@ export class Record extends DataPoint { const list = this.data[fieldName]; for (const command of value) { switch (command[0]) { - case x2ManyCommands.REPLACE_WITH: + case x2ManyCommands.SET: await list._replaceWith(command[2]); break; default: diff --git a/addons/web/static/src/model/relational_model/static_list.js b/addons/web/static/src/model/relational_model/static_list.js index 386112892fa..e7fb22a5bb6 100644 --- a/addons/web/static/src/model/relational_model/static_list.js +++ b/addons/web/static/src/model/relational_model/static_list.js @@ -291,7 +291,7 @@ export class StaticList extends DataPoint { forget(record) { return this.model.mutex.exec(async () => { - await this._applyCommands([[x2ManyCommands.FORGET, record.resId]]); + await this._applyCommands([[x2ManyCommands.UNLINK, record.resId]]); await this._onUpdate(); }); } @@ -328,7 +328,7 @@ export class StaticList extends DataPoint { linkTo(resId, serverData) { return this.model.mutex.exec(async () => { - await this._applyCommands([[x2ManyCommands.LINK_TO, resId, serverData]]); + await this._applyCommands([[x2ManyCommands.LINK, resId, serverData]]); await this._onUpdate(); }); } @@ -464,7 +464,7 @@ export class StaticList extends DataPoint { _applyCommands(commands) { const isOnLastPage = this.limit + this.offset >= this.count; - const { CREATE, UPDATE, DELETE, FORGET, LINK_TO, REPLACE_WITH } = x2ManyCommands; + const { CREATE, UPDATE, DELETE, UNLINK, LINK, SET } = x2ManyCommands; for (const command of commands) { switch (command[0]) { case CREATE: { @@ -518,7 +518,7 @@ export class StaticList extends DataPoint { break; } case DELETE: - case FORGET: { + case UNLINK: { if (command[0] === DELETE) { if (!this._commands.find((c) => c[0] === CREATE && c[1] === command[1])) { this._commands.push([DELETE, command[1]]); @@ -529,7 +529,7 @@ export class StaticList extends DataPoint { } else { // FORGET const replaceWithIndex = this._commands.findIndex( - (c) => c[0] === REPLACE_WITH && c[2].includes(command[1]) + (c) => c[0] === SET && c[2].includes(command[1]) ); if (replaceWithIndex >= 0) { const ids = this._commands[replaceWithIndex][2]; @@ -538,12 +538,12 @@ export class StaticList extends DataPoint { ); } else { const linkToIndex = this._commands.findIndex( - (c) => c[0] === LINK_TO && c[1] === command[1] + (c) => c[0] === LINK && c[1] === command[1] ); if (linkToIndex >= 0) { this._commands.splice(linkToIndex, 1); } else { - this._commands.push([FORGET, command[1]]); + this._commands.push([UNLINK, command[1]]); } } } @@ -559,7 +559,7 @@ export class StaticList extends DataPoint { this.count--; break; } - case LINK_TO: { + case LINK: { const record = this._createRecordDatapoint({ ...command[2], id: command[1] }); if (!this.limit || this.records.length < this.limit) { this.records.push(record); @@ -824,7 +824,7 @@ export class StaticList extends DataPoint { const updateCommandsToKeep = this._commands.filter( (c) => c[0] === x2ManyCommands.UPDATE && ids.includes(c[1]) ); - this._commands = [x2ManyCommands.replaceWith(ids)].concat(updateCommandsToKeep); + this._commands = [x2ManyCommands.set(ids)].concat(updateCommandsToKeep); this._currentIds = [...ids]; this.count = this._currentIds.length; }