Browse Source

Merge da703d88c2 into 82265ff62f

pull/295/merge
NetItUp-CarloToso 1 year ago
committed by GitHub
parent
commit
2e600613ee
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 32
      edit_save_button/static/src/views/form/form_controller.js

32
edit_save_button/static/src/views/form/form_controller.js

@ -17,43 +17,45 @@ const viewRegistry = registry.category("views");
odoo.__DEBUG__ && console.log("Console log inside the patch function", FormController.prototype, "form_controller"); odoo.__DEBUG__ && console.log("Console log inside the patch function", FormController.prototype, "form_controller");
patch(FormController.prototype, "save",{ patch(FormController.prototype, "save", {
setup() { setup() {
this.props.preventEdit = this.env.inDialog ? false :true; this.props.preventEdit = !this.env.inDialog;
this._super(); this._super();
}, },
async edit(){ async edit() {
this._super(); this._super();
await this.model.root.switchMode("edit"); await this.model.root.switchMode("edit");
}, },
async saveButtonClicked(params = {}){ async saveButtonClicked(params = {}) {
this._super(); const saved = await this._super();
if (this.env.inDialog == false){ if (saved) {
await this.model.root.switchMode("readonly"); if (!this.env.inDialog){
} await this.model.root.switchMode("readonly");
else { }
this.model.actionService.doAction({type: 'ir.actions.act_window_close'}); else {
this.model.actionService.doAction({type: 'ir.actions.act_window_close'});
}
} }
}, },
async discard(){ async discard() {
this._super(); this._super();
if (this.env.inDialog == false){ if (!this.env.inDialog){
await this.model.root.switchMode("readonly"); await this.model.root.switchMode("readonly");
} }
else { else {
this.model.actionService.doAction({type: 'ir.actions.act_window_close'}); this.model.actionService.doAction({type: 'ir.actions.act_window_close'});
} }
}, },
async beforeLeave() { async beforeLeave() {
if (this.model.root.isDirty) { if (this.model.root.isDirty) {
if (confirm("The changes you have made will save Automatically!")) { 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 { } else {
this.model.root.discard(); this.model.root.discard();
return true; return true;
} }
} }
} }
}) })

Loading…
Cancel
Save