diff --git a/addons/web/static/src/views/form/form_controller.js b/addons/web/static/src/views/form/form_controller.js index ef3c13c52c3..f32b34892c5 100644 --- a/addons/web/static/src/views/form/form_controller.js +++ b/addons/web/static/src/views/form/form_controller.js @@ -329,13 +329,7 @@ export class FormController extends Component { description: this.env._t("Archive"), icon: "oi oi-archive", callback: () => { - const dialogProps = { - body: this.env._t("Are you sure that you want to archive this record?"), - confirmLabel: this.env._t("Archive"), - confirm: () => this.model.root.archive(), - cancel: () => {}, - }; - this.dialogService.add(ConfirmationDialog, dialogProps); + this.dialogService.add(ConfirmationDialog, this.archiveDialogProps); }, }, unarchive: { @@ -363,6 +357,15 @@ export class FormController extends Component { }; } + get archiveDialogProps() { + return { + body: this.env._t("Are you sure that you want to archive this record?"), + confirmLabel: this.env._t("Archive"), + confirm: () => this.model.root.archive(), + cancel: () => {}, + }; + } + get actionMenuItems() { const { actionMenus } = this.props.info; const staticActionItems = Object.entries(this.getStaticActionMenuItems()) diff --git a/addons/web/static/src/views/list/list_controller.js b/addons/web/static/src/views/list/list_controller.js index 1e1438a9868..7aa5462d6b3 100644 --- a/addons/web/static/src/views/list/list_controller.js +++ b/addons/web/static/src/views/list/list_controller.js @@ -302,17 +302,7 @@ export class ListController extends Component { icon: "oi oi-archive", description: this.env._t("Archive"), callback: () => { - const dialogProps = { - body: this.env._t( - "Are you sure that you want to archive all the selected records?" - ), - confirmLabel: this.env._t("Archive"), - confirm: () => { - this.toggleArchiveState(true); - }, - cancel: () => {}, - }; - this.dialogService.add(ConfirmationDialog, dialogProps); + this.dialogService.add(ConfirmationDialog, this.archiveDialogProps); }, }, unarchive: { @@ -332,6 +322,17 @@ export class ListController extends Component { }; } + get archiveDialogProps() { + return { + body: this.env._t("Are you sure that you want to archive all the selected records?"), + confirmLabel: this.env._t("Archive"), + confirm: () => { + this.toggleArchiveState(true); + }, + cancel: () => {}, + }; + } + get actionMenuItems() { const { actionMenus } = this.props.info; const staticActionItems = Object.entries(this.getStaticActionMenuItems())