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',
'version': '18.0.1.1.0',
'version': '18.0.1.1.1',
'category': 'Extra Tools',
'summary': """Restrict auto save in all models""",
'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
#### UPDATE
- 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 { ListConfirmationDialog } from "@web/views/list/list_confirmation_dialog";
patch(ListController.prototype, {
/* Patch ListController to restrict auto save in tree views */
setup(){

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

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