From 8450574da7026ffeed3785c06e685b7173548029 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Tue, 1 Oct 2024 14:50:06 +0200 Subject: [PATCH] [IMP] account_reconcile_oca: Improve JS for reusing code --- .../reconcile_move_line_controller.esm.js | 1 + .../reconcile_move_line_renderer.esm.js | 7 ++++--- .../src/js/widgets/reconcile_move_line_widget.esm.js | 4 ++++ account_reconcile_oca/static/src/xml/reconcile.xml | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/account_reconcile_oca/static/src/js/reconcile_move_line/reconcile_move_line_controller.esm.js b/account_reconcile_oca/static/src/js/reconcile_move_line/reconcile_move_line_controller.esm.js index af500eb958..bbe9435814 100644 --- a/account_reconcile_oca/static/src/js/reconcile_move_line/reconcile_move_line_controller.esm.js +++ b/account_reconcile_oca/static/src/js/reconcile_move_line/reconcile_move_line_controller.esm.js @@ -15,4 +15,5 @@ ReconcileMoveLineController.props = { ...ListController.props, parentRecord: {type: Object, optional: true}, parentField: {type: String, optional: true}, + counterpartField: {type: String, optional: true}, }; diff --git a/account_reconcile_oca/static/src/js/reconcile_move_line/reconcile_move_line_renderer.esm.js b/account_reconcile_oca/static/src/js/reconcile_move_line/reconcile_move_line_renderer.esm.js index 10958e496e..d825bcee16 100644 --- a/account_reconcile_oca/static/src/js/reconcile_move_line/reconcile_move_line_renderer.esm.js +++ b/account_reconcile_oca/static/src/js/reconcile_move_line/reconcile_move_line_renderer.esm.js @@ -6,9 +6,9 @@ export class ReconcileMoveLineRenderer extends ListRenderer { getRowClass(record) { var classes = super.getRowClass(record); if ( - this.props.parentRecord.data.reconcile_data_info.counterparts.includes( - record.resId - ) + this.props.parentRecord.data.reconcile_data_info[ + this.props.counterpartField + ].includes(record.resId) ) { classes += " o_field_account_reconcile_oca_move_line_selected"; } @@ -19,4 +19,5 @@ ReconcileMoveLineRenderer.props = [ ...ListRenderer.props, "parentRecord", "parentField", + "counterpartField", ]; diff --git a/account_reconcile_oca/static/src/js/widgets/reconcile_move_line_widget.esm.js b/account_reconcile_oca/static/src/js/widgets/reconcile_move_line_widget.esm.js index a539bca43d..080a80b6c9 100644 --- a/account_reconcile_oca/static/src/js/widgets/reconcile_move_line_widget.esm.js +++ b/account_reconcile_oca/static/src/js/widgets/reconcile_move_line_widget.esm.js @@ -36,6 +36,7 @@ export class AccountReconcileMatchWidget extends Component { searchViewId: false, parentRecord: this.props.record, parentField: this.props.name, + counterpartField: this.props.counterpartField, }; } } @@ -45,6 +46,9 @@ AccountReconcileMatchWidget.components = { ...AccountReconcileMatchWidget.components, View, }; +AccountReconcileMatchWidget.extractProps = ({attrs}) => ({ + counterpartField: attrs.options.counterpart_field || "counterparts", +}); registry .category("fields") diff --git a/account_reconcile_oca/static/src/xml/reconcile.xml b/account_reconcile_oca/static/src/xml/reconcile.xml index ac26c7927f..2c6ee76957 100644 --- a/account_reconcile_oca/static/src/xml/reconcile.xml +++ b/account_reconcile_oca/static/src/xml/reconcile.xml @@ -190,6 +190,7 @@ props.parentRecord props.parentField + props.counterpartField