From 8988ebf48163c75540b33b20eb26805f4bedb4e3 Mon Sep 17 00:00:00 2001 From: Sergio Teruel Albert Date: Thu, 26 Jan 2017 08:57:09 +0100 Subject: [PATCH] [9.0][IMP] web_responsive: Load default kanban view for small screen and One2many related fields. (#536) * [9.0][IMP] web_responsive: Load default kanban view for small screen and One2many related fields. * [9.0][IMP] web_responsive: Remove unnecessary One2Many rewrite. * Spell checking --- web_responsive/README.rst | 5 +++++ web_responsive/static/src/js/web_responsive.js | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/web_responsive/README.rst b/web_responsive/README.rst index 7981266f..916abf82 100755 --- a/web_responsive/README.rst +++ b/web_responsive/README.rst @@ -12,6 +12,8 @@ Features: * New navigation with an App drawer * Keyboard shortcuts for easier navigation + * Display kanban views for small screens format if an action or field One2x + has a kanban view Installation @@ -52,6 +54,8 @@ this module. * Adding ``oe_main_menu_navbar`` ID to the top navigation bar triggers some great styles, but also `JavaScript that causes issues on mobile `_ +* The kanban view not is shown if an action window has no kanban mode view + Bug Tracker =========== @@ -75,6 +79,7 @@ Contributors * Dave Lasley * Jairo Llopis +* Sergio Teruel Maintainer ---------- diff --git a/web_responsive/static/src/js/web_responsive.js b/web_responsive/static/src/js/web_responsive.js index 0459f7bc..84817b36 100755 --- a/web_responsive/static/src/js/web_responsive.js +++ b/web_responsive/static/src/js/web_responsive.js @@ -8,6 +8,9 @@ odoo.define('web_responsive', function(require) { var Class = require('web.Class'); var SearchView = require('web.SearchView'); var core = require('web.core'); + var config = require('web.config'); + var FieldOne2Many = core.form_widget_registry.get('one2many'); + var ViewManager = require('web.ViewManager'); Menu.include({ @@ -292,10 +295,24 @@ odoo.define('web_responsive', function(require) { new AppDrawer(); }); + // if we are in small screen change default view to kanban if exists + ViewManager.include({ + get_default_view: function() { + var default_view = this._super() + if (config.device.size_class <= config.device.SIZES.XS && + default_view != 'kanban' && + this.views['kanban']){ + default_view = 'kanban'; + }; + return default_view; + }, + }); + return { 'AppDrawer': AppDrawer, 'SearchView': SearchView, 'Menu': Menu, + 'ViewManager': ViewManager, }; });