summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_view.js
diff options
context:
space:
mode:
authorDamien Bouvy <dbo@odoo.com>2019-08-29 13:42:38 +0000
committerPierre Paridans <app@odoo.com>2019-09-25 12:50:59 +0000
commit5d82725f62bba3f06ba0bb881614f1ae91afa5c5 (patch)
treeab3aea000ba87895a7204126676bf195d109097d /addons/web/static/src/js/views/basic/basic_view.js
parent07631a51858830cf9dd7f06e9c3ac2576efa559b (diff)
[FIX] web: stop defaulting on empty kanbans when you should not
1/ Write a form view with a o2m field that has its own inline tree view (no other view exist in db for the target model) 2/ Open that view in a mobile environment 3/ Instead of having a list view, you get a kanban view. No luck for you, since the default kanban generated by `models.py` is an empty one, your records are *invisible* \o/ From what I can tell, the previous condition made no sense: ``` if (there is a list view and a kanban view) <-- this seems absurd then (use the list mode) elif (there is no list view but a kanban view) then (use the kanban mode) else (use both modes) ``` The first condition seems absurd: it *actively* ignores a kanban view if there is one. Even better, the list view whose existence it checks is never there: it checks for a `tree` when it should be checking for a `list`. In short, the first condition was *never* met, and you ended up either with exclusive kanban mode or with both modes - even if you had no existing kanban view for the target model... This commit moves the normalization of `tree` into `list` before attempting to process the x2many field's subviews. It clarify the usage of `tree` vs `list` (cf. only use `list`) which prevents weird edge cases like described above. closes odoo/odoo#36237 Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com> Co-authored-by: Adrien Dieudonné <adr@odoo.com> Co-authored-by: Pierre Paridans <app@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_view.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_view.js27
1 files changed, 13 insertions, 14 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_view.js b/addons/web/static/src/js/views/basic/basic_view.js
index 38d2f220c2f..5cb293e866b 100644
--- a/addons/web/static/src/js/views/basic/basic_view.js
+++ b/addons/web/static/src/js/views/basic/basic_view.js
@@ -282,29 +282,28 @@ var BasicView = AbstractView.extend({
});
}
+ attrs.views = attrs.views || {};
+
+ // Keep compatibility with 'tree' syntax
+ attrs.mode = attrs.mode === 'tree' ? 'list' : attrs.mode;
+ if (!attrs.views.list && attrs.views.tree) {
+ attrs.views.list = attrs.views.tree;
+ }
+
if (field.type === 'one2many' || field.type === 'many2many') {
if (attrs.Widget.prototype.useSubview) {
- if (!attrs.views) {
- attrs.views = {};
- }
var mode = attrs.mode;
if (!mode) {
- if (attrs.views.tree && attrs.views.kanban) {
- mode = 'tree';
- } else if (!attrs.views.tree && attrs.views.kanban) {
+ if (attrs.views.list && !attrs.views.kanban) {
+ mode = 'list';
+ } else if (!attrs.views.list && attrs.views.kanban) {
mode = 'kanban';
} else {
- mode = 'tree,kanban';
+ mode = 'list,kanban';
}
}
if (mode.indexOf(',') !== -1) {
- mode = config.device.isMobile ? 'kanban' : 'tree';
- }
- if (mode === 'tree') {
- mode = 'list';
- if (!attrs.views.list && attrs.views.tree) {
- attrs.views.list = attrs.views.tree;
- }
+ mode = config.device.isMobile ? 'kanban' : 'list';
}
attrs.mode = mode;
if (mode in attrs.views) {