From 0cd8a45484e015a8da4a0b42057cbf208b35e7c8 Mon Sep 17 00:00:00 2001 From: Meet Dholakia Date: Sun, 29 Jul 2018 22:28:09 +0530 Subject: [PATCH] [MIG] web_listview_invert_selection : Migration to 11.0 --- web_listview_invert_selection/README.rst | 1 + web_listview_invert_selection/__manifest__.py | 5 +- .../src/js/web_listview_invert_selection.js | 52 +++++++++++-------- .../src/xml/web_listview_invert_selection.xml | 12 ----- 4 files changed, 33 insertions(+), 37 deletions(-) delete mode 100644 web_listview_invert_selection/static/src/xml/web_listview_invert_selection.xml diff --git a/web_listview_invert_selection/README.rst b/web_listview_invert_selection/README.rst index c7a0f1ef..9ae1e6a9 100644 --- a/web_listview_invert_selection/README.rst +++ b/web_listview_invert_selection/README.rst @@ -46,6 +46,7 @@ Contributors ------------ * Antonio Esposito +* Meet Dholakia Maintainer ---------- diff --git a/web_listview_invert_selection/__manifest__.py b/web_listview_invert_selection/__manifest__.py index 3f33e074..d4cf7371 100644 --- a/web_listview_invert_selection/__manifest__.py +++ b/web_listview_invert_selection/__manifest__.py @@ -5,10 +5,10 @@ { 'name': 'List Invert Selection', 'summary': 'Invert current selection of list of records', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'category': 'Web', 'author': 'Onestein,Odoo Community Association (OCA)', - 'website': 'http://www.onestein.eu', + 'website': 'https://github.com/OCA/web', 'license': 'AGPL-3', 'depends': [ 'web', @@ -16,6 +16,5 @@ 'data': [ 'templates/assets.xml' ], - 'qweb': ['static/src/xml/web_listview_invert_selection.xml'], 'installable': True, } 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 index d7df0e82..6e01bf52 100644 --- 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 @@ -3,32 +3,40 @@ odoo.define("web_listview_invert_selection", function (require) { "use strict"; - var ListView = require("web.ListView"); + var core = require('web.core'); + var _t = core._t; + var ListRenderer = require('web.ListRenderer'); - ListView.include(/** @lends instance.web.ListView# */{ + ListRenderer.include(/** @lends instance.web.ListView# */{ - load_list: function (data, grouped) { - var self = this; - var result = this._super.apply(this, arguments); + events: _.extend({}, ListRenderer.prototype.events, { + 'click .o_invert_selection': '_onInvertSelection', + }), - 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); + _onInvertSelection: function (event) { + event.stopPropagation(); + 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); + this._updateSelection(); + }, - 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); - } - }); + _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 = $('