[ADD] new module confirm_many2one_create

Pure JS module to override the behaviour of Many2One fields, causing
them to open a confirmation dialog when the user selects the "Create"
option from the autocomplete list of a Many2One field with quick create
enabled.
This commit is contained in:
Marc Durepos 2024-08-02 14:41:56 -04:00
parent 5a53548693
commit 8e5185a80f
3 changed files with 47 additions and 0 deletions

View file

View file

@ -0,0 +1,35 @@
#
# Bemade Inc.
#
# Copyright (C) 2023-June Bemade Inc. (<https://www.bemade.org>).
# Author: Marc Durepos (Contact : marc@bemade.org)
#
# This program is under the terms of the GNU Lesser General Public License,
# version 3.
#
# For full license details, see https://www.gnu.org/licenses/lgpl-3.0.en.html.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
{
"name": "Many2one Confirm Creation",
"version": "17.0.1.0.0",
"summary": "Pop up a confirmation dialog when creating via a Many2one field",
"category": "Web",
"author": "Bemade Inc.",
"website": "http://www.bemade.org",
"license": "LGPL-3",
"depends": ["web"],
"data": [],
"assets": {
"web.assets_backend": ["confirm_many2one_create/src/js/many2one_field.esm.js"]
},
"installable": True,
"auto_install": False,
}

View file

@ -0,0 +1,12 @@
/** @odoo-module **/
import {Many2OneField} from "@web/views/fields/many2one/many2one_field";
import {patch} from "@web/core/utils/patch";
patch(Many2OneField.prototype, {
get Many2XAutocompleteProps() {
const props = super.Many2XAutocompleteProps();
props.quickCreate = this.openConfirmationDialog.bind(this);
return props;
},
});