summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammed Shekha <msh@odoo.com>2020-08-18 07:22:47 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2020-09-01 11:43:50 +0000
commit2eaf49bb05f9278ee9709d0dec130b4c651bfcba (patch)
treef73b6f61a12ff5e43247bb804d2abf467f924418
parent00693dc0b36bebb6b04ef8e81291486334dd4dba (diff)
[FIX] web: do not display nocontent help if empty
Have an action which help field has the value: ``` <p></p> ``` Display an empty list or kanban Before this commit, the nocontent helper was displayed even though there was nothing to display. After this commit, an empty html tag is the same as an empty string, so the helper is not displayed. task-2320318 closes odoo/odoo#56875 X-original-commit: 3d6bdc5b01a4a94de9baa9bae230e6b34f38dbc9 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
-rw-r--r--addons/web/static/src/js/views/abstract_view.js7
-rw-r--r--addons/web/static/tests/views/list_tests.js24
2 files changed, 30 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/abstract_view.js b/addons/web/static/src/js/views/abstract_view.js
index ae572739c4e..9440bf67b00 100644
--- a/addons/web/static/src/js/views/abstract_view.js
+++ b/addons/web/static/src/js/views/abstract_view.js
@@ -126,10 +126,15 @@ var AbstractView = Factory.extend({
// button when the graph view is embedded.
var isEmbedded = params.isEmbedded || false;
+ // The noContentHelper's message can be empty, i.e. either a real empty string
+ // or an empty html tag. In both cases, we consider the helper empty.
+ var help = params.noContentHelp || "";
+ var htmlHelp = document.createElement("div");
+ htmlHelp.innerHTML = help;
this.rendererParams = {
arch: this.arch,
isEmbedded: isEmbedded,
- noContentHelp: params.noContentHelp,
+ noContentHelp: htmlHelp.innerText.trim() ? help : "",
};
this.controllerParams = {
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js
index 9a7bb44fb26..a0cd91774ce 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -4483,6 +4483,30 @@ QUnit.module('Views', {
assert.doesNotHaveClass(list, 'o_view_sample_data');
assert.containsNone(list, '.o_list_table');
assert.containsOnce(list, '.o_nocontent_help');
+ list.destroy();
+ });
+
+ QUnit.test('Do not display nocontent when it is an empty html tag', async function (assert) {
+ assert.expect(2);
+
+ this.data.foo.records = [];
+
+ var list = await createView({
+ View: ListView,
+ model: 'foo',
+ data: this.data,
+ arch: '<tree><field name="foo"/></tree>',
+ viewOptions: {
+ action: {
+ help: '<p class="hello"></p>'
+ }
+ },
+ });
+
+ assert.containsNone(list, '.o_view_nocontent',
+ "should not display the no content helper");
+
+ assert.containsOnce(list, 'table', "should have a table in the dom");
list.destroy();
});