From 1f3ef8cc7a98445356f0da14d98a82f4941505f6 Mon Sep 17 00:00:00 2001 From: Andrius Preimantas Date: Mon, 27 Apr 2015 17:56:12 +0300 Subject: [PATCH 1/7] [INIT][web_search_with_and] --- web_search_with_and/__init__.py | 4 ++ web_search_with_and/__openerp__.py | 44 +++++++++++++++++++++ web_search_with_and/data.xml | 10 +++++ web_search_with_and/static/src/js/search.js | 43 ++++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 web_search_with_and/__init__.py create mode 100644 web_search_with_and/__openerp__.py create mode 100644 web_search_with_and/data.xml create mode 100644 web_search_with_and/static/src/js/search.js diff --git a/web_search_with_and/__init__.py b/web_search_with_and/__init__.py new file mode 100644 index 00000000..2fc5376b --- /dev/null +++ b/web_search_with_and/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# This file is part of OpenERP. The COPYRIGHT file at the top level of +# this module contains the full copyright notices and license terms. + diff --git a/web_search_with_and/__openerp__.py b/web_search_with_and/__openerp__.py new file mode 100644 index 00000000..5b873ea5 --- /dev/null +++ b/web_search_with_and/__openerp__.py @@ -0,0 +1,44 @@ +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2014 by UAB Versada (Ltd.) +# and contributors. See AUTHORS for more details. +# +# All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': "Force AND on Search Input", + 'version': '0.1', + 'author': 'Versada UAB, Odoo Community Association (OCA)', + 'category': 'web', + 'website': 'http://www.versada.lt', + 'description': """ +When searching on same field multiple times Odoo joins queries with OR. +Press Shift key to join them with AND. + +This gives the same affect as using Advanced Search on same field several times. + """, + 'depends': [ + 'web', + ], + 'data': [ + 'data.xml', + ], + 'installable': True, + 'application': False, +} diff --git a/web_search_with_and/data.xml b/web_search_with_and/data.xml new file mode 100644 index 00000000..a7842349 --- /dev/null +++ b/web_search_with_and/data.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/web_search_with_and/static/src/js/search.js b/web_search_with_and/static/src/js/search.js new file mode 100644 index 00000000..8c052e40 --- /dev/null +++ b/web_search_with_and/static/src/js/search.js @@ -0,0 +1,43 @@ +openerp.web_search_with_and = function (instance) { + + instance.web.SearchView = instance.web.SearchView.extend({ + select_completion: function (e, ui) { + var self = this; + if (e.shiftKey) { + e.preventDefault(); + + var input_index = _(this.input_subviews).indexOf( + this.subviewForRoot( + this.$('div.oe_searchview_input:focus')[0])); + this.query.add(ui.item.facet, {at: input_index / 2, shiftKey: true}); + } else { + this._super(e, ui); + } + }, + }); + + instance.web.search.SearchQuery = instance.web.search.SearchQuery.extend({ + add: function (values, options) { + + options = options || {}; + + if (!values) { + values = []; + } else if (!(values instanceof Array)) { + values = [values]; + } + + if (options.shiftKey) { + delete options.shiftKey; + _(values).each(function (value) { + var model = this._prepareModel(value, options); + Backbone.Collection.prototype.add.call(this, model, options); + }, this); + return this; + } + else { + return this.constructor.__super__.add.apply(this, arguments); + } + }, + }); +}; From 9d84b3ff8455c8e656cd9e6a9cc709adc74e2c46 Mon Sep 17 00:00:00 2001 From: Andrius Preimantas Date: Tue, 28 Apr 2015 10:11:31 +0300 Subject: [PATCH 2/7] [IMP] Add README.rst --- web_search_with_and/README.rst | 46 ++++++++++++++++++++++++++++++ web_search_with_and/__openerp__.py | 26 +++++++++++++---- 2 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 web_search_with_and/README.rst diff --git a/web_search_with_and/README.rst b/web_search_with_and/README.rst new file mode 100644 index 00000000..ec963eb1 --- /dev/null +++ b/web_search_with_and/README.rst @@ -0,0 +1,46 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Force AND on Search Input +=========== + +When searching for records on same field Odoo joins multiple queries with OR. +For example: + +* Perform a search for customer "John" on field Name +* Odoo displays customers containing "John" +* Search for "Smith" on same field Name +* Odoo displays customers containing "John" OR "Smith" + +With this module installed you can press Shift key before searching for "Smith" +and Odoo finds customers containing "John" AND "Smith" + +Usage +===== + +* Enter your value in Search Input field +* Press and hold Shift key +* Select field with mouse or keyboard to perform search on + +Credits +======= + +Contributors +------------ + +* Andrius Preimantas + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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 http://odoo-community.org. diff --git a/web_search_with_and/__openerp__.py b/web_search_with_and/__openerp__.py index 5b873ea5..64b0369d 100644 --- a/web_search_with_and/__openerp__.py +++ b/web_search_with_and/__openerp__.py @@ -1,8 +1,8 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2014 by UAB Versada (Ltd.) -# and contributors. See AUTHORS for more details. +# Copyright (C) 2015 by UAB Versada (Ltd.) +# and contributors. # # All Rights Reserved. # @@ -28,10 +28,26 @@ 'category': 'web', 'website': 'http://www.versada.lt', 'description': """ -When searching on same field multiple times Odoo joins queries with OR. -Press Shift key to join them with AND. +Force AND on Search Input +========================= -This gives the same affect as using Advanced Search on same field several times. +When searching for records on same field Odoo joins multiple queries with OR. +For example: + +* Perform a search for customer "John" on field Name +* Odoo displays customers containing "John" +* Search for "Smith" on same field Name +* Odoo displays customers containing "John" OR "Smith" + +With this module installed you can press Shift key before searching for "Smith" +and Odoo finds customers containing "John" AND "Smith" + +Usage +===== + +* Enter your value in Search Input field +* Press and hold Shift key +* Select field with mouse or keyboard to perform search on """, 'depends': [ 'web', From 063282c01172a4dcd0384b4b405511d98bc7edd3 Mon Sep 17 00:00:00 2001 From: Andrius Preimantas Date: Tue, 28 Apr 2015 10:16:25 +0300 Subject: [PATCH 3/7] [FIX] Too short underline for module title in README.rst --- web_search_with_and/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_search_with_and/README.rst b/web_search_with_and/README.rst index ec963eb1..474c99c4 100644 --- a/web_search_with_and/README.rst +++ b/web_search_with_and/README.rst @@ -2,7 +2,7 @@ :alt: License: AGPL-3 Force AND on Search Input -=========== +========================= When searching for records on same field Odoo joins multiple queries with OR. For example: From bdf27d6e0eac1488144a177a51f8951d1606c678 Mon Sep 17 00:00:00 2001 From: Andrius Preimantas Date: Tue, 28 Apr 2015 10:23:02 +0300 Subject: [PATCH 4/7] [IMP] Improving module meta information --- web_search_with_and/README.rst | 6 +++--- web_search_with_and/__openerp__.py | 30 ++++-------------------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/web_search_with_and/README.rst b/web_search_with_and/README.rst index 474c99c4..3d1daae3 100644 --- a/web_search_with_and/README.rst +++ b/web_search_with_and/README.rst @@ -1,8 +1,8 @@ .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg :alt: License: AGPL-3 -Force AND on Search Input -========================= +Use AND conditions on omnibar search +==================================== When searching for records on same field Odoo joins multiple queries with OR. For example: @@ -18,7 +18,7 @@ and Odoo finds customers containing "John" AND "Smith" Usage ===== -* Enter your value in Search Input field +* Enter your value in omnibar search field * Press and hold Shift key * Select field with mouse or keyboard to perform search on diff --git a/web_search_with_and/__openerp__.py b/web_search_with_and/__openerp__.py index 64b0369d..23ed1dbd 100644 --- a/web_search_with_and/__openerp__.py +++ b/web_search_with_and/__openerp__.py @@ -1,36 +1,14 @@ -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2015 by UAB Versada (Ltd.) -# and contributors. -# -# All Rights Reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# This file is part of OpenERP. The COPYRIGHT file at the top level of +# this module contains the full copyright notices and license terms. { - 'name': "Force AND on Search Input", + 'name': "Use AND conditions on omnibar search", 'version': '0.1', 'author': 'Versada UAB, Odoo Community Association (OCA)', 'category': 'web', 'website': 'http://www.versada.lt', 'description': """ -Force AND on Search Input -========================= - When searching for records on same field Odoo joins multiple queries with OR. For example: From cfb6b69ace6613fe723803914d1719be251b1faf Mon Sep 17 00:00:00 2001 From: Andrius Preimantas Date: Tue, 28 Apr 2015 10:24:35 +0300 Subject: [PATCH 5/7] [IMP] Version 1.0 --- web_search_with_and/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_search_with_and/__openerp__.py b/web_search_with_and/__openerp__.py index 23ed1dbd..8d8cbb98 100644 --- a/web_search_with_and/__openerp__.py +++ b/web_search_with_and/__openerp__.py @@ -4,7 +4,7 @@ { 'name': "Use AND conditions on omnibar search", - 'version': '0.1', + 'version': '1.0', 'author': 'Versada UAB, Odoo Community Association (OCA)', 'category': 'web', 'website': 'http://www.versada.lt', From ea9a2e30b243a91116caa34f762f04238bf30073 Mon Sep 17 00:00:00 2001 From: Andrius Preimantas Date: Wed, 29 Apr 2015 13:32:33 +0300 Subject: [PATCH 6/7] [FIX][flake8] W391 blank line at end of file --- web_search_with_and/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/web_search_with_and/__init__.py b/web_search_with_and/__init__.py index 2fc5376b..19ddd656 100644 --- a/web_search_with_and/__init__.py +++ b/web_search_with_and/__init__.py @@ -1,4 +1,3 @@ # -*- coding: utf-8 -*- # This file is part of OpenERP. The COPYRIGHT file at the top level of # this module contains the full copyright notices and license terms. - From 69af1776d7e5025b59a2120e7fc31c57bfc359af Mon Sep 17 00:00:00 2001 From: Andrius Preimantas Date: Thu, 14 May 2015 17:18:14 +0300 Subject: [PATCH 7/7] [FIX] Remove module description because README.rst is there --- web_search_with_and/__openerp__.py | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/web_search_with_and/__openerp__.py b/web_search_with_and/__openerp__.py index 8d8cbb98..effb170a 100644 --- a/web_search_with_and/__openerp__.py +++ b/web_search_with_and/__openerp__.py @@ -8,25 +8,7 @@ 'author': 'Versada UAB, Odoo Community Association (OCA)', 'category': 'web', 'website': 'http://www.versada.lt', - 'description': """ -When searching for records on same field Odoo joins multiple queries with OR. -For example: - -* Perform a search for customer "John" on field Name -* Odoo displays customers containing "John" -* Search for "Smith" on same field Name -* Odoo displays customers containing "John" OR "Smith" - -With this module installed you can press Shift key before searching for "Smith" -and Odoo finds customers containing "John" AND "Smith" - -Usage -===== - -* Enter your value in Search Input field -* Press and hold Shift key -* Select field with mouse or keyboard to perform search on - """, + 'description': "", 'depends': [ 'web', ],