Browse Source

[MIG] Migrated web_search_alphabetic to v10

[MIG] Migrated web_search_alphabetic to v10
pull/572/head
Jay Vora(SerpentCS) 7 years ago
parent
commit
03660703e7
  1. 60
      web_search_alphabetic/README.rst
  2. 24
      web_search_alphabetic/__init__.py
  3. 55
      web_search_alphabetic/__manifest__.py
  4. BIN
      web_search_alphabetic/static/description/icon.png
  5. 5
      web_search_alphabetic/static/src/css/web_search.css
  6. BIN
      web_search_alphabetic/static/src/img/icon.png
  7. 119
      web_search_alphabetic/static/src/js/web_search.js
  8. 56
      web_search_alphabetic/static/src/xml/web_search.xml
  9. 11
      web_search_alphabetic/views/template.xml

60
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 <https://github.com/OCA/web/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 <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Serpent Consulting Services Pvt. Ltd.<jay.vora@serpentcs.com>
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.

24
web_search_alphabetic/__init__.py

@ -1,23 +1,3 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2011-2014 Serpent Consulting Services (<http://www.serpentcs.com>)
#
# 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/>.
#
############################################################################
# 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).

55
web_search_alphabetic/__manifest__.py

@ -1,50 +1,27 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2011-2014 Serpent Consulting Services (<http://www.serpentcs.com>)
#
# 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/>.
#
############################################################################
# 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:

BIN
web_search_alphabetic/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

5
web_search_alphabetic/static/src/css/web_search.css

@ -41,4 +41,7 @@
color: #4C4C4C;
white-space: nowrap;
margin: 0;
}
}
.highlight{
box-shadow:0px 1px 1px 1px #ef2929;
}

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

Before

Width: 159  |  Height: 221  |  Size: 16 KiB

119
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;
}
},
})
});

56
web_search_alphabetic/static/src/xml/web_search.xml

@ -9,38 +9,38 @@
</t>
</t>
<t t-extend="ViewManagerAction">
<t t-jquery=".oe_view_manager .oe_view_manager_header" t-operation="append">
<t t-extend="ControlPanel">
<t t-jquery=".o_control_panel" t-operation="append">
<table class="search_filter">
<tr>
<th class="field_selection_column"/>
<th>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_a" title="A">A</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_b" title="B">B</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_c" title="C">C</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_d" title="D">D</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_e" title="E">E</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_f" title="F">F</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_g" title="G">G</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_h" title="H">H</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_i" title="I">I</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_j" title="J">J</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_k" title="K">K</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_l" title="L">L</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_m" title="M">M</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_n" title="N">N</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_o" title="O">O</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_p" title="P">P</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_q" title="Q">Q</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_r" title="R">R</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_s" title="S">S</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_t" title="T">T</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_u" title="U">U</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_v" title="V">V</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_w" title="W">W</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_x" title="X">X</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_y" title="Y">Y</button>
<button type="button" autofocus="autofocus" class="oe_filter_label" id="filter_z" title="Z">z</button>
<button type="button" class="oe_filter_label" id="filter_a" title="A">A</button>
<button type="button" class="oe_filter_label" id="filter_b" title="B">B</button>
<button type="button" class="oe_filter_label" id="filter_c" title="C">C</button>
<button type="button" class="oe_filter_label" id="filter_d" title="D">D</button>
<button type="button" class="oe_filter_label" id="filter_e" title="E">E</button>
<button type="button" class="oe_filter_label" id="filter_f" title="F">F</button>
<button type="button" class="oe_filter_label" id="filter_g" title="G">G</button>
<button type="button" class="oe_filter_label" id="filter_h" title="H">H</button>
<button type="button" class="oe_filter_label" id="filter_i" title="I">I</button>
<button type="button" class="oe_filter_label" id="filter_j" title="J">J</button>
<button type="button" class="oe_filter_label" id="filter_k" title="K">K</button>
<button type="button" class="oe_filter_label" id="filter_l" title="L">L</button>
<button type="button" class="oe_filter_label" id="filter_m" title="M">M</button>
<button type="button" class="oe_filter_label" id="filter_n" title="N">N</button>
<button type="button" class="oe_filter_label" id="filter_o" title="O">O</button>
<button type="button" class="oe_filter_label" id="filter_p" title="P">P</button>
<button type="button" class="oe_filter_label" id="filter_q" title="Q">Q</button>
<button type="button" class="oe_filter_label" id="filter_r" title="R">R</button>
<button type="button" class="oe_filter_label" id="filter_s" title="S">S</button>
<button type="button" class="oe_filter_label" id="filter_t" title="T">T</button>
<button type="button" class="oe_filter_label" id="filter_u" title="U">U</button>
<button type="button" class="oe_filter_label" id="filter_v" title="V">V</button>
<button type="button" class="oe_filter_label" id="filter_w" title="W">W</button>
<button type="button" class="oe_filter_label" id="filter_x" title="X">X</button>
<button type="button" class="oe_filter_label" id="filter_y" title="Y">Y</button>
<button type="button" class="oe_filter_label" id="filter_z" title="Z">Z</button>
</th>
</tr>
</table>

11
web_search_alphabetic/views/template.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="assets_backend" name="web_search assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/web_search_alphabetic/static/src/css/web_search.css"/>
<script type="text/javascript" src="/web_search_alphabetic/static/src/js/web_search.js"></script>
</xpath>
</template>
</data>
</odoo>
Loading…
Cancel
Save