[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) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2019-05-21 10:51:44 +00:00
parent c7274a48e3
commit 8c4a88a3f9
@@ -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