[FIX] web: graph_renderer: check graph data before rendering

Before this commit, we had two different errors when data was
unavailable:
The first one is generated by Odoo: "No data to display, try to[...]"
The second one is generated by nvd3: "No Data Available".

We always want the same message.
So now, we always make some checks before rendering
the graph by calling _render.
This commit is contained in:
Adrien Dieudonne
2018-08-20 16:10:25 +02:00
parent 21430a4d02
commit 634de21b76
2 changed files with 20 additions and 1 deletions
@@ -56,7 +56,7 @@ return AbstractRenderer.extend({
on_attach_callback: function () {
this._super.apply(this, arguments);
this.isInDOM = true;
this._renderGraph();
this._render();
},
/**
* @override
@@ -190,6 +190,25 @@ QUnit.module('Views', {
});
QUnit.test('no content helper', function (assert) {
assert.expect(2);
this.data.foo.records = [];
var graph = createView({
View: GraphView,
model: "foo",
data: this.data,
arch: '<graph string="Gloups">' +
'<field name="product_id"/>' +
'</graph>',
});
assert.strictEqual(graph.$('div.o_graph_svg_container svg.nvd3-svg').length, 0,
"should not contain a div with a svg element");
assert.strictEqual(graph.$('div.o_view_nocontent').length, 1,
"should display the no content helper");
graph.destroy();
});
QUnit.test('no content helper after update', function (assert) {
var done = assert.async();
assert.expect(4);