diff --git a/web_listview_invert_selection/README.rst b/web_listview_invert_selection/README.rst new file mode 100644 index 00000000..c7a0f1ef --- /dev/null +++ b/web_listview_invert_selection/README.rst @@ -0,0 +1,63 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +===================== +List Invert Selection +===================== + +Allow to invert the current selection of a list of records. + +Configuration +============= + +No configuration is needed. + +Usage +===== + +.. figure:: static/description/before.png + :alt: Before + +.. figure:: static/description/after.png + :alt: After + +To use this module, you need to: + +#. Go on any selectable list view; +#. Click on the "Invert Selection" button on the list header; + +.. 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/10.0 + +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 smash it by providing detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Antonio Esposito + +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 https://odoo-community.org. diff --git a/web_listview_invert_selection/__init__.py b/web_listview_invert_selection/__init__.py new file mode 100644 index 00000000..6529c19d --- /dev/null +++ b/web_listview_invert_selection/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Onestein () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/web_listview_invert_selection/__manifest__.py b/web_listview_invert_selection/__manifest__.py new file mode 100644 index 00000000..3f33e074 --- /dev/null +++ b/web_listview_invert_selection/__manifest__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Onestein () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'List Invert Selection', + 'summary': 'Invert current selection of list of records', + 'version': '10.0.1.0.0', + 'category': 'Web', + 'author': 'Onestein,Odoo Community Association (OCA)', + 'website': 'http://www.onestein.eu', + 'license': 'AGPL-3', + 'depends': [ + 'web', + ], + 'data': [ + 'templates/assets.xml' + ], + 'qweb': ['static/src/xml/web_listview_invert_selection.xml'], + 'installable': True, +} diff --git a/web_listview_invert_selection/static/description/after.png b/web_listview_invert_selection/static/description/after.png new file mode 100644 index 00000000..ed704604 Binary files /dev/null and b/web_listview_invert_selection/static/description/after.png differ diff --git a/web_listview_invert_selection/static/description/before.png b/web_listview_invert_selection/static/description/before.png new file mode 100644 index 00000000..530eece8 Binary files /dev/null and b/web_listview_invert_selection/static/description/before.png differ diff --git a/web_listview_invert_selection/static/src/js/web_listview_invert_selection.js b/web_listview_invert_selection/static/src/js/web_listview_invert_selection.js new file mode 100644 index 00000000..d7df0e82 --- /dev/null +++ b/web_listview_invert_selection/static/src/js/web_listview_invert_selection.js @@ -0,0 +1,34 @@ +/* Copyright 2017 Onestein +* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +odoo.define("web_listview_invert_selection", function (require) { + "use strict"; + var ListView = require("web.ListView"); + + ListView.include(/** @lends instance.web.ListView# */{ + + load_list: function (data, grouped) { + var self = this; + var result = this._super.apply(this, arguments); + + this.$("span.o_invert_selection").click(function () { + var checked = self.$("tbody .o_list_record_selector input:checked"); + var unchecked = self.$("tbody .o_list_record_selector input:not(:checked)"); + checked.prop("checked", false); + unchecked.prop("checked", true); + + var selected = []; + checked.each(function () { + selected.push($(this).attr("name")); + }); + if (selected.length === 0) { + self.$("thead .o_list_record_selector input").prop("checked", true); + } else { + self.$("thead .o_list_record_selector input").prop("checked", false); + } + }); + + return result; + } + }); +}); diff --git a/web_listview_invert_selection/static/src/less/web_listview_invert_selection.less b/web_listview_invert_selection/static/src/less/web_listview_invert_selection.less new file mode 100644 index 00000000..df824a14 --- /dev/null +++ b/web_listview_invert_selection/static/src/less/web_listview_invert_selection.less @@ -0,0 +1,5 @@ +.o_list_view { + .o_invert_selection { + padding-left: 2px; + } +} diff --git a/web_listview_invert_selection/static/src/xml/web_listview_invert_selection.xml b/web_listview_invert_selection/static/src/xml/web_listview_invert_selection.xml new file mode 100644 index 00000000..c79263b1 --- /dev/null +++ b/web_listview_invert_selection/static/src/xml/web_listview_invert_selection.xml @@ -0,0 +1,12 @@ + + + + + +
+ +
+
+
+ +
diff --git a/web_listview_invert_selection/templates/assets.xml b/web_listview_invert_selection/templates/assets.xml new file mode 100644 index 00000000..128966d8 --- /dev/null +++ b/web_listview_invert_selection/templates/assets.xml @@ -0,0 +1,12 @@ + + + + +