Merge PR #3124 into 17.0

Signed-off-by JasminSForgeFlow
pull/3126/head
OCA-git-bot 2025-03-18 07:41:29 +00:00
commit 5ce04734fe
3 changed files with 34 additions and 1 deletions

View File

@ -3,6 +3,7 @@
import {Component} from "@odoo/owl"; import {Component} from "@odoo/owl";
import {X2Many2DMatrixRenderer} from "@web_widget_x2many_2d_matrix/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm"; import {X2Many2DMatrixRenderer} from "@web_widget_x2many_2d_matrix/components/x2many_2d_matrix_renderer/x2many_2d_matrix_renderer.esm";
import {archParseBoolean} from "@web/views/utils"; import {archParseBoolean} from "@web/views/utils";
import {evaluateBooleanExpr} from "@web/core/py_js/py";
import {registry} from "@web/core/registry"; import {registry} from "@web/core/registry";
import {standardFieldProps} from "@web/views/fields/standard_field_props"; import {standardFieldProps} from "@web/views/fields/standard_field_props";
@ -29,12 +30,24 @@ X2Many2DMatrixField.props = {
isYClickable: {type: Boolean, optional: true}, isYClickable: {type: Boolean, optional: true},
showRowTotals: {type: Boolean, optional: true}, showRowTotals: {type: Boolean, optional: true},
showColumnTotals: {type: Boolean, optional: true}, showColumnTotals: {type: Boolean, optional: true},
canOpen: {type: Boolean, optional: true},
canCreate: {type: Boolean, optional: true},
canWrite: {type: Boolean, optional: true},
canQuickCreate: {type: Boolean, optional: true},
canCreateEdit: {type: Boolean, optional: true},
}; };
X2Many2DMatrixField.components = {X2Many2DMatrixRenderer}; X2Many2DMatrixField.components = {X2Many2DMatrixRenderer};
export const x2Many2DMatrixField = { export const x2Many2DMatrixField = {
component: X2Many2DMatrixField, component: X2Many2DMatrixField,
extractProps({attrs}) { extractProps({attrs, options}) {
const hasCreatePermission = attrs.can_create
? evaluateBooleanExpr(attrs.can_create)
: true;
const hasWritePermission = attrs.can_write
? evaluateBooleanExpr(attrs.can_write)
: true;
const canCreate = options.no_create ? false : hasCreatePermission;
return { return {
matrixFields: { matrixFields: {
value: attrs.field_value, value: attrs.field_value,
@ -51,6 +64,11 @@ export const x2Many2DMatrixField = {
"show_column_totals" in attrs "show_column_totals" in attrs
? archParseBoolean(attrs.show_column_totals) ? archParseBoolean(attrs.show_column_totals)
: true, : true,
canOpen: !options.no_open,
canCreate,
canWrite: hasWritePermission,
canQuickCreate: canCreate && !options.no_quick_create,
canCreateEdit: canCreate && !options.no_create_edit,
}; };
}, },
}; };

View File

@ -9,6 +9,11 @@
showColumnTotals="props.showColumnTotals" showColumnTotals="props.showColumnTotals"
readonly="props.readonly" readonly="props.readonly"
domain="props.domain" domain="props.domain"
canOpen="props.canOpen"
canCreate="props.canCreate"
canWrite="props.canWrite"
canQuickCreate="props.canQuickCreate"
canCreateEdit="props.canCreateEdit"
/> />
</div> </div>
</t> </t>

View File

@ -163,6 +163,11 @@ export class X2Many2DMatrixRenderer extends Component {
readonly: this.props.readonly, readonly: this.props.readonly,
record: record, record: record,
name: this.matrixFields.value, name: this.matrixFields.value,
canCreate: this.props.canCreate,
canOpen: this.props.canOpen,
canWrite: this.props.canWrite,
canQuickCreate: this.props.canQuickCreate,
canCreateEdit: this.props.canCreateEdit,
}; };
const domain = record.fields[this.matrixFields.value].domain; const domain = record.fields[this.matrixFields.value].domain;
if (domain) { if (domain) {
@ -185,4 +190,9 @@ X2Many2DMatrixRenderer.props = {
domain: {type: [Array, Function], optional: true}, domain: {type: [Array, Function], optional: true},
showRowTotals: {type: Boolean, optional: true}, showRowTotals: {type: Boolean, optional: true},
showColumnTotals: {type: Boolean, optional: true}, showColumnTotals: {type: Boolean, optional: true},
canOpen: {type: Boolean, optional: true},
canCreate: {type: Boolean, optional: true},
canWrite: {type: Boolean, optional: true},
canQuickCreate: {type: Boolean, optional: true},
canCreateEdit: {type: Boolean, optional: true},
}; };