From 2a40c78a8b529828fc8671d362dcf80e0f68b631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 5 Apr 2017 09:25:02 +0200 Subject: [PATCH] [FIX] web: fix rendering issue with fieldselection on m2o Before this commit, the FieldSelection did not work properly in edit mode with a many2one. This was because it did not take the correct value into account, and the test did not notice it, so both had to be fixed. --- .../static/src/js/fields/relational_fields.js | 47 +++++-------------- .../test/fields/relational_fields_tests.js | 34 ++++++++++---- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 4ae30264ff0..1946cfeb529 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -1337,7 +1337,6 @@ var FieldSelection = AbstractField.extend({ */ init: function () { this._super.apply(this, arguments); - this.values = []; if (this.field.type === 'many2one') { this.values = this.record.specialData[this.name]; } else { @@ -1352,35 +1351,24 @@ var FieldSelection = AbstractField.extend({ // Private //-------------------------------------------------------------------------- - /** - * Format the value to a valid string - * - * @override - * @private - * @param {any} value - * @returns {string} - */ - _formatValue: function (value) { - if (this.field.type === 'many2one') { - var options = _.extend({}, this.nodeOptions); - return field_utils.format.many2one(value, this.field, this.recordData, options); - } else { - return this._super(value); - } - }, /** * @override * @private */ _renderEdit: function () { - this.$el.empty(); - for (var i = 0 ; i < this.values.length ; i++) { - this.$el.append($('