[FIX] website: fix ctx argument

In the call to Chart.js we pass a ctx which should be a DOM element,
however we pass `null` as the ctx.

It seems that what happens is that we look for the DOM element inside
the `document` (via getElementById) but this element is not yet inserted
into the document, hence this returns `null`.

Since we already have a reference to the canvas element which should be
used as ctx, we can probably just reuse this reference

closes odoo/odoo#36072

Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
This commit is contained in:
RomainLibert
2019-08-28 11:13:18 +00:00
parent 85b5c9bbb4
commit 6aaef4a3d9
4 changed files with 26 additions and 1 deletions
@@ -185,7 +185,7 @@ var Dashboard = AbstractAction.extend({
};
});
var ctx = document.getElementById(chart_id);
var ctx = this.$canvas[0];
this.chart = new Chart(ctx, {
type: 'line',
data: {
@@ -0,0 +1,21 @@
odoo.define("website.tour.backend_dashboard", function (require) {
"use strict";
var tour = require("web_tour.tour");
tour.register("backend_dashboard", {
test: true,
url: "/web",
}, [tour.STEPS.SHOW_APPS_MENU_ITEM,
{
trigger: 'a[data-menu-xmlid="website.menu_website_configuration"]',
run: 'click',
}, {
trigger: '.dropdown-toggle[data-menu-xmlid="website.menu_dashboard"]',
run: 'click',
}, {
trigger: '.dropdown-item[data-menu-xmlid="website.menu_website_google_analytics"]',
content: 'Check if traceback',
run: 'click',
}]);
});
+3
View File
@@ -109,3 +109,6 @@ class TestUi(odoo.tests.HttpCase):
])]
})
self.start_tour("/", 'restricted_editor', login='restricted')
def test_04_backend_dashboard(self):
self.start_tour("/", 'backend_dashboard', login='admin')
@@ -23,6 +23,7 @@
<script type="text/javascript" src="/website/static/tests/tours/rte.js"/>
<script type="text/javascript" src="/website/static/tests/tours/html_editor.js"/>
<script type="text/javascript" src="/website/static/tests/tours/restricted_editor.js"/>
<script type="text/javascript" src="/website/static/tests/tours/dashboard_tour.js"/>
</xpath>
</template>