diff --git a/web_group_expand/README.rst b/web_group_expand/README.rst new file mode 100644 index 00000000..278696a4 --- /dev/null +++ b/web_group_expand/README.rst @@ -0,0 +1,62 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +==================== +Group Expand Buttons +==================== + +A group by list can be expanded and collapased 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. + + +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/11.0 + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + + +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 `_. + + +Credits +======= + +Contributors +------------ + +* Mantavya Gajjar +* Oihane Crucelaegui +* Pedro M. Baeza +* Jay Vora (SerpentCS) for their alternative implementation +* Aldo Soares + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + diff --git a/web_group_expand/__init__.py b/web_group_expand/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/web_group_expand/__manifest__.py b/web_group_expand/__manifest__.py new file mode 100644 index 00000000..c680789f --- /dev/null +++ b/web_group_expand/__manifest__.py @@ -0,0 +1,25 @@ +{ + "name": "Group Expand Buttons", + 'summary': """ + Enables expanding/reset all groups in list view + """, + "version": "11.0.1.0.0", + "category": "Web", + "author": "OpenERP SA, " + "AvanzOSC, " + "Serv. Tecnol. Avanzados - Pedro M. Baeza, " + "Odoo Community Association (OCA)", + "website": "https://github.com/oca/web", + 'license': 'AGPL-3', + "depends": [ + "web" + ], + "data": [ + "templates/assets.xml", + ], + "qweb": [ + "static/src/xml/web_group_expand.xml", + ], + "installable": True, + 'application': False, +} diff --git a/web_group_expand/static/description/icon.png b/web_group_expand/static/description/icon.png new file mode 100644 index 00000000..9eb607c3 Binary files /dev/null and b/web_group_expand/static/description/icon.png differ diff --git a/web_group_expand/static/src/css/web_group_expand.css b/web_group_expand/static/src/css/web_group_expand.css new file mode 100644 index 00000000..63604211 --- /dev/null +++ b/web_group_expand/static/src/css/web_group_expand.css @@ -0,0 +1,8 @@ +.o_favorites_menu + .toggle_buttons{ + float: left; + padding-left: 5px; +} + +.o_favorites_menu + .toggle_buttons button{ + display: inline; +} \ No newline at end of file diff --git a/web_group_expand/static/src/js/web_group_expand.js b/web_group_expand/static/src/js/web_group_expand.js new file mode 100644 index 00000000..ddb98032 --- /dev/null +++ b/web_group_expand/static/src/js/web_group_expand.js @@ -0,0 +1,75 @@ +odoo.define('web_groupby_expand.web_groupby_expand', function (require) { +"use strict"; + +var ViewManager = require('web.ViewManager'); + +ViewManager.include({ + render_view_control_elements: function (){ + var res = this._super.apply(this, arguments); + if (this.searchview_elements) { + var searchview = this.searchview_elements.$searchview_buttons + var expand_button = searchview.find('#oe_group_by_expand'); + var reset_button = searchview.find('#oe_group_by_reset'); + expand_button.on('click', this.proxy('expand_records')); + reset_button.on('click', this.proxy('reset_records')); + this.do_toggle_visibility(false) + } + return res; + }, + + _process_search_data: function () { + var res = this._super.apply(this, arguments); + if (this.active_view && this.active_view.type == 'list' && this.searchview_elements) { + var searchview = this.searchview_elements.$searchview_buttons + var has_groups = res.groupBy.length > 0 + this.do_toggle_visibility(has_groups) + } + return res; + }, + + get_search_groups: function (groups) { + var current_search_group = {}; + for (var group in groups) { + if (groups[group].count > 0 && groups[group].data.length > 0) { + current_search_group[groups[group].id] = groups[group].data; + } + } + return current_search_group; + }, + + do_toggle_visibility: function (show) { + var searchview = this.searchview_elements.$searchview_buttons + var buttons = searchview.find('.toggle_buttons'); + if (show) { + buttons.show() + } + else { + buttons.hide() + } + }, + + toggle_group_records: function (op, controller) { + var current_search_group = this.get_search_groups(controller.model.localData); + if (current_search_group) { + for (var group in current_search_group) { + for (var gp in current_search_group[group]) { + var cur_group = controller.model.localData[current_search_group[group][gp]] + if ((op && !cur_group.isOpen) || (!op && cur_group.isOpen)) { + controller.trigger_up('toggle_group', { group: cur_group }) + } + } + } + } + }, + + reset_records: function () { + var controller = this.active_view.controller; + this.toggle_group_records(false, controller) + }, + + expand_records: function () { + var controller = this.active_view.controller; + this.toggle_group_records(true, controller) + }, +}); +}); diff --git a/web_group_expand/static/src/xml/web_group_expand.xml b/web_group_expand/static/src/xml/web_group_expand.xml new file mode 100644 index 00000000..614900a5 --- /dev/null +++ b/web_group_expand/static/src/xml/web_group_expand.xml @@ -0,0 +1,11 @@ + + \ No newline at end of file diff --git a/web_group_expand/templates/assets.xml b/web_group_expand/templates/assets.xml new file mode 100644 index 00000000..4fcaee58 --- /dev/null +++ b/web_group_expand/templates/assets.xml @@ -0,0 +1,9 @@ + + + +