summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorfw-bot <otis@odoo.com>2019-10-08 17:04:02 +0000
committerfw-bot <otis@odoo.com>2019-10-09 13:42:59 +0000
commit126788ec147c0f1cb513b6e54edf11652c300b43 (patch)
tree64cac1617da9244ee5809a80fb8b5725a43000eb /addons/web/static/src/js/fields
parent1a895eab1eb8088b537f0ce1133290f5ea155d8c (diff)
[FIX] web: list many2one quick-create
Allows the quick create on m2o in list views Before this commit, when entering a new value in a many2one in a list and exiting the cell through a click, the quick-create modal appeared for the duration of the mousedown. Now, the modal remains and allow to edit the new many2one value Task 2076380 closes odoo/odoo#38289 X-original-commit: c00f84eb0a176b8d23927080078eb02dc2e5d806 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 2e14ee56e8d..f54f46e4ebf 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -901,7 +901,12 @@ var ListFieldMany2One = FieldMany2One.extend({
this.m2oDialogFocused = false;
},
/**
- * In list views, we don't want to try to trigger a fieldChange when the field
+ * In case the focus is lost from a mousedown, we want to prevent the click occuring on the
+ * following mouseup since it might trigger some unwanted list functions.
+ * If it's not the case, we want to remove the added handler on the next mousedown.
+ * @see list_editable_renderer._onWindowClicked()
+ *
+ * Also, in list views, we don't want to try to trigger a fieldChange when the field
* is being emptied. Instead, it will be triggered as the user leaves the field
* while it is empty.
*
@@ -909,6 +914,19 @@ var ListFieldMany2One = FieldMany2One.extend({
* @private
*/
_onInputFocusout: function () {
+ if (this.can_create && this.floating) {
+ // In case the focus out is due to a mousedown, we want to prevent the next click
+ var attachedEvents = ['click', 'mousedown'];
+ var stopNextClick = (function (ev) {
+ ev.stopPropagation();
+ attachedEvents.forEach(function (eventName) {
+ window.removeEventListener(eventName, stopNextClick, true);
+ });
+ }).bind(this);
+ attachedEvents.forEach(function (eventName) {
+ window.addEventListener(eventName, stopNextClick, true);
+ });
+ }
this._super.apply(this, arguments);
if (!this.m2oDialogFocused && this.$input.val() === "" && this.mustSetValue) {
this.reinitialize(false);