[FIX] web: JournalDashboardGraph widget crash Mk.II

Hardening of commit:995610c065bf0242cb5023cfad2940234395739e

The JournalDashboardGraph requires nv, which is lazyloaded.
However it requires nvd3.js which is loaded after nv.d3.js.
A function called in destroy is defined by nv.d3.js,
which can make the crashhappen with the right (wrong) timing.

opw 1873749
This commit is contained in:
MOENS Alexandre
2018-09-14 16:13:35 +02:00
committed by len-odoo
parent 70ed882088
commit b83db27135
2 changed files with 40 additions and 1 deletions
@@ -2055,7 +2055,7 @@ var JournalDashboardGraph = AbstractField.extend({
return this._super.apply(this, arguments);
},
destroy: function () {
if ('nv' in window) {
if ('nv' in window && nv.utils && nv.utils.offWindowResize) {
// if the widget is destroyed before the lazy loaded libs (nv) are
// actually loaded (i.e. after the widget has actually started),
// nv is undefined, but the handler isn't bound yet anyway