In Version 17 -when we do some modification - ODOO saving automatically.
How to stop this and user want to save himself - by pressing exclusive save button
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
In Version 17 -when we do some modification - ODOO saving automatically.
How to stop this and user want to save himself - by pressing exclusive save button
Hi,
By patching FormController, we can restrict auto-save in form views. By restricting the auto-save, the form will not save if we refresh the page.Use the following code for patching the FormController:
/** @odoo-module */
import { FormController } from "@web/views/form/form_controller";
import { patch } from "@web/core/utils/patch";
import { useSetupView } from "@web/views/view_hook";
patch(FormController.prototype, {
setup(){
super.setup(...arguments);
this.beforeLeaveHook = false
useSetupView({
beforeLeave: () => this.beforeLeave(),
beforeUnload: (ev) => this.beforeUnload(ev),
});
},
async beforeLeave() {
/* function will work before leave the form */
if(this.model.root.isDirty && this.beforeLeaveHook == false){
if (this.env.searchModel && this.env.searchModel.resModel != 'model.name') {
this.beforeLeaveHook = true
await this.model.root.save({
reload: false,
onError: this.onSaveError.bind(this),
});
} else {
this.beforeLeaveHook = true
this.model.root.discard();
}
}
},
beforeUnload: async (ev) => {
ev.preventDefault();
}
});
Hope it helps.
Hi,
Please use the below module for prevent auto save feature
Hope it helps!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.