summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/relational_fields.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-11-07 15:28:28 +0100
committerChristophe Simonis <chs@odoo.com>2017-11-07 15:28:28 +0100
commit449ec5e29dab7b4a306c824666160fdf6b79088a (patch)
treed6fc7ee2f5e0a41bfe65b6d6ebd090aa7e76051d /addons/web/static/src/js/fields/relational_fields.js
parent8670f62e3c1d57371e34836b84a0f5079b2ad0e6 (diff)
parent255478acbd66f01daf32422636f09f2014ebc9f8 (diff)
[MERGE] forward port branch saas-16 up to 255478acbd6
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js30
1 files changed, 29 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 ae3080b3b8e..2d2a5d5ea4d 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -46,7 +46,7 @@ var M2ODialog = Dialog.extend({
click: function () {
if (this.$("input").val() !== ''){
this.trigger_up('quick_create', { value: this.$('input').val() });
- this.close();
+ this.close(true);
} else {
this.$("input").focus();
}
@@ -71,12 +71,30 @@ var M2ODialog = Dialog.extend({
this.$("p").text(_.str.sprintf(_t("You are creating a new %s, are you sure it does not exist yet?"), this.name));
this.$("input").val(this.value);
},
+ /**
+ * @override
+ * @param {boolean} isSet
+ */
+ close: function (isSet) {
+ this.isSet = isSet;
+ this._super.apply(this, arguments);
+ },
+ /**
+ * @override
+ */
+ destroy: function () {
+ if (!this.isSet) {
+ this.trigger_up('closed_unset');
+ }
+ this._super.apply(this, arguments);
+ },
});
var FieldMany2One = AbstractField.extend({
supportedFieldTypes: ['many2one'],
template: 'FieldMany2One',
custom_events: _.extend({}, AbstractField.prototype.custom_events, {
+ 'closed_unset': '_onDialogClosedUnset',
'quick_create': '_onQuickCreate',
'search_create_popup': '_onSearchCreatePopup',
}),
@@ -451,6 +469,16 @@ var FieldMany2One = AbstractField.extend({
});
}
},
+
+ /**
+ * Reset the input as dialog has been closed without m2o creation.
+ *
+ * @private
+ */
+ _onDialogClosedUnset: function () {
+ this.floating = false;
+ this._render();
+ },
/**
* @private
*/