diff --git a/setup/web_confirm_duplicate/odoo/addons/web_confirm_duplicate b/setup/web_confirm_duplicate/odoo/addons/web_confirm_duplicate new file mode 120000 index 000000000..529a7cc55 --- /dev/null +++ b/setup/web_confirm_duplicate/odoo/addons/web_confirm_duplicate @@ -0,0 +1 @@ +../../../../web_confirm_duplicate \ No newline at end of file diff --git a/setup/web_confirm_duplicate/setup.py b/setup/web_confirm_duplicate/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_confirm_duplicate/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_confirm_duplicate/README.rst b/web_confirm_duplicate/README.rst new file mode 100644 index 000000000..6dc2d9fc6 --- /dev/null +++ b/web_confirm_duplicate/README.rst @@ -0,0 +1,87 @@ +===================== +Web Confirm Duplicate +===================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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/13.0/web_confirm_duplicate + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_confirm_duplicate + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a confirmation dialog when duplicating a record. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Go to a form view of any record, click duplicate. A confirmation dialog will +pop up. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Lois Rilo + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-LoisRForgeFlow| image:: https://github.com/LoisRForgeFlow.png?size=40px + :target: https://github.com/LoisRForgeFlow + :alt: LoisRForgeFlow + +Current `maintainer `__: + +|maintainer-LoisRForgeFlow| + +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_confirm_duplicate/__init__.py b/web_confirm_duplicate/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/web_confirm_duplicate/__manifest__.py b/web_confirm_duplicate/__manifest__.py new file mode 100644 index 000000000..2c88b60c3 --- /dev/null +++ b/web_confirm_duplicate/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2022 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Web Confirm Duplicate", + "summary": "Adds a confirmation dialog when duplicating a record.", + "version": "13.0.1.0.0", + "depends": ["web"], + "data": ["templates/assets.xml"], + "author": "ForgeFlow, Odoo Community Association (OCA)", + "maintainers": ["LoisRForgeFlow"], + "development_status": "Beta", + "website": "https://github.com/OCA/web", + "license": "AGPL-3", + "installable": True, +} diff --git a/web_confirm_duplicate/readme/CONTRIBUTORS.rst b/web_confirm_duplicate/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..77dfbe89e --- /dev/null +++ b/web_confirm_duplicate/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Lois Rilo diff --git a/web_confirm_duplicate/readme/DESCRIPTION.rst b/web_confirm_duplicate/readme/DESCRIPTION.rst new file mode 100644 index 000000000..d5c9aa1ab --- /dev/null +++ b/web_confirm_duplicate/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds a confirmation dialog when duplicating a record. diff --git a/web_confirm_duplicate/readme/USAGE.rst b/web_confirm_duplicate/readme/USAGE.rst new file mode 100644 index 000000000..17efc1348 --- /dev/null +++ b/web_confirm_duplicate/readme/USAGE.rst @@ -0,0 +1,2 @@ +Go to a form view of any record, click duplicate. A confirmation dialog will +pop up. diff --git a/web_confirm_duplicate/static/description/icon.png b/web_confirm_duplicate/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_confirm_duplicate/static/description/icon.png differ diff --git a/web_confirm_duplicate/static/description/index.html b/web_confirm_duplicate/static/description/index.html new file mode 100644 index 000000000..69b28ef26 --- /dev/null +++ b/web_confirm_duplicate/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Web Confirm Duplicate + + + +
+

Web Confirm Duplicate

+ + +

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

+

This module adds a confirmation dialog when duplicating a record.

+

Table of contents

+ +
+

Usage

+

Go to a form view of any record, click duplicate. A confirmation dialog will +pop up.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

LoisRForgeFlow

+

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_confirm_duplicate/static/src/js/basic_view.js b/web_confirm_duplicate/static/src/js/basic_view.js new file mode 100644 index 000000000..ec4f53dc7 --- /dev/null +++ b/web_confirm_duplicate/static/src/js/basic_view.js @@ -0,0 +1,14 @@ +/* Copyright 2022 ForgeFlow S.L. + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ +odoo.define("web_confirm_duplicate.basic_view", function(require) { + "use strict"; + + var BasicView = require("web.BasicView"); + + BasicView.include({ + init: function() { + this._super.apply(this, arguments); + this.controllerParams.confirmOnDuplicate = true; + }, + }); +}); diff --git a/web_confirm_duplicate/static/src/js/form_controller.js b/web_confirm_duplicate/static/src/js/form_controller.js new file mode 100644 index 000000000..28e5fb12b --- /dev/null +++ b/web_confirm_duplicate/static/src/js/form_controller.js @@ -0,0 +1,38 @@ +/* Copyright 2022 ForgeFlow S.L. + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ +odoo.define("web_confirm_duplicate", function(require) { + "use strict"; + + var FormController = require("web.FormController"); + var Dialog = require("web.Dialog"); + var _t = require("web.core")._t; + + FormController.include({ + init: function(parent, model, renderer, params) { + this._super.apply(this, arguments); + this.confirmOnDuplicate = params.confirmOnDuplicate; + }, + + _onDuplicateRecord: function() { + var self = this; + function doIt() { + self.model.duplicateRecord(self.handle).then(function(handle) { + self.handle = handle; + self._updateEnv(); + self._setMode("edit"); + }); + } + if (this.confirmOnDuplicate) { + Dialog.confirm( + this, + _t("Are you sure you want to duplicate this record ?"), + { + confirm_callback: doIt, + } + ); + } else { + return self._super.apply(this, arguments); + } + }, + }); +}); diff --git a/web_confirm_duplicate/templates/assets.xml b/web_confirm_duplicate/templates/assets.xml new file mode 100644 index 000000000..79c5030d5 --- /dev/null +++ b/web_confirm_duplicate/templates/assets.xml @@ -0,0 +1,19 @@ + + +