diff --git a/web_copy_confirm/README.rst b/web_copy_confirm/README.rst index bd1a8bc18..466d6171a 100644 --- a/web_copy_confirm/README.rst +++ b/web_copy_confirm/README.rst @@ -14,7 +14,7 @@ Show confirmation dialogue before copying records :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github - :target: https://github.com/OCA/web/tree/15.0/web_copy_confirm + :target: https://github.com/OCA/web/tree/16.0/web_copy_confirm :alt: OCA/web .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png :target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_copy_confirm @@ -63,6 +63,7 @@ Contributors * Stefan Rijnhart * Robin Conjour +* Dhara Solanki Maintainers ~~~~~~~~~~~ @@ -77,6 +78,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/web `_ project on GitHub. +This module is part of the `OCA/web `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_copy_confirm/__manifest__.py b/web_copy_confirm/__manifest__.py index 805514947..48b03dbdd 100644 --- a/web_copy_confirm/__manifest__.py +++ b/web_copy_confirm/__manifest__.py @@ -13,7 +13,7 @@ ], "assets": { "web.assets_backend": [ - "web_copy_confirm/static/src/js/web_copy_confirm.js", + "web_copy_confirm/static/src/js/web_copy_confirm.esm.js", ], "web.qunit_suite_tests": [ "web_copy_confirm/static/tests/**/*", diff --git a/web_copy_confirm/readme/CONTRIBUTORS.rst b/web_copy_confirm/readme/CONTRIBUTORS.rst index 6462026c0..22134d635 100644 --- a/web_copy_confirm/readme/CONTRIBUTORS.rst +++ b/web_copy_confirm/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Stefan Rijnhart * Robin Conjour +* Dhara Solanki diff --git a/web_copy_confirm/readme/newsfragments/.gitkeep b/web_copy_confirm/readme/newsfragments/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/web_copy_confirm/static/description/index.html b/web_copy_confirm/static/description/index.html index 42161b846..c0e1132d1 100644 --- a/web_copy_confirm/static/description/index.html +++ b/web_copy_confirm/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

This module will show a confirmation dialog when the user selects the Duplicate option from the Action dropdown in the standard form view.

Table of contents

@@ -425,7 +425,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/web project on GitHub.

+

This module is part of the OCA/web project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/web_copy_confirm/static/src/js/web_copy_confirm.esm.js b/web_copy_confirm/static/src/js/web_copy_confirm.esm.js new file mode 100644 index 000000000..6e1f75ef4 --- /dev/null +++ b/web_copy_confirm/static/src/js/web_copy_confirm.esm.js @@ -0,0 +1,23 @@ +/** @odoo-module **/ + +import {patch} from "web.utils"; +import {ConfirmationDialog} from "@web/core/confirmation_dialog/confirmation_dialog"; +import {_t} from "@web/core/l10n/translation"; +import {FormController} from "@web/views/form/form_controller"; + +patch(FormController.prototype, "DuplicateConfirmation", { + async duplicateRecord() { + var _super = this._super; + await this.dialogService.add(ConfirmationDialog, { + title: _t("Duplicate"), + body: _t("Are you sure that you would like to copy this record?"), + confirm: () => { + _super.apply(this, arguments); + }, + cancel: () => { + // `ConfirmationDialog` needs this prop to display the cancel + // button but we do nothing on cancel. + }, + }); + }, +}); diff --git a/web_copy_confirm/static/src/js/web_copy_confirm.js b/web_copy_confirm/static/src/js/web_copy_confirm.js deleted file mode 100644 index 9bf08e952..000000000 --- a/web_copy_confirm/static/src/js/web_copy_confirm.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2018 DynApps -// @author Stefan Rijnhart -// @author Robin Conjour -// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -odoo.define("web_copy_confirm.web_copy_confirm", function (require) { - "use strict"; - - const Core = require("web.core"); - const FormController = require("web.FormController"); - const Dialog = require("web.Dialog"); - const _t = Core._t; - - return FormController.include({ - /** - * Trigger the confirmation dialog when duplicating records - * @returns {Promise} - * @private - */ - _onDuplicateRecordConfirm: async function () { - Dialog.confirm( - this, - _t("Are you sure that you would like to copy this record?"), - { - confirm_callback: () => this._onDuplicateRecord(), - } - ); - }, - /** - * Override the "duplicate" in the action menu - * @returns {any} - * @private - */ - _getActionMenuItems: function () { - const props = this._super(...arguments); - - if (props && props.items && props.items.other) { - const other_list = props.items.other; - const duplicate_index = other_list.findIndex( - (item) => item.description === _t("Duplicate") - ); - if (other_list[duplicate_index]) { - other_list[duplicate_index].callback = () => - this._onDuplicateRecordConfirm(); - } - } - - return props; - }, - }); -});