From 422ab51460682ba409aebb46d5eddf5dd2e442e3 Mon Sep 17 00:00:00 2001 From: gawa-odoo Date: Thu, 10 Nov 2022 14:17:40 +0000 Subject: [PATCH] [FIX] analytic: traceback hr_expense invoicing analytic distribution Steps to reproduce the issue: - Have the modules `hr_expense` and `account` installed (not `account_accountant`) - Create a new expense - Change the category - Click on analytic distribution field => Traceback The issue comes from the fact that the account field is present but empty (we don't have accounting). For the old and new account field, we have 2 undefined values. We then do a shallowEqual of these, where it will compare length attributes, so traceback. To solve it, we just give it a value false to the field instead of being undefined for the comparison. closes odoo/odoo#105593 X-original-commit: face5b8f9134fc052ea09742667a610b508a4886 Signed-off-by: John Laterre (jol) --- .../analytic_distribution/analytic_distribution.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js b/addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js index 5fc96b27fd6..b8d146dfbf5 100644 --- a/addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js +++ b/addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js @@ -70,8 +70,8 @@ export class AnalyticDistribution extends Component { fieldString: this.env._t("Analytic Distribution Template"), }); this.allPlans = []; - this.lastAccount = this.props.account_field ? this.props.record.data[this.props.account_field] : false; - this.lastProduct = this.props.product_field ? this.props.record.data[this.props.product_field] : false; + this.lastAccount = this.props.account_field && this.props.record.data[this.props.account_field] || false; + this.lastProduct = this.props.product_field && this.props.record.data[this.props.product_field] || false; } // Lifecycle @@ -88,8 +88,8 @@ export class AnalyticDistribution extends Component { // or a model applies that contains unavailable plans // This should only execute when these fields have changed, therefore we use the `_field` props. const valueChanged = JSON.stringify(this.props.value) !== JSON.stringify(nextProps.value); - const currentAccount = this.props.account_field ? this.props.record.data[this.props.account_field] : false; - const currentProduct = this.props.product_field ? this.props.record.data[this.props.product_field] : false; + const currentAccount = this.props.account_field && this.props.record.data[this.props.account_field] || false; + const currentProduct = this.props.product_field && this.props.record.data[this.props.product_field] || false; const accountChanged = !shallowEqual(this.lastAccount, currentAccount); const productChanged = !shallowEqual(this.lastProduct, currentProduct); if (valueChanged || accountChanged || productChanged) {