diff --git a/edit_save_button/__manifest__.py b/edit_save_button/__manifest__.py index a02f0c705..95e614c9b 100644 --- a/edit_save_button/__manifest__.py +++ b/edit_save_button/__manifest__.py @@ -22,7 +22,7 @@ { 'name': 'Edit Button In Odoo16', - 'version': '16.0.1.0.2', + 'version': '16.0.1.0.3', 'summary': 'Edit Button Odoo16', 'description': 'Edit Button in Odoo16', 'author': 'Cybrosys Techno Solutions', diff --git a/edit_save_button/static/src/views/form/form_controller.js b/edit_save_button/static/src/views/form/form_controller.js index 6c9156329..977e25fea 100644 --- a/edit_save_button/static/src/views/form/form_controller.js +++ b/edit_save_button/static/src/views/form/form_controller.js @@ -16,29 +16,34 @@ const viewRegistry = registry.category("views"); odoo.__DEBUG__ && console.log("Console log inside the patch function", FormController.prototype, "form_controller"); -var data = false; patch(FormController.prototype, "save",{ setup() { - data = false; - this.props.preventEdit = !data + this.props.preventEdit = this.env.inDialog ? false :true; this._super(); }, async edit(){ this._super(); - data = true; await this.model.root.switchMode("edit"); }, async saveButtonClicked(params = {}){ this._super(); - data = false; - await this.model.root.switchMode("readonly"); + if (this.env.inDialog == false){ + await this.model.root.switchMode("readonly"); + } + else { + this.model.actionService.doAction({type: 'ir.actions.act_window_close'}); + } }, async discard(){ this._super(); - data = false; - await this.model.root.switchMode("readonly"); + if (this.env.inDialog == false){ + await this.model.root.switchMode("readonly"); + } + else { + this.model.actionService.doAction({type: 'ir.actions.act_window_close'}); + } }, async beforeLeave() { if (this.model.root.isDirty) { diff --git a/edit_save_button/views/test.xml b/edit_save_button/views/test.xml new file mode 100644 index 000000000..2ff6c2f59 --- /dev/null +++ b/edit_save_button/views/test.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + +