Browse Source

:Dec 30 [FIX] Bug Fixed 'auto_save_restrict'

18.0
Risvana Cybro 2 days ago
parent
commit
fc76ecc1ea
  1. 2
      auto_save_restrict/__manifest__.py
  2. 5
      auto_save_restrict/doc/RELEASE_NOTES.md
  3. 2
      auto_save_restrict/static/src/js/list_controller.js
  4. 36
      auto_save_restrict/static/src/js/view_button.js

2
auto_save_restrict/__manifest__.py

@ -21,7 +21,7 @@
############################################################################# #############################################################################
{ {
'name': 'Auto Save Restrict', 'name': 'Auto Save Restrict',
'version': '18.0.1.1.0', 'version': '18.0.1.1.1',
'category': 'Extra Tools', 'category': 'Extra Tools',
'summary': """Restrict auto save in all models""", 'summary': """Restrict auto save in all models""",
'description': 'Using this module,we can restrict' 'description': 'Using this module,we can restrict'

5
auto_save_restrict/doc/RELEASE_NOTES.md

@ -9,3 +9,8 @@
#### Version 18.0.1.1.0 #### Version 18.0.1.1.0
#### UPDATE #### UPDATE
- Auto save restrict for smart button - Auto save restrict for smart button
#### 19.12.2025
#### Version 18.0.1.1.1
#### UPDATE
- Fixed the issue causing the restriction to trigger twice in wizard processes

2
auto_save_restrict/static/src/js/list_controller.js

@ -7,8 +7,6 @@ import { SettingsConfirmationDialog } from "@web/webclient/settings_form_view/se
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { ListConfirmationDialog } from "@web/views/list/list_confirmation_dialog"; import { ListConfirmationDialog } from "@web/views/list/list_confirmation_dialog";
patch(ListController.prototype, { patch(ListController.prototype, {
/* Patch ListController to restrict auto save in tree views */ /* Patch ListController to restrict auto save in tree views */
setup(){ setup(){

36
auto_save_restrict/static/src/js/view_button.js

@ -11,7 +11,7 @@ patch(ViewButton.prototype, {
setup() { setup() {
super.setup(...arguments); super.setup(...arguments);
this.dialogService = useService("dialog"); this.dialogService = useService("dialog");
this.actionService = useService("action"); // use this instead of old DOM this.actionService = useService("action");
}, },
async onClick(ev) { async onClick(ev) {
@ -20,11 +20,26 @@ patch(ViewButton.prototype, {
model && typeof model.isDirty === "function" && (await model.isDirty()); model && typeof model.isDirty === "function" && (await model.isDirty());
if (hasUnsavedChanges) { if (hasUnsavedChanges) {
if (this.props.tag === "a") {
ev.preventDefault();
}
ev.stopPropagation();
const proceed = await this._confirmSave(model); const proceed = await this._confirmSave(model);
if (!proceed) return; if (!proceed) {
return;
}
if (this.props.clickParams) {
return this.env.onClickViewButton({
clickParams: this.props.clickParams,
getResParams: () =>
pick(model, "context", "evalContext", "resModel", "resId", "resIds"),
});
}
return;
} }
// Normal button behavior // Normal button behavior (no unsaved changes)
if (this.props.tag === "a") { if (this.props.tag === "a") {
ev.preventDefault(); ev.preventDefault();
} }
@ -49,23 +64,16 @@ patch(ViewButton.prototype, {
confirm: async () => { confirm: async () => {
try { try {
await model.save(); await model.save();
// use Action Service instead of onClickViewButton (avoids `el=null`) proceed = true;
if (this.props.clickParams) {
this.actionService.doActionButton({
name: this.props.clickParams.name,
type: "object",
resModel: model.resModel,
resId: model.resId,
context: model.context,
});
}
} catch (e) { } catch (e) {
console.error("Save failed:", e); console.error("Save failed:", e);
proceed = false;
} }
resolve(); resolve();
}, },
cancel: async () => { cancel: async () => {
if (model?.discard) await model.discard(); if (model?.discard) await model.discard();
proceed = true;
resolve(); resolve();
}, },
stayHere: () => { stayHere: () => {
@ -77,4 +85,4 @@ patch(ViewButton.prototype, {
return proceed; return proceed;
}, },
}); });
Loading…
Cancel
Save