Browse Source

[10.0][ADD] Module web_listview_invert_selection (#538)

* [10.0][ADD] Module web_listview_invert_selection

* [FIX] Multiple code reviews

* [FIX] Changed single-quotes to double-quotes for improving codacy tests;
pull/955/head
Antonio Esposito 7 years ago
committed by Dennis Sluijk
parent
commit
dacb60f784
  1. 63
      web_listview_invert_selection/README.rst
  2. 3
      web_listview_invert_selection/__init__.py
  3. 21
      web_listview_invert_selection/__manifest__.py
  4. BIN
      web_listview_invert_selection/static/description/after.png
  5. BIN
      web_listview_invert_selection/static/description/before.png
  6. 34
      web_listview_invert_selection/static/src/js/web_listview_invert_selection.js
  7. 5
      web_listview_invert_selection/static/src/less/web_listview_invert_selection.less
  8. 12
      web_listview_invert_selection/static/src/xml/web_listview_invert_selection.xml
  9. 12
      web_listview_invert_selection/templates/assets.xml

63
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
<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 <a.esposito@onestein.nl>
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.

3
web_listview_invert_selection/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

21
web_listview_invert_selection/__manifest__.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# 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': '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,
}

BIN
web_listview_invert_selection/static/description/after.png

After

Width: 1850  |  Height: 900  |  Size: 123 KiB

BIN
web_listview_invert_selection/static/description/before.png

After

Width: 1850  |  Height: 900  |  Size: 118 KiB

34
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;
}
});
});

5
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;
}
}

12
web_listview_invert_selection/static/src/xml/web_listview_invert_selection.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-extend="ListView">
<t t-jquery="th.o_list_record_selector" t-operation="prepend">
<div>
<span class="o_invert_selection" title="Invert Selection"><i class="fa fa-refresh" aria-hidden="true"></i></span>
</div>
</t>
</t>
</templates>

12
web_listview_invert_selection/templates/assets.xml

@ -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/less" href="/web_listview_invert_selection/static/src/less/web_listview_invert_selection.less"/>
</xpath>
</template>
</odoo>
Loading…
Cancel
Save