diff --git a/web_search_alphabetic/__init__.py b/web_search_alphabetic/__init__.py new file mode 100644 index 00000000..26f88456 --- /dev/null +++ b/web_search_alphabetic/__init__.py @@ -0,0 +1,23 @@ +# -*- 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: diff --git a/web_search_alphabetic/__openerp__.py b/web_search_alphabetic/__openerp__.py new file mode 100644 index 00000000..818d0057 --- /dev/null +++ b/web_search_alphabetic/__openerp__.py @@ -0,0 +1,49 @@ +# -*- 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 . +# +############################################################################ + +{ + 'name': 'Web Alphabetical Search', + 'author' : 'Serpent Consulting Services Pvt. Ltd.', + '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', + 'depends': ['web'], + 'js': [ + 'static/src/js/web_search.js' + ], + 'css': [ + 'static/src/css/web_search.css' + ], + 'qweb' : [ + 'static/src/xml/web_search.xml', + ], + 'auto_install': False +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/web_search_alphabetic/static/src/css/web_search.css b/web_search_alphabetic/static/src/css/web_search.css new file mode 100644 index 00000000..741a071c --- /dev/null +++ b/web_search_alphabetic/static/src/css/web_search.css @@ -0,0 +1,44 @@ +.openerp .search_filter { + background: #F0F0F0; + width: 100%; + border: 1px solid #999; + background: -moz-linear-gradient(top, #F0F0F0 0%, #C0C0C0 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#F0F0F0), color-stop(100%,#C0C0C0)); +} + +.openerp .oe_filter_label { + background: #F0F0F0; + width: 3.35%; + border: 1px solid #999; + background: -moz-linear-gradient(top, #F0F0F0 0%, #C0C0C0 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#F0F0F0), color-stop(100%,#C0C0C0)); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F0F0F0', endColorstr='#C0C0C0',GradientType=0 ); +} +.openerp .oe_filter_label:hover { + background: #F0F0F0; + background: -moz-linear-gradient(top, #F0F0F0 0%, #A1A7CE 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#F0F0F0), color-stop(100%,#A1A7CE)); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F0F0F0', endColorstr='#A1A7CE',GradientType=0 ); +} +.openerp .oe_filter_label:active { + background: #aaa; + background: -moz-linear-gradient(top, #999999 0%, #EEEEEE 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#999999), color-stop(100%,#EEEEEE)); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#999999', endColorstr='#EEEEEE',GradientType=0 ); +} +.openerp .oe_filter_label.enabled { + background: #aaa; + filter: none; + -moz-box-shadow: none; + -webkit-box-shadow: none; + -o-box-shadow: none; + box-shadow: none; +} +.openerp .oe_filter_label { + font-weight: bold; + text-transform: uppercase; + text-shadow: #EEE 0 1px 0; + color: #4C4C4C; + white-space: nowrap; + margin: 0; +} \ No newline at end of file diff --git a/web_search_alphabetic/static/src/img/icon.png b/web_search_alphabetic/static/src/img/icon.png new file mode 100644 index 00000000..53dd30d9 Binary files /dev/null and b/web_search_alphabetic/static/src/img/icon.png differ diff --git a/web_search_alphabetic/static/src/js/web_search.js b/web_search_alphabetic/static/src/js/web_search.js new file mode 100644 index 00000000..9227c5fe --- /dev/null +++ b/web_search_alphabetic/static/src/js/web_search.js @@ -0,0 +1,80 @@ +openerp.web_search_alphabetic = function (instance) { + var QWeb = instance.web.qweb; + instance.web.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; + }) + } + }); + $('.oe_filter_label').click(function (e) { + $(this).toggleClass('enabled'); + self.do_search(); + }); + return result; + }, + search_filter: function(){ + var filter_domain = []; + var self = this; + _.each($('.oe_filter_label'), function(value) { + if ($(value).hasClass('enabled') && $(value).attr('id') && self.search_on) { + filter_domain.push("[('" + self.search_on + "', '=ilike', '" + $(value).attr('id').split('_')[1] + "%')]") + } + }); + if (filter_domain.length) { + var filter_or_domain = []; + for (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(); + 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) { + 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(); + } + return result; + }, + }); + instance.web.FormView.include({ + load_defaults: function () { + if($('.search_filter')) + $('.search_filter').hide(); + return this._super(); + }, + }); +}; + +// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: diff --git a/web_search_alphabetic/static/src/xml/web_search.xml b/web_search_alphabetic/static/src/xml/web_search.xml new file mode 100644 index 00000000..4b71d90d --- /dev/null +++ b/web_search_alphabetic/static/src/xml/web_search.xml @@ -0,0 +1,49 @@ +