From 5ee8764579407c80c684dd7c1cbd5648aed79121 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Thu, 9 Jul 2015 16:09:18 +0200 Subject: [PATCH] [WIP] port from 7.0 branch 'web_listview_custom_element_number' module; --- .../__init__.py | 1 + .../__openerp__.py | 72 ++++++++++++++++ web_listview_custom_element_number/i18n/fr.po | 23 +++++ .../web_listview_custom_element_number.pot | 23 +++++ .../web_listview_custom_element_number.css | 22 +++++ .../static/src/img/icon.png | Bin 0 -> 3333 bytes .../js/web_listview_custom_element_number.js | 81 ++++++++++++++++++ 7 files changed, 222 insertions(+) create mode 100644 web_listview_custom_element_number/__init__.py create mode 100644 web_listview_custom_element_number/__openerp__.py create mode 100644 web_listview_custom_element_number/i18n/fr.po create mode 100644 web_listview_custom_element_number/i18n/web_listview_custom_element_number.pot create mode 100644 web_listview_custom_element_number/static/src/css/web_listview_custom_element_number.css create mode 100644 web_listview_custom_element_number/static/src/img/icon.png create mode 100644 web_listview_custom_element_number/static/src/js/web_listview_custom_element_number.js diff --git a/web_listview_custom_element_number/__init__.py b/web_listview_custom_element_number/__init__.py new file mode 100644 index 00000000..dae354a6 --- /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 00000000..6bf3fc3a --- /dev/null +++ b/web_listview_custom_element_number/__openerp__.py @@ -0,0 +1,72 @@ +# -*- 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', + 'version': '1.0', + 'category': 'web', + 'description': """ +Allow users to set manually a quantity of items to display in a tree view +========================================================================= + +Functionality: +-------------- + * 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 + +Roadmap: +-------- + * When pressing Esc key, it could be user friendly to return to the + previous state (before editing the quantity). + +Copyright, Author and Licence: +------------------------------ + * Copyright: + * 2015-Today, Akretion; + * Author: + * Sylvain LE GAL (https://twitter.com/legalsylvain); + * Licence: AGPL-3 (http://www.gnu.org/licenses/)""", + 'author': "Akretion,Odoo Community Association (OCA)", + 'website': 'http://www.grap.coop', + 'license': 'AGPL-3', + 'depends': [ + 'web', + ], + 'js': [ + 'static/src/js/web_listview_custom_element_number.js', + ], + 'css': [ + 'static/src/css/web_listview_custom_element_number.css', + ], +} 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 00000000..6f8db58e --- /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 00000000..fcebc90a --- /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 00000000..c3a75be5 --- /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:50px; +} 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 0000000000000000000000000000000000000000..0d11906dfcb99614f651e6360ab5e8120784b29d GIT binary patch literal 3333 zcmchacQhN^|HorIW{XNSYE-DvqV{a8+FD7~RwGvE5@OZXqG}T(DnT{0Mm_N;6?u%J zRIRG28WEe6(1=l+pZ?D8zu({A?>*;p-{;=@IiK^n=e*8&-E^{?6USg1 zf1lvT9)SqJ4R3!>1lYpQ!xv$V@bC^t^&oTrfHQFx#y4!k3fBsw16&X--TKtkV%-Cb znj-WTRyy~a757!eAJ%L)yC$B>cELy~M2Y;kl-^yHl!%tnDY>+aq|n~}qxc~?`zzqq zC&V~wCWzpbAkzDW@63KIIcgL?n`~+5zvH8IR7U0i@|}f76HXeJKDb$+J-oW7OAU{S zET-=jO^1J}dCMuz%5{IpcY>*_AI}Qbz6r=K{V&Trt5)c$Alf`(m|pzie(X&cB1F{A z&Q483BjX`aK9xXFh-(M4u&_8{x`Gd@ttI)}=NXpa9{|`lvw@@v0^v<yf|ZyEDbgU%y7A4ZM>-Emc%hWNT|{%?SjPg)S5j5QHLPaCEZE~M z{Q!TtH)L-39u_m)eNXMCN1j%1UuQ4tJ*?j!ft048m_yzk8B3 zPVX3;L4x^QLlTAi-u>ez?CuEgl7Sn&g{P8YR850egf2)lJ|7bkllU>Ek1qlq;RnJr z9(8Ds#%r}??uuQKjA)c82QFR^;Np)tr}q$RzondWU%volYNn#=%f1xY5BZSz(2X~l zLQXz@Ef6_%fSTUB=3c~exL$Iemf8-&qGmgC$$ow^l zC~W(PbioTHP#ax-0~f!!j~gnD$&bCo1fwA3p2^eF>unSA>+cCR}Q-$3Hh8n zZzd$?#bLbTUPrFYL;Gr!b_I=T#vKI$Dy_J=aG~|DwCipVe_$~U9bNdSFGIIQ# z2&ev$N<$GP#`2vnC_i_>v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PW-Sk#`>t){CW_bE)(3>-p3x`840H74ID{8yK|S)|#E62{|c` z_w2P|&JvLV^xR?2DxB*LHHou{rSy2+rY{*#0T#XjAQ#fpYtG1$an1U5&+T_~qWo}eFrFmmr!h4ertsN8`_F~w!@}=D_@eXD% zj7k@Cr>V*~Z44=HY%4x;KPKO1v^9XV5CWbKxmdi!lclEIK_n#+sbwutMR!i2{)}n3 z6rF>7s7;lbUK)30sv13#c}xjACmrXrgK9mT_Z=T0VaT9`T1AaFRA<>hYwyXCfHD~| z@Wof<(;eFW;z5O3Kea8%C8<(!Ldwr44lph~5`SlY^z%(xtOdd4Uu!vhnf-(V@6Mg9 zd(T8^P(r2bgvNZEE_M!1rp&hCNmVas&#WFNgtzNx-le;pyltN&3M?EMqxuq-;8ic1+sk7y{nRxHonCwqR69j7#`x9UXeG zT5it7(c!P#&ik0viSe4gUYV!v#9jys+q2wC0pl- zJXxzti!#TSC)t@new2&X$%AFTX$n;PS=%^Tm1bX;QP-adq_&ndcH{t+ci z!<`9Os+GG5Lop}4T%g~0DiE7378P0cDv>wZUykTHgI~UU@gTZc8 zaoVcKOO;nYV741@U%vYGe~%+Zli}Jb%J7C2Fwp+KuM_8+{?b$Xi7LE%c zF;P32yUtPd;;z7ZXRa+ACYT*>vFW06HVKVrh+Z9fF({ER9rXSr$7Us4$qwk~Q-L)w zvG@b7CBNeeyxcmM9eafeN7-9KRxbR6ZmyVFEKI7`n&(4<^bx AeE. +******************************************************************************/ + +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() + }); + } + }, + }); +};