summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/relational_fields.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js22
1 files changed, 17 insertions, 5 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 3b47b8c64b0..419d1f5f646 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -124,7 +124,7 @@ var FieldMany2One = AbstractField.extend({
* @returns {jQuery}
*/
getFocusableElement: function () {
- return this.$input || $();
+ return this.mode === 'edit' && this.$input || this.$el;
},
/**
* TODO
@@ -206,6 +206,17 @@ var FieldMany2One = AbstractField.extend({
return [];
},
/**
+ * Returns the display_name from a string which contains it but was altered
+ * as a result of the show_address option using a horrible hack.
+ *
+ * @private
+ * @param {string} value
+ * @returns {string} display_name without show_address mess
+ */
+ _getDisplayName: function (value) {
+ return value.split('\n')[0];
+ },
+ /**
* @private
* @param {string} name
*/
@@ -244,7 +255,7 @@ var FieldMany2One = AbstractField.extend({
// and hope for the best that noone tries to uses this mechanism to do
// something else.
if (this.nodeOptions.always_reload) {
- value = value.split('\n')[0];
+ value = this._getDisplayName(value);
}
this.$input.val(value);
if (!this.autocomplete_bound) {
@@ -302,7 +313,7 @@ var FieldMany2One = AbstractField.extend({
.then(function (result) {
// possible selections for the m2o
var values = _.map(result, function (x) {
- x[1] = x[1].split("\n")[0];
+ x[1] = self._getDisplayName(x[1]);
return {
label: _.str.escapeHTML(x[1].trim()) || data.noDisplayContent,
value: x[1],
@@ -478,7 +489,7 @@ var FieldMany2One = AbstractField.extend({
_onInputKeyup: function () {
if (this.$input.val() === "") {
this.reinitialize(false);
- } else if (this.m2o_value !== this.$input.val()) {
+ } else if (this._getDisplayName(this.m2o_value) !== this.$input.val()) {
this.floating = true;
this._updateExternalButton();
}
@@ -1585,7 +1596,7 @@ var FormFieldMany2ManyTags = FieldMany2ManyTags.extend({
var KanbanFieldMany2ManyTags = FieldMany2ManyTags.extend({
_render: function () {
var self = this;
- this.$el.addClass('o_field_many2manytags o_kanban_tags');
+ this.$el.empty().addClass('o_field_many2manytags o_kanban_tags');
_.each(this.value.data, function (m2m) {
// 10th color is invisible
if ('color' in m2m.data && m2m.data.color !== 10) {
@@ -1763,6 +1774,7 @@ var FieldSelection = AbstractField.extend({
this._super.apply(this, arguments);
if (this.field.type === 'many2one') {
this.values = this.record.specialData[this.name];
+ this.formatType = 'many2one';
} else {
this.values = _.reject(this.field.selection, function (v) {
return v[0] === false && v[1] === '';