diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 6053a250c2e..213998b9274 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -501,6 +501,8 @@ var FieldMany2One = AbstractField.extend({
_renderEdit: function () {
var value = this.m2o_value;
+ this.$('.o_field_many2one_extra').html(this._renderValueLines(false));
+
// this is a stupid hack necessary to support the always_reload flag.
// the field value has been reread by the basic model. We use it to
// display the full address of a partner, separated by \n. This is
@@ -516,15 +518,24 @@ var FieldMany2One = AbstractField.extend({
}
this._updateExternalButton();
},
+ /**
+ * @private
+ * @param {boolean} needFirstLine
+ * @returns {string} escaped html of value lines
+ */
+ _renderValueLines: function (needFirstLine) {
+ const escapedValue = _.escape((this.m2o_value || "").trim());
+ const lines = escapedValue.split('\n');
+ if (!needFirstLine) {
+ lines.shift();
+ }
+ return lines.map((line) => `${line}`).join('
');
+ },
/**
* @private
*/
_renderReadonly: function () {
- var escapedValue = _.escape((this.m2o_value || "").trim());
- var value = escapedValue.split('\n').map(function (line) {
- return '' + line + '';
- }).join('
');
- this.$el.html(value);
+ this.$el.html(this._renderValueLines(true));
if (!this.noOpen && this.value) {
this.$el.attr('href', _.str.sprintf('#id=%s&model=%s', this.value.res_id, this.field.relation));
this.$el.addClass('o_form_uri');
@@ -2923,7 +2934,7 @@ var FieldSelection = AbstractField.extend({
this._super.apply(this, arguments);
if (!this.attrs.modifiersValue.invisible && this.mode !== 'readonly') {
this._setValues();
- this._renderEdit();
+ this._render();
}
},
@@ -3017,7 +3028,7 @@ var FieldRadio = FieldSelection.extend({
description: _lt("Radio"),
template: null,
className: 'o_field_radio',
- tagName: 'span',
+ tagName: 'div',
specialData: "_fetchSpecialMany2ones",
supportedFieldTypes: ['selection', 'many2one'],
events: _.extend({}, AbstractField.prototype.events, {
@@ -3028,10 +3039,7 @@ var FieldRadio = FieldSelection.extend({
*/
init: function () {
this._super.apply(this, arguments);
- if (this.mode === 'edit') {
- this.tagName = 'div';
- this.className += this.nodeOptions.horizontal ? ' o_horizontal' : ' o_vertical';
- }
+ this.className += this.nodeOptions.horizontal ? ' o_horizontal' : ' o_vertical';
this.unique_id = _.uniqueId("radio");
this._setValues();
},
@@ -3077,7 +3085,7 @@ var FieldRadio = FieldSelection.extend({
* @private
* @override
*/
- _renderEdit: function () {
+ _render: function () {
var self = this;
var currentValue;
if (this.field.type === 'many2one') {
@@ -3095,6 +3103,7 @@ var FieldRadio = FieldSelection.extend({
index: index,
name: self.unique_id,
value: value,
+ disabled: self.mode !== 'edit',
}));
});
},
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js
index 4923b1ef596..8beebba7df6 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -1618,16 +1618,20 @@ var BasicModel = AbstractModel.extend({
}
var rel_data = _.pick(data, 'id', 'display_name');
+ const viewType = options.viewType || record.viewType;
+ const fieldInfo = record.fieldsInfo[viewType][fieldName] || {};
+ const fieldOptions = fieldInfo.options || {};
+
// the reference field doesn't store its co-model in its field metadata
// but directly in the data (as the co-model isn't fixed)
var def;
- if (rel_data.display_name === undefined) {
+ if (rel_data.display_name === undefined || fieldOptions.always_reload) {
// TODO: refactor this to use _fetchNameGet
def = this._rpc({
model: coModel,
method: 'name_get',
args: [data.id],
- context: record.context,
+ context: this._getContext(record, { fieldName, viewType }),
})
.then(function (result) {
rel_data.display_name = result[0][1];
diff --git a/addons/web/static/src/scss/fields.scss b/addons/web/static/src/scss/fields.scss
index d560cb3e7f8..37bc8cc6418 100644
--- a/addons/web/static/src/scss/fields.scss
+++ b/addons/web/static/src/scss/fields.scss
@@ -12,8 +12,8 @@
}
// Empty
-.o_field_empty {
- display: none!important;
+.o_field_empty:empty {
+ min-height: $font-size-base * $line-height-base;
}
// Numbers
@@ -87,6 +87,21 @@
}
}
+ // Many2One
+ &.o_field_many2one {
+ flex-direction: column;
+
+ .o_field_many2one_selection {
+ display: flex;
+ width: 100%;
+ }
+
+ .o_external_button {
+ padding-top: 0;
+ padding-bottom: 0;
+ }
+ }
+
// Many2OneAvatar
&.o_field_many2one_avatar {
> img.o_m2o_avatar {
diff --git a/addons/web/static/src/scss/fields_extra.scss b/addons/web/static/src/scss/fields_extra.scss
index 47fca992eb5..1dd838d90df 100644
--- a/addons/web/static/src/scss/fields_extra.scss
+++ b/addons/web/static/src/scss/fields_extra.scss
@@ -22,6 +22,7 @@
// Many2one
&.o_field_many2one .o_external_button {
+ flex: 0 0 auto;
padding: 0;
margin-left: 2px;
font-size: 19px;
diff --git a/addons/web/static/src/scss/form_view.scss b/addons/web/static/src/scss/form_view.scss
index 5d101f3c8c5..ec356efb629 100644
--- a/addons/web/static/src/scss/form_view.scss
+++ b/addons/web/static/src/scss/form_view.scss
@@ -486,6 +486,12 @@
.o_priority > .o_priority_star {
font-size: inherit;
}
+ > h1 {
+ min-height: 55px;
+ }
+ > h2 {
+ min-height: 43px;
+ }
}
// Avatar
@@ -507,6 +513,10 @@
width: 100%;
margin: 10px 0;
+ .o_group {
+ margin: 0;
+ }
+
// o_group contains nested groups
@for $i from 1 through $o-form-group-cols {
.o_group_col_#{$i} {
@@ -554,7 +564,7 @@
// it does not really matter
// Makes extra buttons (e.g. m2o external button) overflow on the
// right padding of the parent element
- > .o_input_dropdown {
+ .o_input_dropdown {
flex: 1 0 auto;
}
}
@@ -605,6 +615,14 @@
margin-bottom: 0px;
}
}
+ td.o_td_label .o_form_label {
+ min-height: 33px;
+ }
+ td:not(.o_field_cell) .o_form_uri > span:first-child {
+ display: inline-block;
+ padding: 1px 0;
+ margin-bottom: 1px;
+ }
// Translate icon
span.o_field_translate {
diff --git a/addons/web/static/src/scss/list_view.scss b/addons/web/static/src/scss/list_view.scss
index bbdff95b817..55e255ed269 100644
--- a/addons/web/static/src/scss/list_view.scss
+++ b/addons/web/static/src/scss/list_view.scss
@@ -275,7 +275,7 @@
}
> .o_field_widget {
width: 100%;
- > .o_external_button {
+ .o_external_button {
padding: 0;
border: none;
background-color: inherit;
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index 764d15dc5c8..6e6e69de0ef 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -1235,7 +1235,7 @@