diff --git a/auto_save_restrict/doc/RELEASE_NOTES.md b/auto_save_restrict/doc/RELEASE_NOTES.md index e5973dd21..6b03b687d 100644 --- a/auto_save_restrict/doc/RELEASE_NOTES.md +++ b/auto_save_restrict/doc/RELEASE_NOTES.md @@ -10,3 +10,8 @@ ##### BUG FIX - Updated the module by removing the auto save option while reloading the page in form and tree. + +#### 17.04.2024 +#### Version 17.0.1.0.2 +##### BUG FIX +- Fixed the issue in the form where the popup appeared repeatedly diff --git a/auto_save_restrict/static/src/js/form_controller.js b/auto_save_restrict/static/src/js/form_controller.js index 98989261d..b70a7e8d8 100644 --- a/auto_save_restrict/static/src/js/form_controller.js +++ b/auto_save_restrict/static/src/js/form_controller.js @@ -6,6 +6,7 @@ patch(FormController.prototype, { /* Patch FormController to restrict auto save in form views */ setup(){ super.setup(...arguments); + this.beforeLeaveHook = false useSetupView({ beforeLeave: () => this.beforeLeave(), beforeUnload: (ev) => this.beforeUnload(ev), @@ -13,14 +14,16 @@ patch(FormController.prototype, { }, async beforeLeave() { /* function will work before leave the form */ - if(this.model.root.dirty){ + if(this.model.root.isDirty && this.beforeLeaveHook == false){ if (confirm("Do you want to save changes before leaving?")) { + this.beforeLeaveHook = true await this.model.root.save({ reload: false, onError: this.onSaveError.bind(this), }); } else { - this.discard(); + this.beforeLeaveHook = true + this.model.root.discard(); } } },