diff --git a/web_listview_custom_element_number/README.rst b/web_listview_custom_element_number/README.rst new file mode 100644 index 000000000..1b936dbf2 --- /dev/null +++ b/web_listview_custom_element_number/README.rst @@ -0,0 +1,74 @@ +Allow users to set manually a quantity of items to display in a tree view +========================================================================= + +By default, in Odoo, user can display 80 / 200 / 500 / 2000 elements in +a tree view. With that module, user can select a custom number of items to +display; + +Technical information +--------------------- + +* replace a select element by an input with datalist option. That allows + to set a custom value, or to select an option. (same options as before: + 80 / 200 / 500 / 2000 / unlimited); + +* WARNING: 'Datalist' is a HTML5 tag; If your browser is not HTML5 + compliant, the options will not be displayed (but it is possible for + user to select manually a value); + See browser Support: http://www.w3schools.com/tags/tag_datalist.asp + + +Usage +----- + +* Sample for res.partner model with a limit of 3: + +.. image:: web_listview_custom_element_number/static/src/img/screnshot_partner_limit.png + +The display of the datalist input can be different depending of the browser. + +* FireFox Display: + +.. image:: web_listview_custom_element_number/static/src/img/screnshot_firefox.png + +* Chrome Display: + +.. image:: web_listview_custom_element_number/static/src/img/screnshot_chrome.png + +Limits / Roadmap +================ +* When pressing Esc key, it could be user friendly to return to the previous + state (before editing the quantity). + + +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 +------------ + +* Sylvain LE GAL (https://twitter.com/legalsylvain) + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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_listview_custom_element_number/__init__.py b/web_listview_custom_element_number/__init__.py new file mode 100644 index 000000000..dae354a67 --- /dev/null +++ b/web_listview_custom_element_number/__init__.py @@ -0,0 +1 @@ +# -*- encoding: utf-8 -*- diff --git a/web_listview_custom_element_number/__openerp__.py b/web_listview_custom_element_number/__openerp__.py new file mode 100644 index 000000000..60a49c71d --- /dev/null +++ b/web_listview_custom_element_number/__openerp__.py @@ -0,0 +1,38 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Web - Custom Element Number in ListView module for Odoo +# Copyright (C) 2015-Today Akretion (http://www.akretion.com) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'Web - Custom Element Number in ListView', + 'summary': 'Allow users to set manually a quantity of items to display' + ' in a tree view', + 'version': '1.0', + 'category': 'web', + 'author': "Akretion,Odoo Community Association (OCA)", + 'website': 'http://www.akretion.com', + 'license': 'AGPL-3', + 'depends': [ + 'web', + ], + 'data': [ + 'views/templates.xml', + ], +} diff --git a/web_listview_custom_element_number/i18n/fr.po b/web_listview_custom_element_number/i18n/fr.po new file mode 100644 index 000000000..6f8db58e8 --- /dev/null +++ b/web_listview_custom_element_number/i18n/fr.po @@ -0,0 +1,23 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-06-07 23:26+0000\n" +"PO-Revision-Date: 2015-06-07 23:26+0000\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_custom_element_number +#. openerp-web +#: code:addons/web_listview_custom_element_number/static/src/js/web_listview_custom_element_number.js:56 +#, python-format +msgid "0 (Unlimited)" +msgstr "0 (Illimité)" + diff --git a/web_listview_custom_element_number/i18n/web_listview_custom_element_number.pot b/web_listview_custom_element_number/i18n/web_listview_custom_element_number.pot new file mode 100644 index 000000000..fcebc90ae --- /dev/null +++ b/web_listview_custom_element_number/i18n/web_listview_custom_element_number.pot @@ -0,0 +1,23 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-06-07 23:25+0000\n" +"PO-Revision-Date: 2015-06-07 23:25+0000\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_custom_element_number +#. openerp-web +#: code:addons/web_listview_custom_element_number/static/src/js/web_listview_custom_element_number.js:56 +#, python-format +msgid "0 (Unlimited)" +msgstr "" + diff --git a/web_listview_custom_element_number/static/src/css/web_listview_custom_element_number.css b/web_listview_custom_element_number/static/src/css/web_listview_custom_element_number.css new file mode 100644 index 000000000..2bc137158 --- /dev/null +++ b/web_listview_custom_element_number/static/src/css/web_listview_custom_element_number.css @@ -0,0 +1,22 @@ +/****************************************************************************** + Web - Custom Element Number in ListView module for Odoo + Copyright (C) 2015-Today Akretion (http://www.akretion.com) + @author Sylvain LE GAL (https://twitter.com/legalsylvain) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +******************************************************************************/ + +.custom_element_number { + width:80px; +} diff --git a/web_listview_custom_element_number/static/src/img/icon.png b/web_listview_custom_element_number/static/src/img/icon.png new file mode 100644 index 000000000..0d11906df Binary files /dev/null and b/web_listview_custom_element_number/static/src/img/icon.png differ diff --git a/web_listview_custom_element_number/static/src/img/screnshot_chrome.png b/web_listview_custom_element_number/static/src/img/screnshot_chrome.png new file mode 100644 index 000000000..ef6944347 Binary files /dev/null and b/web_listview_custom_element_number/static/src/img/screnshot_chrome.png differ diff --git a/web_listview_custom_element_number/static/src/img/screnshot_firefox.png b/web_listview_custom_element_number/static/src/img/screnshot_firefox.png new file mode 100644 index 000000000..7e239ce42 Binary files /dev/null and b/web_listview_custom_element_number/static/src/img/screnshot_firefox.png differ diff --git a/web_listview_custom_element_number/static/src/img/screnshot_partner_limit.png b/web_listview_custom_element_number/static/src/img/screnshot_partner_limit.png new file mode 100644 index 000000000..8668139b2 Binary files /dev/null and b/web_listview_custom_element_number/static/src/img/screnshot_partner_limit.png differ diff --git a/web_listview_custom_element_number/static/src/js/web_listview_custom_element_number.js b/web_listview_custom_element_number/static/src/js/web_listview_custom_element_number.js new file mode 100644 index 000000000..5e6ecfb57 --- /dev/null +++ b/web_listview_custom_element_number/static/src/js/web_listview_custom_element_number.js @@ -0,0 +1,81 @@ +/****************************************************************************** + Web - Custom Element Number in ListView module for Odoo + Copyright (C) 2015-Today Akretion (http://www.akretion.com) + @author Sylvain LE GAL (https://twitter.com/legalsylvain) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +******************************************************************************/ + +openerp.web_listview_custom_element_number = function (instance) { + module = instance.web; + _t = module._t; + + /*************************************************************************** + Extend the widget 'instance.web.ListView' to replace the select tag by an + input with datalist option. + ***************************************************************************/ + module.ListView.include({ + + /** + * Overload 'load_list' function: + */ + load_list: function(data) { + var self = this; + this._super.apply(this, arguments); + + if (this.$pager){ + // unbind previous function that added a select tag + this.$pager.find('.oe_list_pager_state').unbind("click"); + + // bind a new function on click, that add a input type select + this.$pager.find('.oe_list_pager_state').click(function (e) { + e.stopPropagation(); + var $this = $(this); + var $select = $('') + .appendTo($this.empty()) + .click(function (e) {e.stopPropagation();}) + .append( + '' + + '') + .change(function () { + var val = parseInt($select.val(), 10); + if (!isNaN(val)){ + if (val == 0){ + self._limit = null; + } + else{ + self._limit = val; + } + self.page = 0; + self.reload_content(); + } + }).blur(function() { + $(this).trigger('change'); + }) + .keypress(function(e) { + if(e.which == 13) { + $(this).trigger('change'); + } + }) + .focus() + }); + } + }, + }); +}; diff --git a/web_listview_custom_element_number/views/templates.xml b/web_listview_custom_element_number/views/templates.xml new file mode 100644 index 000000000..4a00a4a1e --- /dev/null +++ b/web_listview_custom_element_number/views/templates.xml @@ -0,0 +1,30 @@ + + + + + + + +