diff --git a/web_search_alphabetic/README.rst b/web_search_alphabetic/README.rst new file mode 100644 index 00000000..d32b4c99 --- /dev/null +++ b/web_search_alphabetic/README.rst @@ -0,0 +1,60 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +===================== +Web Search Alphabetic +===================== + +Provides search functionality with the help of alphabetic buttons. + +After the installation of the module, you will be able to see alphabetic buttons appeared on the top of the Views panel +in sequence. By clicking on any of these buttons, it will provide you with the records starting with the relevant alphabet. + + +Installation +============ + +This module is simple to install as it has no depenency on addons other than core web module. + + +Usage +===== + +.. 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 `_. 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. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Serpent Consulting Services Pvt. Ltd. + +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. \ No newline at end of file diff --git a/web_search_alphabetic/__init__.py b/web_search_alphabetic/__init__.py index 26f88456..d5551063 100644 --- a/web_search_alphabetic/__init__.py +++ b/web_search_alphabetic/__init__.py @@ -1,23 +1,3 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# Copyright (C) 2011-2014 Serpent Consulting Services () -# -# 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 . -# -############################################################################ - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# Copyright 2014-Today Serpent Consulting Services Pvt. Ltd. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/web_search_alphabetic/__manifest__.py b/web_search_alphabetic/__manifest__.py index 63763868..00b95bc8 100644 --- a/web_search_alphabetic/__manifest__.py +++ b/web_search_alphabetic/__manifest__.py @@ -1,50 +1,27 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# Copyright (C) 2011-2014 Serpent Consulting Services () -# -# 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 . -# -############################################################################ - +# Copyright 2014-Today Serpent Consulting Services Pvt. Ltd. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Web Alphabetical Search', - 'author' : "Serpent Consulting Services Pvt. Ltd.,Odoo Community Association (OCA)", - 'category' : 'Web', + 'author': 'Serpent Consulting Services Pvt. Ltd.,' + 'Odoo Community Association(OCA)', + 'category': 'Web', 'website': 'http://www.serpentcs.com', 'description': """ -OpenERP Web Search Extended. -============================ - -This module used for search record base on alphabetical character be default it will search on name field. -User also is able to change search field name instead of name field. - """, - 'version': '1.0', + Odoo Web Search Extended. + ============================ + This module is used for searching the record base on alphabetical + character be default it will search on name field. + User is also able to change search field name instead of name field. + """, + 'version': '10.0.1.0.0', 'depends': ['web'], - 'js': [ - 'static/src/js/web_search.js' + 'data': [ + 'views/template.xml', ], - 'css': [ - 'static/src/css/web_search.css' - ], - 'qweb' : [ + 'qweb': [ 'static/src/xml/web_search.xml', ], - 'installable': False, + 'installable': True, 'auto_install': False } - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/web_search_alphabetic/static/description/icon.png b/web_search_alphabetic/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/web_search_alphabetic/static/description/icon.png differ diff --git a/web_search_alphabetic/static/src/css/web_search.css b/web_search_alphabetic/static/src/css/web_search.css index 741a071c..de8ccf0c 100644 --- a/web_search_alphabetic/static/src/css/web_search.css +++ b/web_search_alphabetic/static/src/css/web_search.css @@ -41,4 +41,7 @@ color: #4C4C4C; white-space: nowrap; margin: 0; -} \ No newline at end of file +} +.highlight{ + box-shadow:0px 1px 1px 1px #ef2929; +} diff --git a/web_search_alphabetic/static/src/img/icon.png b/web_search_alphabetic/static/src/img/icon.png deleted file mode 100644 index 53dd30d9..00000000 Binary files a/web_search_alphabetic/static/src/img/icon.png and /dev/null differ diff --git a/web_search_alphabetic/static/src/js/web_search.js b/web_search_alphabetic/static/src/js/web_search.js index 9227c5fe..de6613ca 100644 --- a/web_search_alphabetic/static/src/js/web_search.js +++ b/web_search_alphabetic/static/src/js/web_search.js @@ -1,32 +1,55 @@ -openerp.web_search_alphabetic = function (instance) { - var QWeb = instance.web.qweb; - instance.web.SearchView.include({ +odoo.define('web_search_alphabetic',function(require){ +"use strict"; + + var core = require('web.core') + var QWeb = core.qweb + var SearchView = require('web.SearchView'); + var ViewManager = require('web.ViewManager'); + var FormView = require('web.FormView'); + var ControlPanel = require('web.ControlPanel'); + + SearchView.include({ start: function() { - var result = this._super(); var self = this; - self.search_on = "name"; - self.fields_selection = []; - this.dataset.call('fields_get', [false, {}]).done(function (fields) { - $.each(fields, function (value) { - if(fields[value].type == "char"){ - fields[value].id = value; - self.fields_selection.push(fields[value]); - } - }) - if(self.fields_selection.length){ - $('.field_selection_column').append((QWeb.render('field-selection', {widget: self}))); - $("#field_name_selection").change(function(){ - self.search_on = $(this).val() || false; - }) + return $.when(this._super()).done(function(){ + if(self.ViewManager && self.ViewManager.action && self.ViewManager.action.target != 'new'){ + self.search_on = "name"; + self.fields_selection = []; + self.dataset.call('fields_get', [false, {}]).done(function (fields) { + $.each(fields, function (value) { + if(fields[value].type == "char") { + fields[value].id = value; + self.fields_selection.push(fields[value]); + } + }) + if(self.fields_selection.length){ + if($("#field_name_selection")){ + $("#field_name_selection").remove(); + } + if($('.field_selection_column')[0]){ + $('.field_selection_column').append((QWeb.render('field-selection', {widget: self}))); + self.search_on = $('#field_name_selection').val(); + $("#field_name_selection").change(function(){ + self.search_on = $(this).val() || false; + }); + $('.oe_filter_label').unbind('click').bind('click',function (e) { + $(this).toggleClass('enabled'); + if($(this).hasClass('enabled')){ + $(this).addClass('highlight') + } + else{ + $(this).removeClass('highlight') + } + self.do_search(); + }); + } + } + }); } }); - $('.oe_filter_label').click(function (e) { - $(this).toggleClass('enabled'); - self.do_search(); - }); - return result; }, - search_filter: function(){ + + search_filter: function() { var filter_domain = []; var self = this; _.each($('.oe_filter_label'), function(value) { @@ -36,45 +59,61 @@ openerp.web_search_alphabetic = function (instance) { }); if (filter_domain.length) { var filter_or_domain = []; - for (i = 0; i < filter_domain.length-1; i++) { + for (var i = 0; i < filter_domain.length-1; i++) { filter_or_domain.push("['|']"); } return filter_or_domain.concat(filter_domain || []); } return false; }, + build_search_data: function () { var result = this._super(); - filter_domain = this.search_filter(); + var filter_domain = this.search_filter(); if (filter_domain) result['domains'] = filter_domain.concat(result.domains || []); return result; }, }); - instance.web.ViewManager.include({ - switch_mode: function(view_type, no_store, view_options) { + ViewManager.include({ + switch_mode: function(view_type, view_options) { + var self = this; var view = this.views[view_type]; - var result = this._super(view_type, no_store, view_options); - if (this.searchview && this.active_view != "form") { - if ((view.controller.searchable === false || this.searchview.options.hidden) || this.active_view == "form"){ - $('.search_filter').live().hide(); - }else - $('.search_filter').show(); - } - else{ - $('.search_filter').live().hide(); + var result = this._super(view_type, view_options); + if(this.action && this.action.target != 'new'){ + if (this.searchview) { + if(view_type=="form" || (view.controller.searchable === false || this.searchview.options.hidden) || this.active_view == "form"){ + $('.search_filter').on().hide(); + }else{ + $('.search_filter').show(); + } + }else{ + $('.search_filter').on().hide(); + } } return result; }, }); - instance.web.FormView.include({ + + FormView.include({ load_defaults: function () { if($('.search_filter')) $('.search_filter').hide(); return this._super(); }, }); -}; -// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: + ControlPanel.include({ + _toggle_visibility: function(visible) { + this._super(); + this.do_toggle(visible); + if (!visible && !this.$content) { + this.$content = this.$el.contents().detach(); + } else if (this.$content) { + this.$content.appendTo(this.$el); + this.$content = null; + } + }, + }) +}); diff --git a/web_search_alphabetic/static/src/xml/web_search.xml b/web_search_alphabetic/static/src/xml/web_search.xml index 4b71d90d..d45bd15c 100644 --- a/web_search_alphabetic/static/src/xml/web_search.xml +++ b/web_search_alphabetic/static/src/xml/web_search.xml @@ -9,38 +9,38 @@ - - + +
- - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/web_search_alphabetic/views/template.xml b/web_search_alphabetic/views/template.xml new file mode 100644 index 00000000..bd1964db --- /dev/null +++ b/web_search_alphabetic/views/template.xml @@ -0,0 +1,11 @@ + + + + + +