From 205abee60125f829b0e0ffa3e69f84c2ac2c15c8 Mon Sep 17 00:00:00 2001 From: "Serpent Consulting Services Pvt. Ltd" Date: Fri, 10 Jun 2016 19:52:38 +0530 Subject: [PATCH] Migrated web_group_expand module to v9 --- web_group_expand/README.rst | 10 ++-- web_group_expand/__init__.py | 3 + web_group_expand/__openerp__.py | 9 ++- .../static/src/css/expand_buttons.css | 1 - .../static/src/js/web_group_expand.js | 57 +++++++++++-------- .../static/src/xml/expand_buttons.xml | 10 ++-- 6 files changed, 53 insertions(+), 37 deletions(-) diff --git a/web_group_expand/README.rst b/web_group_expand/README.rst index a88dcba5..279922a0 100644 --- a/web_group_expand/README.rst +++ b/web_group_expand/README.rst @@ -5,7 +5,7 @@ Group Expand Buttons ==================== -A group by list can be expanded and collapased with buttons +A group by list can be expanded and collapsed with buttons. You'll see two buttons appear on top right corner of the list when you perform a group by with which you can expand and collapse grouped records by level. @@ -16,7 +16,7 @@ Usage .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/162/8.0 + :target: https://runbot.odoo-community.org/runbot/162/9.0 For further information, please visit: @@ -28,8 +28,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback. Credits @@ -41,6 +40,7 @@ Contributors * Mantavya Gajjar * Oihane Crucelaegui * Pedro M. Baeza +* Meet Dholakia * Jay Vora (SerpentCS) for their alternative implementation Maintainer @@ -56,5 +56,5 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/web_group_expand/__init__.py b/web_group_expand/__init__.py index e69de29b..b4bbbc6b 100644 --- a/web_group_expand/__init__.py +++ b/web_group_expand/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (http://www.serpentcs.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/web_group_expand/__openerp__.py b/web_group_expand/__openerp__.py index a0608500..82790c2f 100644 --- a/web_group_expand/__openerp__.py +++ b/web_group_expand/__openerp__.py @@ -1,7 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Serpent Consulting Services Pvt. Ltd. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + { "name": "Group Expand Buttons", "category": "Web", - "version": "8.0.1.0.0", + "version": "9.0.1.0.0", + "license": "AGPL-3", "author": "OpenERP SA, " "AvanzOSC, " "Serv. Tecnol. Avanzados - Pedro M. Baeza, " @@ -15,5 +20,5 @@ "data": [ "views/templates.xml", ], - 'installable': False, + 'installable': True, } diff --git a/web_group_expand/static/src/css/expand_buttons.css b/web_group_expand/static/src/css/expand_buttons.css index e02cfec5..039b1979 100644 --- a/web_group_expand/static/src/css/expand_buttons.css +++ b/web_group_expand/static/src/css/expand_buttons.css @@ -3,6 +3,5 @@ line-height: 25px; } .openerp .fa-expand, .openerp .fa-compress { - font-size:15px; font-weight:bold; } diff --git a/web_group_expand/static/src/js/web_group_expand.js b/web_group_expand/static/src/js/web_group_expand.js index 37bee516..ffae946b 100644 --- a/web_group_expand/static/src/js/web_group_expand.js +++ b/web_group_expand/static/src/js/web_group_expand.js @@ -1,44 +1,53 @@ -"use strict"; -openerp.web_group_expand = function(openerp) { - var QWeb = openerp.web.qweb; - openerp.web.ViewManager.include({ +odoo.define('web_group_expand.web_group_expand',function(require){ + "use strict"; + var core = require('web.core'); + var ViewManager = require('web.ViewManager'); + var _t = core._t; + var QWeb = core.qweb; + + ViewManager.include({ switch_mode: function(view_type, no_store, view_options) { - if (view_type != 'list' && view_type != 'tree' ) { - this.$el.find("ul#oe_group_by").remove(); + if (view_type !== 'list' && view_type !== 'tree' ) { + $("div#oe_group_by").remove(); } - if(view_type == 'tree'){ + if(view_type === 'tree'){ + $("div#oe_group_by").remove(); this.load_expand_buttons(); - this.$ExpandButtons.find("a#oe_group_by_reset").click(function(){ - $('.oe_open .treeview-tr.oe-treeview-first').filter(function(){return ($(this).parents('tr').attr('data-level') == 1)}).click() + this.$ExpandButtons.find("li#oe_group_by_reset").click(function(){ + $('.oe_open .treeview-tr.oe-treeview-first').filter(function(){ + return parseInt($(this).parents('tr').attr('data-level'),10) === 1; + }).click(); }); - this.$ExpandButtons.find("a#oe_group_by_expand").click(function(){ - $('.treeview-tr.oe-treeview-first').filter(function(){return (!$(this).parents().is('.oe_open')) & ($(this).parents().css( "display" ) != 'none')}).click(); + this.$ExpandButtons.find("li#oe_group_by_expand").click(function(){ + $('.treeview-tr.oe-treeview-first').filter(function(){ + return !$(this).parents().is('.oe_open') && $(this).parents().css( "display" ) !== 'none'; + }).click(); }); } - return this._super.apply(this, arguments); + return this._super(view_type, no_store, view_options); }, expand: function(domains, contexts, groupbys) { - this.$el.find("ul#oe_group_by").remove(); - if(groupbys.length && this.active_view == 'list') { + $("div#oe_group_by").remove(); + if(groupbys.length && this.active_view.type === 'list') { this.load_expand_buttons(); - this.$el.find("a#oe_group_by_reset").click(function(){ - $('span.ui-icon-triangle-1-s').click() + $("li#oe_group_by_reset").click(function(){ + $('span.ui-icon-triangle-1-s').click(); }); - this.$el.find("a#oe_group_by_expand").click(function(){ - $('span.ui-icon-triangle-1-e').click() + $("li#oe_group_by_expand").click(function(){ + $('span.ui-icon-triangle-1-e').click(); }); } }, load_expand_buttons:function() { var self = this; this.$ExpandButtons = $(QWeb.render("GroupExpand.Buttons", {'widget':self})); - this.$el.find("ul.oe_view_manager_switch.oe_button_group.oe_right").before(this.$ExpandButtons); + $(".oe-cp-switch-buttons.btn-group.btn-group-sm").before(this.$ExpandButtons); }, - setup_search_view: function(view_id, search_defaults) { + setup_search_view: function() { var self = this; - var res = this._super.apply(this, arguments); + var res = this._super(); this.searchview.on('search_data', self, this.expand); - return res + return res; }, - }) -} \ No newline at end of file + }); +}); diff --git a/web_group_expand/static/src/xml/expand_buttons.xml b/web_group_expand/static/src/xml/expand_buttons.xml index 27d3a50a..ed301d0a 100644 --- a/web_group_expand/static/src/xml/expand_buttons.xml +++ b/web_group_expand/static/src/xml/expand_buttons.xml @@ -1,11 +1,11 @@ -
-
    -
  • -
  • -
+
+
+
  • +
  • +