From 71210c651b3ea6d674f18b118c8f92511cd66ce6 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 9 Dec 2015 21:30:36 +0100 Subject: [PATCH 01/11] [ADD] web_search_autocomplete_prefetch --- web_search_autocomplete_prefetch/README.rst | 64 +++++++++++++ web_search_autocomplete_prefetch/__init__.py | 3 + .../__openerp__.py | 21 +++++ .../web_search_autocomplete_prefetch.png | Bin 0 -> 9767 bytes .../static/description/icon.png | Bin 0 -> 9455 bytes .../js/web_search_autocomplete_prefetch.js | 87 ++++++++++++++++++ .../views/templates.xml | 10 ++ 7 files changed, 185 insertions(+) create mode 100644 web_search_autocomplete_prefetch/README.rst create mode 100644 web_search_autocomplete_prefetch/__init__.py create mode 100644 web_search_autocomplete_prefetch/__openerp__.py create mode 100644 web_search_autocomplete_prefetch/images/web_search_autocomplete_prefetch.png create mode 100644 web_search_autocomplete_prefetch/static/description/icon.png create mode 100644 web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js create mode 100644 web_search_autocomplete_prefetch/views/templates.xml diff --git a/web_search_autocomplete_prefetch/README.rst b/web_search_autocomplete_prefetch/README.rst new file mode 100644 index 00000000..11956759 --- /dev/null +++ b/web_search_autocomplete_prefetch/README.rst @@ -0,0 +1,64 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +============================ +Prefetch autocomplete offers +============================ + +When searching, the autocomplete options can be a bit frustrating because you +will be offered choices that won't yield a result. This addon searches for the +term in the background and only offers an option if this search has a result. + +Usage +===== + +* go to ... +.. 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/8.0 + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + +* some searches (especially via function fields) can be very heavy on the + server. + + To disable prefetching on a per field basis, set the option + `web_search_autocomplete_prefetch.disable`:: + options="{'web_search_autocomplete_prefetch.disable': true}" + on your field in the search view. + +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 +`here `_. + +Credits +======= + +Contributors +------------ + +* Holger Brunn + +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 http://odoo-community.org. diff --git a/web_search_autocomplete_prefetch/__init__.py b/web_search_autocomplete_prefetch/__init__.py new file mode 100644 index 00000000..6d9656f1 --- /dev/null +++ b/web_search_autocomplete_prefetch/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# © 2015 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/web_search_autocomplete_prefetch/__openerp__.py b/web_search_autocomplete_prefetch/__openerp__.py new file mode 100644 index 00000000..e12afde7 --- /dev/null +++ b/web_search_autocomplete_prefetch/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# © 2015 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Prefetch autocomplete offers", + "version": "8.0.1.0.0", + "author": "Therp BV,Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Usability", + "summary": "Offer only items on autocompletion that will yield results", + "depends": [ + 'web', + ], + "images": [ + 'images/web_search_autocomplete_prefetch.png', + ], + "data": [ + 'views/templates.xml', + ], + "installable": True, +} diff --git a/web_search_autocomplete_prefetch/images/web_search_autocomplete_prefetch.png b/web_search_autocomplete_prefetch/images/web_search_autocomplete_prefetch.png new file mode 100644 index 0000000000000000000000000000000000000000..a1ab7db8e9873905da864737ca315d6f6029b804 GIT binary patch literal 9767 zcmZv?2Q*yY_dYBINwf$Fq7y`k5?z!JQKN^bgG7zqTeL(E(IV<-LG%#469l8TgpA(% z7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3x%p$Ti?c7U!1dw3Ku(jb9kg}zK{OZ zaUySGYYy&Gp@$6#Nn;zi6&2TOr)YN*O~COPu%LSnA5N|t2LB-(b8i&*CmpZMxSjg{ zbOg^xecH@y?nm}d3PN6=OS9qW|BKSAJ+82aj90ILXX}ILP}OfSyZ+MiY9{r(`frvs z!`pOMla2Q-E^<5<<{|?wfLl9=?PVw4H?O99#erY=_{7YgU|stxpc!KD Wu&H@t9Gu_6QIb=WEtPp4`2PSsrfPuz literal 0 HcmV?d00001 diff --git a/web_search_autocomplete_prefetch/static/description/icon.png b/web_search_autocomplete_prefetch/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH zG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E4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js new file mode 100644 index 00000000..cb95220e --- /dev/null +++ b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js @@ -0,0 +1,87 @@ +//-*- coding: utf-8 -*- +//© 2015 Therp BV +//License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +openerp.web_search_autocomplete_prefetch = function(instance) +{ + // overwrite this or use it to recycle the functionality for your own field + openerp.web_search_autocomplete_prefetch.complete = function(self, value, data) + { + if(self.options['web_search_autocomplete_prefetch.disable']) + { + return data; + } + var facet = { + get: function(name) + { + switch(name) + { + case 'value': return value; + case 'operator': return 'ilike'; + } + }, + }, + domain = new instance.web.CompoundDomain( + self.get_domain({values: [facet]}), + self.view.dataset.domain); + domain.set_eval_context(self.view.dataset.get_context()); + return self.view.dataset._model.call( + 'search_count', [domain.eval()]) + .then(function(count) + { + if(count) + { + _.each(data, function(obj) + { + obj.label += _.str.sprintf(' (%s)', count); + }); + return data; + } + else + { + return null; + } + }); + } + + instance.web.search.CharField.include({ + init: function() + { + var result = this._super.apply(this, arguments); + this.options = instance.web.py_eval(this.attrs.options || '{}'); + return result; + }, + complete: function(value) + { + var self = this; + return this._super.apply(this, arguments).then(function(data) + { + return openerp.web_search_autocomplete_prefetch.complete( + self, value, data); + }); + } + }); + + instance.web.search.ManyToOneField.include({ + complete: function(value) + { + var self = this; + return this._super.apply(this, arguments).then(function(data) + { + return openerp.web_search_autocomplete_prefetch.complete( + self, value, data); + }); + } + }); + + instance.web.search.AutoComplete.include({ + select_item: function() + { + if(!this.current_result) + { + return; + } + return this._super.apply(this, arguments); + }, + }); +} diff --git a/web_search_autocomplete_prefetch/views/templates.xml b/web_search_autocomplete_prefetch/views/templates.xml new file mode 100644 index 00000000..624c099d --- /dev/null +++ b/web_search_autocomplete_prefetch/views/templates.xml @@ -0,0 +1,10 @@ + + + + + + From fac5e8873aabfc21a8eb00fe685922e30d95a294 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 14 Dec 2015 19:52:21 +0100 Subject: [PATCH 02/11] [IMP] synchronize searches --- .../js/web_search_autocomplete_prefetch.js | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js index cb95220e..ae663510 100644 --- a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js +++ b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js @@ -11,6 +11,10 @@ openerp.web_search_autocomplete_prefetch = function(instance) { return data; } + if(!self.autocomplete_mutex) + { + self.autocomplete_mutex = new instance.Mutex() + } var facet = { get: function(name) { @@ -25,23 +29,26 @@ openerp.web_search_autocomplete_prefetch = function(instance) self.get_domain({values: [facet]}), self.view.dataset.domain); domain.set_eval_context(self.view.dataset.get_context()); - return self.view.dataset._model.call( - 'search_count', [domain.eval()]) - .then(function(count) - { - if(count) + return self.autocomplete_mutex.exec(function() + { + return self.view.dataset._model.call( + 'search_count', [domain.eval()]) + .then(function(count) { - _.each(data, function(obj) + if(count) { - obj.label += _.str.sprintf(' (%s)', count); - }); - return data; - } - else - { - return null; - } - }); + _.each(data, function(obj) + { + obj.label += _.str.sprintf(' (%s)', count); + }); + return data; + } + else + { + return null; + } + }); + }); } instance.web.search.CharField.include({ From b4bc88f747cc6e9536b2d554f2292bc27d22649d Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 21 Jan 2016 13:28:09 +0100 Subject: [PATCH 03/11] [FIX] link to https version of oca website --- web_search_autocomplete_prefetch/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_search_autocomplete_prefetch/README.rst b/web_search_autocomplete_prefetch/README.rst index 11956759..e8f8af57 100644 --- a/web_search_autocomplete_prefetch/README.rst +++ b/web_search_autocomplete_prefetch/README.rst @@ -61,4 +61,4 @@ 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. +To contribute to this module, please visit https://odoo-community.org. From 9766608c6f6a9c63689107c3156c88f13106f6e8 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 1 Feb 2016 17:58:48 +0100 Subject: [PATCH 04/11] [FIX] support self in domains --- .../static/src/js/web_search_autocomplete_prefetch.js | 1 + 1 file changed, 1 insertion(+) diff --git a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js index ae663510..b9f82588 100644 --- a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js +++ b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js @@ -20,6 +20,7 @@ openerp.web_search_autocomplete_prefetch = function(instance) { switch(name) { + case 'label': return value; case 'value': return value; case 'operator': return 'ilike'; } From 23b69e1bb05df65d6773b8fb614aed991b476325 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 16 May 2016 11:24:48 +0200 Subject: [PATCH 05/11] [FIX] pass dataset's context to search_count --- .../static/src/js/web_search_autocomplete_prefetch.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js index b9f82588..1ff401ef 100644 --- a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js +++ b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js @@ -33,7 +33,8 @@ openerp.web_search_autocomplete_prefetch = function(instance) return self.autocomplete_mutex.exec(function() { return self.view.dataset._model.call( - 'search_count', [domain.eval()]) + 'search_count', [domain.eval()], + {context: self.view.dataset.get_context()}) .then(function(count) { if(count) From b73f80a24df102201f8e2aacfef07ca68bc9142f Mon Sep 17 00:00:00 2001 From: lfreeke Date: Mon, 4 Jul 2016 12:13:13 +0200 Subject: [PATCH 06/11] [ADD] disable base_view search for better performance --- web_search_autocomplete_prefetch/__openerp__.py | 1 + .../views/base_view.xml | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 web_search_autocomplete_prefetch/views/base_view.xml diff --git a/web_search_autocomplete_prefetch/__openerp__.py b/web_search_autocomplete_prefetch/__openerp__.py index e12afde7..03db260a 100644 --- a/web_search_autocomplete_prefetch/__openerp__.py +++ b/web_search_autocomplete_prefetch/__openerp__.py @@ -16,6 +16,7 @@ ], "data": [ 'views/templates.xml', + 'views/base_view.xml', ], "installable": True, } diff --git a/web_search_autocomplete_prefetch/views/base_view.xml b/web_search_autocomplete_prefetch/views/base_view.xml new file mode 100644 index 00000000..2c6a9723 --- /dev/null +++ b/web_search_autocomplete_prefetch/views/base_view.xml @@ -0,0 +1,16 @@ + + + + + ir.ui.view + + + + + {'web_search_autocomplete_prefetch.disable': true} + + + + + + From 2aaab334cb32a8a14a8f714a438e5696175252ae Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sun, 28 Aug 2016 09:36:57 -0400 Subject: [PATCH 07/11] OCA Transbot updated translations from Transifex --- web_search_autocomplete_prefetch/i18n/es.po | 24 ++++++++++++++++++ web_search_autocomplete_prefetch/i18n/fi.po | 24 ++++++++++++++++++ web_search_autocomplete_prefetch/i18n/sl.po | 25 +++++++++++++++++++ web_search_autocomplete_prefetch/i18n/tr.po | 24 ++++++++++++++++++ .../i18n/web_search_autocomplete_prefetch.pot | 20 +++++++++++++++ 5 files changed, 117 insertions(+) create mode 100644 web_search_autocomplete_prefetch/i18n/es.po create mode 100644 web_search_autocomplete_prefetch/i18n/fi.po create mode 100644 web_search_autocomplete_prefetch/i18n/sl.po create mode 100644 web_search_autocomplete_prefetch/i18n/tr.po create mode 100644 web_search_autocomplete_prefetch/i18n/web_search_autocomplete_prefetch.pot diff --git a/web_search_autocomplete_prefetch/i18n/es.po b/web_search_autocomplete_prefetch/i18n/es.po new file mode 100644 index 00000000..cc7ecd45 --- /dev/null +++ b/web_search_autocomplete_prefetch/i18n/es.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_search_autocomplete_prefetch +# +# Translators: +# Pedro M. Baeza , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-26 01:59+0000\n" +"PO-Revision-Date: 2016-11-26 01:59+0000\n" +"Last-Translator: Pedro M. Baeza , 2016\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: web_search_autocomplete_prefetch +#: view:ir.ui.view:web_search_autocomplete_prefetch.view_view_search_autocomplete +msgid "{'web_search_autocomplete_prefetch.disable': true}" +msgstr "{'web_search_autocomplete_prefetch.disable': true}" diff --git a/web_search_autocomplete_prefetch/i18n/fi.po b/web_search_autocomplete_prefetch/i18n/fi.po new file mode 100644 index 00000000..0787833a --- /dev/null +++ b/web_search_autocomplete_prefetch/i18n/fi.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_search_autocomplete_prefetch +# +# Translators: +# Jarmo Kortetjärvi , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-26 01:59+0000\n" +"PO-Revision-Date: 2016-11-26 01:59+0000\n" +"Last-Translator: Jarmo Kortetjärvi , 2016\n" +"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"Language: fi\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: web_search_autocomplete_prefetch +#: view:ir.ui.view:web_search_autocomplete_prefetch.view_view_search_autocomplete +msgid "{'web_search_autocomplete_prefetch.disable': true}" +msgstr "{'web_search_autocomplete_prefetch.disable': true}" diff --git a/web_search_autocomplete_prefetch/i18n/sl.po b/web_search_autocomplete_prefetch/i18n/sl.po new file mode 100644 index 00000000..16196e36 --- /dev/null +++ b/web_search_autocomplete_prefetch/i18n/sl.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_search_autocomplete_prefetch +# +# Translators: +# Matjaž Mozetič , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-08-25 00:50+0000\n" +"PO-Revision-Date: 2016-08-25 00:50+0000\n" +"Last-Translator: Matjaž Mozetič , 2016\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" + +#. module: web_search_autocomplete_prefetch +#: view:ir.ui.view:web_search_autocomplete_prefetch.view_view_search_autocomplete +msgid "{'web_search_autocomplete_prefetch.disable': true}" +msgstr "{'web_search_autocomplete_prefetch.disable': true}" diff --git a/web_search_autocomplete_prefetch/i18n/tr.po b/web_search_autocomplete_prefetch/i18n/tr.po new file mode 100644 index 00000000..5ba7ed28 --- /dev/null +++ b/web_search_autocomplete_prefetch/i18n/tr.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_search_autocomplete_prefetch +# +# Translators: +# Ahmet Altinisik , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-29 03:45+0000\n" +"PO-Revision-Date: 2016-12-29 03:45+0000\n" +"Last-Translator: Ahmet Altinisik , 2016\n" +"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" +"Language: tr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: web_search_autocomplete_prefetch +#: view:ir.ui.view:web_search_autocomplete_prefetch.view_view_search_autocomplete +msgid "{'web_search_autocomplete_prefetch.disable': true}" +msgstr "{'web_search_autocomplete_prefetch.disable': true}" diff --git a/web_search_autocomplete_prefetch/i18n/web_search_autocomplete_prefetch.pot b/web_search_autocomplete_prefetch/i18n/web_search_autocomplete_prefetch.pot new file mode 100644 index 00000000..6e0dfc2e --- /dev/null +++ b/web_search_autocomplete_prefetch/i18n/web_search_autocomplete_prefetch.pot @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_search_autocomplete_prefetch +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: web_search_autocomplete_prefetch +#: view:ir.ui.view:web_search_autocomplete_prefetch.view_view_search_autocomplete +msgid "{'web_search_autocomplete_prefetch.disable': true}" +msgstr "" + From 21c2320dc4653a2e8f35f0bade1d26e5b5fd0893 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 1 May 2017 18:53:56 +0200 Subject: [PATCH 08/11] [ADD] search only a few milliseconds after a keypress --- .../src/js/web_search_autocomplete_prefetch.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js index 1ff401ef..4ae89e9f 100644 --- a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js +++ b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js @@ -84,6 +84,7 @@ openerp.web_search_autocomplete_prefetch = function(instance) }); instance.web.search.AutoComplete.include({ + keypress_timeout: 200, select_item: function() { if(!this.current_result) @@ -92,5 +93,18 @@ openerp.web_search_autocomplete_prefetch = function(instance) } return this._super.apply(this, arguments); }, + initiate_search: function(query) + { + var self = this, + _super = this._super, + last_timeout = null; + this.last_timeout = last_timeout = window.setTimeout(function() + { + if(self.last_timeout == last_timeout) + { + _super.apply(self, [query]); + } + }, this.keypress_timeout) + }, }); } From 149cd41302b5c4ff105ff210757eb834df6b3de9 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 1 May 2017 19:11:22 +0200 Subject: [PATCH 09/11] [IMP] slightly higher timeout --- .../static/src/js/web_search_autocomplete_prefetch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js index 4ae89e9f..99556afa 100644 --- a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js +++ b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js @@ -84,7 +84,7 @@ openerp.web_search_autocomplete_prefetch = function(instance) }); instance.web.search.AutoComplete.include({ - keypress_timeout: 200, + keypress_timeout: 350, select_item: function() { if(!this.current_result) From 55df4a57f671df0eb725f7c6d82df7845b237485 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Fri, 5 May 2017 12:05:02 +0200 Subject: [PATCH 10/11] [ADD] make prefetch timeout configurable --- web_search_autocomplete_prefetch/README.rst | 9 +++++++-- .../src/js/web_search_autocomplete_prefetch.js | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/web_search_autocomplete_prefetch/README.rst b/web_search_autocomplete_prefetch/README.rst index e8f8af57..88b25800 100644 --- a/web_search_autocomplete_prefetch/README.rst +++ b/web_search_autocomplete_prefetch/README.rst @@ -12,7 +12,6 @@ term in the background and only offers an option if this search has a result. Usage ===== -* go to ... .. 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/8.0 @@ -26,11 +25,17 @@ Known issues / Roadmap * some searches (especially via function fields) can be very heavy on the server. - To disable prefetching on a per field basis, set the option `web_search_autocomplete_prefetch.disable`:: + options="{'web_search_autocomplete_prefetch.disable': true}" + on your field in the search view. +* by default, the addon triggers a search 350 milliseconds after the last key + pess. If you want a different timeout, set the parameter + ``web_search_autocomplete_prefetch.keypress_timeout`` to the amount of + milliseconds you need as timeout. + Bug Tracker =========== diff --git a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js index 99556afa..1d34dde5 100644 --- a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js +++ b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js @@ -85,6 +85,23 @@ openerp.web_search_autocomplete_prefetch = function(instance) instance.web.search.AutoComplete.include({ keypress_timeout: 350, + start: function() + { + var self = this; + return jQuery.when( + this._super.apply(this, arguments), + new instance.web.Model('ir.config_parameter').call( + 'get_param', + [ + 'web_search_autocomplete_prefetch.keypress_timeout', + this.keypress_timeout + ] + ).then(function(keypress_timeout) + { + self.keypress_timeout = parseInt(keypress_timeout); + }) + ); + }, select_item: function() { if(!this.current_result) From e32cf8ba14a2a8b9a10117ae321e0dc223c14102 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 29 Aug 2018 14:51:13 +0200 Subject: [PATCH 11/11] [MIG] web_search_autocomplete_prefetch --- web_search_autocomplete_prefetch/README.rst | 70 ++- web_search_autocomplete_prefetch/__init__.py | 1 - .../{__openerp__.py => __manifest__.py} | 5 +- .../readme/CONFIGURE.rst | 12 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 3 + .../static/description/index.html | 419 ++++++++++++++++++ .../js/web_search_autocomplete_prefetch.js | 169 +++---- .../views/base_view.xml | 22 +- .../views/templates.xml | 16 +- 10 files changed, 593 insertions(+), 125 deletions(-) rename web_search_autocomplete_prefetch/{__openerp__.py => __manifest__.py} (81%) create mode 100644 web_search_autocomplete_prefetch/readme/CONFIGURE.rst create mode 100644 web_search_autocomplete_prefetch/readme/CONTRIBUTORS.rst create mode 100644 web_search_autocomplete_prefetch/readme/DESCRIPTION.rst create mode 100644 web_search_autocomplete_prefetch/static/description/index.html diff --git a/web_search_autocomplete_prefetch/README.rst b/web_search_autocomplete_prefetch/README.rst index 88b25800..0df604e0 100644 --- a/web_search_autocomplete_prefetch/README.rst +++ b/web_search_autocomplete_prefetch/README.rst @@ -1,27 +1,41 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License: AGPL-3 - ============================ Prefetch autocomplete offers ============================ +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/10.0/web_search_autocomplete_prefetch + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-10-0/web-10-0-web_search_autocomplete_prefetch + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/10.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + When searching, the autocomplete options can be a bit frustrating because you will be offered choices that won't yield a result. This addon searches for the term in the background and only offers an option if this search has a result. -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/8.0 - -For further information, please visit: +**Table of contents** -* https://www.odoo.com/forum/help-1 +.. contents:: + :local: -Known issues / Roadmap -====================== +Configuration +============= * some searches (especially via function fields) can be very heavy on the server. @@ -32,38 +46,46 @@ Known issues / Roadmap on your field in the search view. * by default, the addon triggers a search 350 milliseconds after the last key - pess. If you want a different timeout, set the parameter + press. If you want a different timeout, set the parameter ``web_search_autocomplete_prefetch.keypress_timeout`` to the amount of milliseconds you need as timeout. - 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 -`here `_. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Therp BV + Contributors ------------- +~~~~~~~~~~~~ * Holger Brunn -Maintainer ----------- +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. 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. +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_search_autocomplete_prefetch/__init__.py b/web_search_autocomplete_prefetch/__init__.py index 6d9656f1..94673b34 100644 --- a/web_search_autocomplete_prefetch/__init__.py +++ b/web_search_autocomplete_prefetch/__init__.py @@ -1,3 +1,2 @@ # -*- coding: utf-8 -*- -# © 2015 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/web_search_autocomplete_prefetch/__openerp__.py b/web_search_autocomplete_prefetch/__manifest__.py similarity index 81% rename from web_search_autocomplete_prefetch/__openerp__.py rename to web_search_autocomplete_prefetch/__manifest__.py index 03db260a..492421d2 100644 --- a/web_search_autocomplete_prefetch/__openerp__.py +++ b/web_search_autocomplete_prefetch/__manifest__.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- -# © 2015 Therp BV +# Copyright 2015-2018 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Prefetch autocomplete offers", - "version": "8.0.1.0.0", + "version": "10.0.1.0.0", "author": "Therp BV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web", "license": "AGPL-3", "category": "Usability", "summary": "Offer only items on autocompletion that will yield results", diff --git a/web_search_autocomplete_prefetch/readme/CONFIGURE.rst b/web_search_autocomplete_prefetch/readme/CONFIGURE.rst new file mode 100644 index 00000000..c56e2e8d --- /dev/null +++ b/web_search_autocomplete_prefetch/readme/CONFIGURE.rst @@ -0,0 +1,12 @@ +* some searches (especially via function fields) can be very heavy on the + server. + To disable prefetching on a per field basis, set the option + `web_search_autocomplete_prefetch.disable`:: + + options="{'web_search_autocomplete_prefetch.disable': true}" + + on your field in the search view. +* by default, the addon triggers a search 350 milliseconds after the last key + press. If you want a different timeout, set the parameter + ``web_search_autocomplete_prefetch.keypress_timeout`` to the amount of + milliseconds you need as timeout. diff --git a/web_search_autocomplete_prefetch/readme/CONTRIBUTORS.rst b/web_search_autocomplete_prefetch/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..b120a956 --- /dev/null +++ b/web_search_autocomplete_prefetch/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Holger Brunn diff --git a/web_search_autocomplete_prefetch/readme/DESCRIPTION.rst b/web_search_autocomplete_prefetch/readme/DESCRIPTION.rst new file mode 100644 index 00000000..c6509e38 --- /dev/null +++ b/web_search_autocomplete_prefetch/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +When searching, the autocomplete options can be a bit frustrating because you +will be offered choices that won't yield a result. This addon searches for the +term in the background and only offers an option if this search has a result. diff --git a/web_search_autocomplete_prefetch/static/description/index.html b/web_search_autocomplete_prefetch/static/description/index.html new file mode 100644 index 00000000..0d1a5320 --- /dev/null +++ b/web_search_autocomplete_prefetch/static/description/index.html @@ -0,0 +1,419 @@ + + + + + + +Prefetch autocomplete offers + + + +
+

Prefetch autocomplete offers

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

When searching, the autocomplete options can be a bit frustrating because you +will be offered choices that won’t yield a result. This addon searches for the +term in the background and only offers an option if this search has a result.

+

Table of contents

+ +
+

Configuration

+
    +
  • some searches (especially via function fields) can be very heavy on the +server. +To disable prefetching on a per field basis, set the option +web_search_autocomplete_prefetch.disable:

    +
    +options="{'web_search_autocomplete_prefetch.disable': true}"
    +
    +

    on your field in the search view.

    +
  • +
  • by default, the addon triggers a search 350 milliseconds after the last key +press. If you want a different timeout, set the parameter +web_search_autocomplete_prefetch.keypress_timeout to the amount of +milliseconds you need as timeout.

    +
  • +
+
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Therp BV
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js index 1d34dde5..a4131e38 100644 --- a/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js +++ b/web_search_autocomplete_prefetch/static/src/js/web_search_autocomplete_prefetch.js @@ -1,127 +1,144 @@ //-*- coding: utf-8 -*- -//© 2015 Therp BV +//Copyright 2015-2018 Therp BV //License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +odoo.define('web_search_autocomplete_prefetch', function(require) { + var CompoundDomain = require('web.data').CompoundDomain, + Mutex = require('web.utils').Mutex; -openerp.web_search_autocomplete_prefetch = function(instance) -{ - // overwrite this or use it to recycle the functionality for your own field - openerp.web_search_autocomplete_prefetch.complete = function(self, value, data) - { - if(self.options['web_search_autocomplete_prefetch.disable']) - { + var complete = function(self, value, data) { + if(self.options['web_search_autocomplete_prefetch.disable']) { return data; } - if(!self.autocomplete_mutex) - { - self.autocomplete_mutex = new instance.Mutex() + if(!self.autocomplete_mutex) { + self.autocomplete_mutex = new Mutex(); } var facet = { - get: function(name) - { - switch(name) - { + get: function(name) { + switch(name) { case 'label': return value; case 'value': return value; case 'operator': return 'ilike'; } }, + attributes: { + value: value, + }, }, - domain = new instance.web.CompoundDomain( + domain = new CompoundDomain( self.get_domain({values: [facet]}), - self.view.dataset.domain); - domain.set_eval_context(self.view.dataset.get_context()); - return self.autocomplete_mutex.exec(function() - { - return self.view.dataset._model.call( + self.searchview.dataset.domain + ); + domain.set_eval_context(self.searchview.dataset.get_context()); + return self.autocomplete_mutex.exec(function() { + return self.searchview.dataset._model.call( 'search_count', [domain.eval()], - {context: self.view.dataset.get_context()}) - .then(function(count) - { - if(count) - { - _.each(data, function(obj) - { - obj.label += _.str.sprintf(' (%s)', count); - }); - return data; - } - else - { - return null; - } - }); + {context: self.searchview.dataset.get_context()} + ) + .then(function(count) { + if(count) { + _.each(data, function(obj) { + obj.label += _.str.sprintf(' (%s)', count); + }); + return data; + } + return null; + }); }); - } + }; - instance.web.search.CharField.include({ - init: function() - { + return { + // overwrite this or use it to recycle the functionality + // for your own field + complete: complete, + }; +}); + +odoo.define('web_search_autocomplete_prefetch.inputs', function(require) { + var AutoComplete = require('web.AutoComplete'), + Field = require('web.search_inputs').Field, + Model = require('web.Model'), + pyeval = require('web.pyeval'), + search_widgets_registry = require('web.core').search_widgets_registry, + web_search_autocomplete_prefetch = require( + 'web_search_autocomplete_prefetch' + ); + + Field.include({ + init: function() { var result = this._super.apply(this, arguments); - this.options = instance.web.py_eval(this.attrs.options || '{}'); + this.options = pyeval.py_eval(this.attrs.options || '{}'); return result; }, - complete: function(value) - { + }); + + search_widgets_registry.get('char').include({ + complete: function(value) { var self = this; - return this._super.apply(this, arguments).then(function(data) - { - return openerp.web_search_autocomplete_prefetch.complete( - self, value, data); + return this._super.apply(this, arguments).then(function(data) { + return web_search_autocomplete_prefetch.complete( + self, value, data + ); }); } }); - instance.web.search.ManyToOneField.include({ - complete: function(value) - { + search_widgets_registry.get('many2one').include({ + complete: function(value) { var self = this; - return this._super.apply(this, arguments).then(function(data) - { - return openerp.web_search_autocomplete_prefetch.complete( - self, value, data); + return this._super.apply(this, arguments).then(function(data) { + return web_search_autocomplete_prefetch.complete( + self, value, data + ); }); } }); - instance.web.search.AutoComplete.include({ + search_widgets_registry.get('selection').include({ + complete: function(value) { + var self = this; + return this._super.apply(this, arguments).then(function(data) { + return web_search_autocomplete_prefetch.complete( + self, value, data + ); + }); + } + }); + + AutoComplete.include({ keypress_timeout: 350, - start: function() - { + start: function() { var self = this; return jQuery.when( this._super.apply(this, arguments), - new instance.web.Model('ir.config_parameter').call( + new Model('ir.config_parameter').call( 'get_param', [ 'web_search_autocomplete_prefetch.keypress_timeout', this.keypress_timeout ] - ).then(function(keypress_timeout) - { - self.keypress_timeout = parseInt(keypress_timeout); + ).then(function(keypress_timeout) { + self.keypress_timeout = parseInt(keypress_timeout, 10); }) ); }, - select_item: function() - { - if(!this.current_result) - { + select_item: function() { + if(!this.current_result) { return; } return this._super.apply(this, arguments); }, - initiate_search: function(query) - { + initiate_search: function(query) { var self = this, _super = this._super, last_timeout = null; - this.last_timeout = last_timeout = window.setTimeout(function() - { - if(self.last_timeout == last_timeout) - { - _super.apply(self, [query]); - } - }, this.keypress_timeout) + this.last_timeout = last_timeout = window.setTimeout( + function() { + if(self.last_timeout === last_timeout) { + _super.apply(self, [query]); + } + }, + this.keypress_timeout + ); }, }); -} +}); diff --git a/web_search_autocomplete_prefetch/views/base_view.xml b/web_search_autocomplete_prefetch/views/base_view.xml index 2c6a9723..f5fd09bc 100644 --- a/web_search_autocomplete_prefetch/views/base_view.xml +++ b/web_search_autocomplete_prefetch/views/base_view.xml @@ -1,16 +1,12 @@ - - - - ir.ui.view - - - + + + ir.ui.view + + - {'web_search_autocomplete_prefetch.disable': true} + {'web_search_autocomplete_prefetch.disable': true} - - - - - + + + diff --git a/web_search_autocomplete_prefetch/views/templates.xml b/web_search_autocomplete_prefetch/views/templates.xml index 624c099d..8d4e89e5 100644 --- a/web_search_autocomplete_prefetch/views/templates.xml +++ b/web_search_autocomplete_prefetch/views/templates.xml @@ -1,10 +1,8 @@ - - - - - + + +