Skip to content

Commit

Permalink
Merge PR #2463 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by tarteo
  • Loading branch information
OCA-git-bot committed Jun 7, 2023
2 parents 749d0f5 + 476fe9a commit 88c5d19
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -127,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,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
t-props="getValueFieldProps(column.value, row.value)"
/>
</td>
<td t-if="props.showRowTotals" class="row-total">
<td
t-if="props.showRowTotals and _canAggregate()"
class="row-total"
>
<t
t-component="ValueFieldComponent"
readonly="true"
Expand All @@ -40,7 +43,7 @@
</tr>
</tbody>
<tfoot>
<tr t-if="props.showColumnTotals">
<tr t-if="props.showColumnTotals and _canAggregate()">
<th />
<th t-foreach="columns" t-as="column" t-key="column.value">
<t
Expand Down

0 comments on commit 88c5d19

Please sign in to comment.