Browse Source

Merge pull request #1260 from tarteo/12-matrix-use-widget-totals

[12.0][FIX] web_widget_x2many_2d_matrix: Use widget for formatting aggregates
pull/1270/head
Pedro M. Baeza 6 years ago
committed by GitHub
parent
commit
4d5a31aaa3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      web_widget_x2many_2d_matrix/__manifest__.py
  2. 26
      web_widget_x2many_2d_matrix/static/src/js/2d_matrix_renderer.js
  3. 6
      web_widget_x2many_2d_matrix/static/src/scss/web_widget_x2many_2d_matrix.scss

2
web_widget_x2many_2d_matrix/__manifest__.py

@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': '2D matrix for x2many fields',
'version': '12.0.1.0.3',
'version': '12.0.1.0.4',
'author': (
'Therp BV, '
'Tecnativa, '

26
web_widget_x2many_2d_matrix/static/src/js/2d_matrix_renderer.js

@ -306,21 +306,9 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
if (node.tag === 'widget') {
return $td.append(this._renderWidget(record, node));
}
if (node.attrs.widget || (options && (options.renderWidgets || options.mode === 'edit'))) {
var $el = this._renderFieldWidget(node, record, _.pick(options, 'mode'));
this._handleAttributes($el, node);
return $td.append($el);
}
var name = node.attrs.name;
var field = this.state.fields[name];
var value = record.data[name];
var formattedValue = field_utils.format[field.type](value, field, {
data: record.data,
escape: true,
isPassword: 'password' in node.attrs,
});
this._handleAttributes($td, node);
return $td.html(formattedValue);
var $el = this._renderFieldWidget(node, record, _.pick(options, 'mode'));
this._handleAttributes($el, node);
return $td.append($el);
},
/**
@ -513,10 +501,10 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
var field = this.state.fields[axis.attrs.name];
var value = axis.aggregate.value;
var help = axis.aggregate.help;
var formatFunc = field_utils.format[axis.attrs.widget];
if (!formatFunc) {
formatFunc = field_utils.format[field.type];
}
var fieldInfo = this.state.fieldsInfo.list[axis.attrs.name];
var formatFunc = field_utils.format[
fieldInfo.widget ? fieldInfo.widget : field.type
];
var formattedValue = formatFunc(value, field, { escape: true });
$cell.addClass('o_list_number').attr('title', help).html(formattedValue);
},

6
web_widget_x2many_2d_matrix/static/src/scss/web_widget_x2many_2d_matrix.scss

@ -2,9 +2,13 @@
font-weight: bold;
}
.o_x2many_2d_matrix {
.o_form_view .o_x2many_2d_matrix.o_list_view {
thead > tr > th {
// Respect newline characters
white-space: pre-line;
}
> tfoot > tr > td {
padding: 0.75rem;
}
}
Loading…
Cancel
Save