mirror of https://github.com/OCA/web.git
[MIG] web_copy_confirm: Migration to 16.0
parent
e59d43f1c4
commit
0b9b94a451
|
@ -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 <stefan@opener.amsterdam>
|
||||
* Robin Conjour <rconjour@demolium.com>
|
||||
* Dhara Solanki <dhara.solanki@initos.com>
|
||||
|
||||
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 <https://github.com/OCA/web/tree/15.0/web_copy_confirm>`_ project on GitHub.
|
||||
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_copy_confirm>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
|
|
@ -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/**/*",
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
* Stefan Rijnhart <stefan@opener.amsterdam>
|
||||
* Robin Conjour <rconjour@demolium.com>
|
||||
* Dhara Solanki <dhara.solanki@initos.com>
|
||||
|
|
|
@ -367,7 +367,7 @@ ul.auto-toc {
|
|||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_copy_confirm"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_copy_confirm"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_copy_confirm"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_copy_confirm"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module will show a confirmation dialog when the user selects the
|
||||
<cite>Duplicate</cite> option from the <cite>Action</cite> dropdown in the standard form view.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
|
@ -425,7 +425,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||
<p>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.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_copy_confirm">OCA/web</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_copy_confirm">OCA/web</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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.
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
|
@ -1,50 +0,0 @@
|
|||
// Copyright (C) 2018 DynApps <http://www.dynapps.be>
|
||||
// @author Stefan Rijnhart <stefan@opener.amsterdam>
|
||||
// @author Robin Conjour <rconjour@demolium.com>
|
||||
// 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<void>}
|
||||
* @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;
|
||||
},
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue