Skip to content

[12.0][MIG] web_listview_invert_selection #1412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

64 changes: 64 additions & 0 deletions web_listview_invert_selection/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.. 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
<https://github.com/OCA/web/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 <[email protected]>
* Meet Dholakia <[email protected]>

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.
2 changes: 2 additions & 0 deletions web_listview_invert_selection/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2017 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
19 changes: 19 additions & 0 deletions web_listview_invert_selection/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2017 Onestein (<http://www.onestein.eu>)
# 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': '12.0.1.0.0',
'category': 'Web',
'author': 'Onestein,Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/web',
'license': 'AGPL-3',
'depends': [
'web',
],
'data': [
'templates/assets.xml'
],
'installable': True,
}
26 changes: 26 additions & 0 deletions web_listview_invert_selection/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_listview_invert_selection
#
# Translators:
# Quentin THEURET <[email protected]>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-26 02:44+0000\n"
"PO-Revision-Date: 2017-07-26 02:44+0000\n"
"Last-Translator: Quentin THEURET <[email protected]>, 2017\n"
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#. module: web_listview_invert_selection
#. openerp-web
#: code:addons/web_listview_invert_selection/static/src/js/web_listview_invert_selection.js:35
#, python-format
msgid "Invert Selection"
msgstr "Inverser la sélection"
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_listview_invert_selection
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: web_listview_invert_selection
#. openerp-web
#: code:addons/web_listview_invert_selection/static/src/js/web_listview_invert_selection.js:35
#, python-format
msgid "Invert Selection"
msgstr ""

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* 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 core = require('web.core');
var _t = core._t;
var ListRenderer = require('web.ListRenderer');

ListRenderer.include(/** @lends instance.web.ListView# */{

events: _.extend({}, ListRenderer.prototype.events, {
'click .o_invert_selection': '_onInvertSelection',
}),

_onInvertSelection: function (event) {
event.stopPropagation();
var checked = $("tbody .o_list_record_selector input:checked");
var unchecked = $("tbody .o_list_record_selector input:not(:checked)");
checked.prop("checked", false);
unchecked.prop("checked", true);
this._updateSelection();
},

_renderHeader: function (isGrouped) {
var $header = this._super.apply(this, arguments);
if (this.hasSelectors) {
$header.find('th.o_list_record_selector').prepend(this._renderInvertSelection('span'));
}
return $header;
},

_renderInvertSelection: function (tag) {
var $icon = $('<i>', {class: 'fa fa-refresh o_invert_selection_btn', name: 'Invert Selection',
'aria-label': _t('Invert Selection'), 'title': _t('Invert Selection')});
return $('<' + tag + '>')
.addClass('o_invert_selection')
.append($icon);
},

});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.o_list_view {
.o_invert_selection {
padding-left: 2px;
}
}
12 changes: 12 additions & 0 deletions web_listview_invert_selection/templates/assets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2017 Onestein
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo>
<template id="assets_backend" name="web_listview_invert_selection backend assets" inherit_id="web.assets_backend">
<xpath expr=".">
<script type="text/javascript" src="/web_listview_invert_selection/static/src/js/web_listview_invert_selection.js"/>
<link rel="stylesheet" type="text/scss" href="/web_listview_invert_selection/static/src/scss/web_listview_invert_selection.scss"/>
</xpath>
</template>
</odoo>