From 8c4a88a3f92c1e7a6cd3cbbc5af5cfae3334ce60 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 21 May 2019 10:51:44 +0000 Subject: [PATCH] [FIX] account: auto-reconcile hidden lines - Create 11 invoices with the same partner but different totals like: 1.0, 2.0, 3.0 ... 11.0 - Confirm them - Create a bank statement with 11 lines having each of them the previous invoice amount (1.0, 2.0, 3.0 .... 11.0) and the partner - Click on the 'Reconcile' button - In the reconcile form, do NOT push the 'Load More' button, but push the 'Automatic Reconciliation' button All lines are reconciled, but a JS traceback is raised. This is because we try to destroy a widgets which were not rendered. opw-1985580 closes odoo/odoo#33524 Signed-off-by: Nicolas Martinelli (nim) --- .../src/js/reconciliation/reconciliation_action.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/account/static/src/js/reconciliation/reconciliation_action.js b/addons/account/static/src/js/reconciliation/reconciliation_action.js index b1b6451967f..a90d831ded1 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_action.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_action.js @@ -302,9 +302,12 @@ var StatementAction = Widget.extend(ControlPanelMixin, { 'context': self.model.getContext(), }); _.each(result.handles, function (handle) { - self._getWidget(handle).destroy(); - var index = _.findIndex(self.widgets, function (widget) {return widget.handle===handle;}); - self.widgets.splice(index, 1); + var widget = self._getWidget(handle); + if (widget) { + widget.destroy(); + var index = _.findIndex(self.widgets, function (widget) {return widget.handle===handle;}); + self.widgets.splice(index, 1); + } }); // Get number of widget and if less than constant and if there are more to laod, load until constant if (self.widgets.length < self.model.defaultDisplayQty