From 81fcf6cce1c88784981b6eb1a5912d75a9471c6b Mon Sep 17 00:00:00 2001 From: Carlos Roca Date: Fri, 8 Mar 2024 14:20:23 +0100 Subject: [PATCH] [IMP] web_drop_target: Avoid errors for undefined elements This changes are done to avoid errors in dms_field. This error is found using this other PR: https://github.com/OCA/dms/pull/310 The steps to reproduce the error are: 1. Create a directory or a file without using drag and drop 2. Drag and drop a file into a folder and you will see the error --- web_drop_target/static/src/js/web_drop_target.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web_drop_target/static/src/js/web_drop_target.js b/web_drop_target/static/src/js/web_drop_target.js index 8c67143c7..c2d0f2b70 100644 --- a/web_drop_target/static/src/js/web_drop_target.js +++ b/web_drop_target/static/src/js/web_drop_target.js @@ -155,7 +155,7 @@ odoo.define("web_drop_target", function (require) { const abstractAction = this.findAncestor(function (ancestor) { return ancestor instanceof AbstractAction; }); - const controller = abstractAction.currentDialogController; + const controller = abstractAction && abstractAction.currentDialogController; if ( _.isEmpty(this._get_drop_items(ev)) && this._checkDragOver() && @@ -186,7 +186,9 @@ odoo.define("web_drop_target", function (require) { */ _onBodyFileDrop: function (ev) { ev.preventDefault(); - this._drop_overlay.addClass("d-none"); + if (this._drop_overlay) { + this._drop_overlay.addClass("d-none"); + } }, /**