Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix edit_save_button check required on save #295

Open
wants to merge 3 commits into
base: 16.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions edit_save_button/static/src/views/form/form_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,45 @@ const viewRegistry = registry.category("views");

odoo.__DEBUG__ && console.log("Console log inside the patch function", FormController.prototype, "form_controller");

patch(FormController.prototype, "save",{
patch(FormController.prototype, "save", {
setup() {
this.props.preventEdit = this.env.inDialog ? false :true;
this.props.preventEdit = !this.env.inDialog;
this._super();
},

async edit(){
async edit() {
this._super();
await this.model.root.switchMode("edit");
},
async saveButtonClicked(params = {}){
this._super();
if (this.env.inDialog == false){
await this.model.root.switchMode("readonly");
}
else {
this.model.actionService.doAction({type: 'ir.actions.act_window_close'});
async saveButtonClicked(params = {}) {
const saved = await this._super();
if (saved) {
if (!this.env.inDialog){
await this.model.root.switchMode("readonly");
}
else {
this.model.actionService.doAction({type: 'ir.actions.act_window_close'});
}
}
},
async discard(){
async discard() {
this._super();
if (this.env.inDialog == false){
if (!this.env.inDialog){
await this.model.root.switchMode("readonly");
}
else {
this.model.actionService.doAction({type: 'ir.actions.act_window_close'});
}
},
async beforeLeave() {
async beforeLeave() {
if (this.model.root.isDirty) {
if (confirm("The changes you have made will save Automatically!")) {
return this.model.root.save({noReload: true, stayInEdition: true});
return this.model.root.save({ noReload: true, stayInEdition: true });
} else {
this.model.root.discard();
return true;
}
}
}
}
})