Browse Source

[ADD] new module web_custom_search_quantity;

pull/150/head
Sylvain LE GAL 10 years ago
parent
commit
f97885a057
  1. 21
      web_custom_search_quantity/__init__.py
  2. 67
      web_custom_search_quantity/__openerp__.py
  3. 23
      web_custom_search_quantity/i18n/fr.po
  4. 23
      web_custom_search_quantity/i18n/web_custom_search_quantity.pot
  5. 22
      web_custom_search_quantity/static/src/css/web_custom_search_quantity.css
  6. BIN
      web_custom_search_quantity/static/src/img/icon.png
  7. 76
      web_custom_search_quantity/static/src/js/web_custom_search_quantity.js

21
web_custom_search_quantity/__init__.py

@ -0,0 +1,21 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Web - Custom Search Quantity 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 <http://www.gnu.org/licenses/>.
#
##############################################################################

67
web_custom_search_quantity/__openerp__.py

@ -0,0 +1,67 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Web - Custom Search Quantity 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Web - Custom Search Quantity',
'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
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': "GRAP,Odoo Community Association (OCA)",
'website': 'http://www.grap.coop',
'license': 'AGPL-3',
'depends': [
'web',
],
'js': [
'static/src/js/web_custom_search_quantity.js',
],
'css': [
"static/src/css/web_custom_search_quantity.css",
],
}

23
web_custom_search_quantity/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_custom_search_quantity
#. openerp-web
#: code:addons/web_custom_search_quantity/static/src/js/web_custom_search_quantity.js:56
#, python-format
msgid "0 (Unlimited)"
msgstr "0 (Illimité)"

23
web_custom_search_quantity/i18n/web_custom_search_quantity.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_custom_search_quantity
#. openerp-web
#: code:addons/web_custom_search_quantity/static/src/js/web_custom_search_quantity.js:56
#, python-format
msgid "0 (Unlimited)"
msgstr ""

22
web_custom_search_quantity/static/src/css/web_custom_search_quantity.css

@ -0,0 +1,22 @@
/******************************************************************************
Web - Custom Search Quantity 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 <http://www.gnu.org/licenses/>.
******************************************************************************/
.custom_search_quantity {
width:50px;
}

BIN
web_custom_search_quantity/static/src/img/icon.png

After

Width: 128  |  Height: 128  |  Size: 3.3 KiB

76
web_custom_search_quantity/static/src/js/web_custom_search_quantity.js

@ -0,0 +1,76 @@
/******************************************************************************
Web - Custom Search Quantity 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 <http://www.gnu.org/licenses/>.
******************************************************************************/
openerp.web_custom_search_quantity = 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 = $('<input list="page_value" class="custom_search_quantity" type="text">')
.appendTo($this.empty())
.click(function (e) {e.stopPropagation();})
.append(
'<datalist id="page_value">' +
'<option value="80">' +
'<option value="200">' +
'<option value="500">' +
'<option value="2000">' +
'<option value="0" label="'+_t("0 (Unlimited)") + '">' +
'</datalist>')
.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');
})
.val(self._limit || '0');
});
}
},
});
};
Loading…
Cancel
Save