From 2ae0f239b5ca5b4eb92f506032e31c1267fd3e7a Mon Sep 17 00:00:00 2001 From: FrancoisGe Date: Tue, 24 Oct 2023 10:25:04 +0200 Subject: [PATCH] [REM] im_livechat: remove obsolete patch on X2ManyFieldDialog Since the new RelationalModel (PR 114024), when you click Save and New in X2ManyFieldDialog, the new record has its sequence correctly incremented by 1 compared with the previous record. So the patch on X2ManyFieldDialog in im_livechat_chatbot_steps_one2many.js is no longer necessary. So we're going to remove it. closes odoo/odoo#139551 Signed-off-by: Aaron Bohy (aab) --- .../js/im_livechat_chatbot_steps_one2many.js | 38 +------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/addons/im_livechat/static/src/js/im_livechat_chatbot_steps_one2many.js b/addons/im_livechat/static/src/js/im_livechat_chatbot_steps_one2many.js index 2dc588ada9e..f5c339a1f02 100644 --- a/addons/im_livechat/static/src/js/im_livechat_chatbot_steps_one2many.js +++ b/addons/im_livechat/static/src/js/im_livechat_chatbot_steps_one2many.js @@ -1,48 +1,12 @@ /* @odoo-module */ import { registry } from "@web/core/registry"; -import { patch } from "@web/core/utils/patch"; -import { - useX2ManyCrud, - useOpenX2ManyRecord, - X2ManyFieldDialog, -} from "@web/views/fields/relational_utils"; +import { useX2ManyCrud, useOpenX2ManyRecord } from "@web/views/fields/relational_utils"; import { X2ManyField, x2ManyField } from "@web/views/fields/x2many/x2many_field"; import { ListRenderer } from "@web/views/list/list_renderer"; const fieldRegistry = registry.category("fields"); -patch(X2ManyFieldDialog.prototype, { - /** - * Dirty patching of the 'X2ManyFieldDialog'. - * It is done to force the "save and new" to close the dialog first, and then click again on - * the "Add a line" link. - * - * This is the only way (or at least the least complicated) to correctly compute the sequence - * field, which is crucial when creating chatbot.steps, as they depend on each other. - * - */ - async save({ saveAndNew }) { - if (this.record.resModel !== "chatbot.script.step") { - return super.save(...arguments); - } - - if (await this.record.checkValidity()) { - this.record = (await this.props.save(this.record, { saveAndNew })) || this.record; - } else { - return false; - } - - this.props.close(); - - if (saveAndNew) { - document.querySelector(".o_field_x2many_list_row_add a").click(); - } - - return true; - }, -}); - export class ChatbotStepsOne2manyRenderer extends ListRenderer { /** * Small override to force column entries to be non-sortable.