diff --git a/auto_save_restrict/__manifest__.py b/auto_save_restrict/__manifest__.py index 42ea2f2f1..5dbc4b61e 100644 --- a/auto_save_restrict/__manifest__.py +++ b/auto_save_restrict/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################# { 'name': 'Auto Save Restrict', - 'version': '18.0.1.1.0', + 'version': '18.0.1.1.1', 'category': 'Extra Tools', 'summary': """Restrict auto save in all models""", 'description': 'Using this module,we can restrict' diff --git a/auto_save_restrict/doc/RELEASE_NOTES.md b/auto_save_restrict/doc/RELEASE_NOTES.md index a9790d019..7151bcb0a 100644 --- a/auto_save_restrict/doc/RELEASE_NOTES.md +++ b/auto_save_restrict/doc/RELEASE_NOTES.md @@ -9,3 +9,8 @@ #### Version 18.0.1.1.0 #### UPDATE - Auto save restrict for smart button + +#### 19.12.2025 +#### Version 18.0.1.1.1 +#### UPDATE +- Fixed the issue causing the restriction to trigger twice in wizard processes diff --git a/auto_save_restrict/static/src/js/list_controller.js b/auto_save_restrict/static/src/js/list_controller.js index 843fa3b7a..ad1ce8ffb 100644 --- a/auto_save_restrict/static/src/js/list_controller.js +++ b/auto_save_restrict/static/src/js/list_controller.js @@ -7,8 +7,6 @@ import { SettingsConfirmationDialog } from "@web/webclient/settings_form_view/se import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { ListConfirmationDialog } from "@web/views/list/list_confirmation_dialog"; - - patch(ListController.prototype, { /* Patch ListController to restrict auto save in tree views */ setup(){ diff --git a/auto_save_restrict/static/src/js/view_button.js b/auto_save_restrict/static/src/js/view_button.js index c950efae3..ff7b8fbdb 100644 --- a/auto_save_restrict/static/src/js/view_button.js +++ b/auto_save_restrict/static/src/js/view_button.js @@ -11,7 +11,7 @@ patch(ViewButton.prototype, { setup() { super.setup(...arguments); this.dialogService = useService("dialog"); - this.actionService = useService("action"); // use this instead of old DOM + this.actionService = useService("action"); }, async onClick(ev) { @@ -20,11 +20,26 @@ patch(ViewButton.prototype, { model && typeof model.isDirty === "function" && (await model.isDirty()); if (hasUnsavedChanges) { + if (this.props.tag === "a") { + ev.preventDefault(); + } + ev.stopPropagation(); + const proceed = await this._confirmSave(model); - if (!proceed) return; + if (!proceed) { + return; + } + if (this.props.clickParams) { + return this.env.onClickViewButton({ + clickParams: this.props.clickParams, + getResParams: () => + pick(model, "context", "evalContext", "resModel", "resId", "resIds"), + }); + } + return; } - // Normal button behavior + // Normal button behavior (no unsaved changes) if (this.props.tag === "a") { ev.preventDefault(); } @@ -49,23 +64,16 @@ patch(ViewButton.prototype, { confirm: async () => { try { await model.save(); - // use Action Service instead of onClickViewButton (avoids `el=null`) - if (this.props.clickParams) { - this.actionService.doActionButton({ - name: this.props.clickParams.name, - type: "object", - resModel: model.resModel, - resId: model.resId, - context: model.context, - }); - } + proceed = true; } catch (e) { console.error("Save failed:", e); + proceed = false; } resolve(); }, cancel: async () => { if (model?.discard) await model.discard(); + proceed = true; resolve(); }, stayHere: () => { @@ -77,4 +85,4 @@ patch(ViewButton.prototype, { return proceed; }, -}); +}); \ No newline at end of file