mirror of https://github.com/OCA/web.git
commit
036b986bdd
|
@ -0,0 +1,46 @@
|
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:alt: License: AGPL-3
|
||||
|
||||
Use AND conditions on omnibar search
|
||||
====================================
|
||||
|
||||
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 omnibar search field
|
||||
* Press and hold Shift key
|
||||
* Select field with mouse or keyboard to perform search on
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Andrius Preimantas <andrius@versada.lt>
|
||||
|
||||
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.
|
|
@ -0,0 +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.
|
|
@ -0,0 +1,20 @@
|
|||
# -*- 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': "Use AND conditions on omnibar search",
|
||||
'version': '1.0',
|
||||
'author': 'Versada UAB, Odoo Community Association (OCA)',
|
||||
'category': 'web',
|
||||
'website': 'http://www.versada.lt',
|
||||
'description': "",
|
||||
'depends': [
|
||||
'web',
|
||||
],
|
||||
'data': [
|
||||
'data.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'application': False,
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="assets_backend" name="web_view_editor assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/web_search_with_and/static/src/js/search.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
|
@ -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);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue