From ef513673e29e4adc701fd1e0781ea309d04da2a2 Mon Sep 17 00:00:00 2001 From: tarteo Date: Wed, 7 Jun 2023 15:49:51 +0200 Subject: [PATCH 1/2] [IMP] web_widget_x2many_2d_matrix: Check is aggregatable --- .../x2many_2d_matrix_renderer.esm.js | 6 ++++++ .../x2many_2d_matrix_renderer.xml | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js b/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js index 30756a926ad3..b0e555885e8c 100644 --- a/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js +++ b/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js @@ -116,6 +116,12 @@ export class X2Many2DMatrixRenderer extends Component { .reduce((aggr, y) => aggr + y); } + _canAggregate() { + return ["integer", "float", "monetary"].includes( + this.list.fields[this.matrixFields.value].type + ); + } + update(x, y, value) { this.matrix[y][x].value = value; const xFieldValue = this.columns[x].value; diff --git a/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.xml b/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.xml index 1c2fe9c078b7..be7e979bf16f 100644 --- a/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.xml +++ b/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.xml @@ -30,7 +30,10 @@ t-props="getValueFieldProps(column.value, row.value)" /> - + - + Date: Wed, 7 Jun 2023 16:01:57 +0200 Subject: [PATCH 2/2] [IMP] web_widget_x2many_2d_matrix: Many2one value field --- .../x2many_2d_matrix_renderer.esm.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js b/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js index b0e555885e8c..3ae67e1b7621 100644 --- a/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js +++ b/web_widget_x2many_2d_matrix/static/src/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm.js @@ -133,10 +133,22 @@ export class X2Many2DMatrixRenderer extends Component { getValueFieldProps(column, row) { const x = this.columns.findIndex((c) => c.value === column); const y = this.rows.findIndex((r) => r.value === row); + const props = this.list.activeFields[this.matrixFields.value].props; + const propsFromAttrs = + this.list.activeFields[this.matrixFields.value].propsFromAttrs; + const record = this.matrix[y][x].records[0]; + let value = this.matrix[y][x].value; + if (!this._canAggregate()) { + value = record.data[this.matrixFields.value]; + } + return { - value: this.matrix[y][x].value, + ...props, + ...propsFromAttrs, + value: value, update: (value) => this.update(x, y, value), readonly: this.props.readonly, + record: record, }; } }