[MIG] confirm_many2one_create to 18.0
This commit is contained in:
parent
8e69382d84
commit
e0f55f4458
3 changed files with 66 additions and 0 deletions
0
confirm_many2one_create/__init__.py
Normal file
0
confirm_many2one_create/__init__.py
Normal file
37
confirm_many2one_create/__manifest__.py
Normal file
37
confirm_many2one_create/__manifest__.py
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
#
|
||||||
|
# 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": "18.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/static/src/js/many2one_field.esm.js",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"installable": True,
|
||||||
|
"auto_install": False,
|
||||||
|
}
|
||||||
29
confirm_many2one_create/static/src/js/many2one_field.esm.js
Normal file
29
confirm_many2one_create/static/src/js/many2one_field.esm.js
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
/** @odoo-module **/
|
||||||
|
|
||||||
|
import {Many2OneField, m2oTupleFromData} from "@web/views/fields/many2one/many2one_field";
|
||||||
|
import {patch} from "@web/core/utils/patch";
|
||||||
|
|
||||||
|
patch(Many2OneField.prototype, {
|
||||||
|
/**
|
||||||
|
* The original Many2OneField already has a quickCreate method and an openConfirmationDialog method.
|
||||||
|
* The quickCreate method directly updates the record, while openConfirmationDialog shows a dialog
|
||||||
|
* before calling quickCreate.
|
||||||
|
*
|
||||||
|
* We just need to modify the Many2XAutocompleteProps getter to use openConfirmationDialog
|
||||||
|
* instead of quickCreate for the quickCreate property.
|
||||||
|
*/
|
||||||
|
get Many2XAutocompleteProps() {
|
||||||
|
const props = super.Many2XAutocompleteProps;
|
||||||
|
|
||||||
|
// If quickCreate is defined, replace it with openConfirmationDialog
|
||||||
|
if (props.quickCreate && this.openConfirmationDialog) {
|
||||||
|
// Store the original quickCreate function
|
||||||
|
const originalQuickCreate = props.quickCreate;
|
||||||
|
|
||||||
|
// Replace with openConfirmationDialog
|
||||||
|
props.quickCreate = (name) => this.openConfirmationDialog(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return props;
|
||||||
|
},
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue