From bd8abd2bb83d09514df7b09cca627ea126606a1c Mon Sep 17 00:00:00 2001 From: Sylvain Calador Date: Thu, 23 Apr 2015 17:43:35 +0200 Subject: [PATCH 1/7] [IMP] Add 'web_completion_search' module --- web_completion_search/__init__.py | 20 ++++++++++ web_completion_search/__openerp__.py | 36 ++++++++++++++++++ .../static/src/js/view_form.js | 38 +++++++++++++++++++ .../views/web_completion_search.xml | 10 +++++ 4 files changed, 104 insertions(+) create mode 100644 web_completion_search/__init__.py create mode 100644 web_completion_search/__openerp__.py create mode 100644 web_completion_search/static/src/js/view_form.js create mode 100644 web_completion_search/views/web_completion_search.xml diff --git a/web_completion_search/__init__.py b/web_completion_search/__init__.py new file mode 100644 index 00000000..56bc1ffd --- /dev/null +++ b/web_completion_search/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2015-TODAY Akretion (). +# +# 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 . +# +############################################################################## diff --git a/web_completion_search/__openerp__.py b/web_completion_search/__openerp__.py new file mode 100644 index 00000000..5c14b2b9 --- /dev/null +++ b/web_completion_search/__openerp__.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2015-TODAY Akretion (). +# +# 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 completion_search', + 'version': '0.1', + 'author': 'Akretion, Odoo Community Association (OCA)', + 'depends': [ + 'web', + ], + 'demo': [], + 'website': 'https://www.akretion.com', + 'data': [ + 'views/web_completion_search.xml', + ], + 'installable': True, + 'auto_install': False, +} diff --git a/web_completion_search/static/src/js/view_form.js b/web_completion_search/static/src/js/view_form.js new file mode 100644 index 00000000..43df8395 --- /dev/null +++ b/web_completion_search/static/src/js/view_form.js @@ -0,0 +1,38 @@ +openerp.web_completion_search = function(instance, local) { + var _t = instance.web._t; + + + instance.web.form.CompletionFieldMixin.init = function() { + if (this.field.type == 'many2many') { + this.limit = 0; + } else { + this.limit = 7; + } + this.orderer = new instance.web.DropMisordered(); + }; + + instance.web.form.CompletionFieldMixin._search_create_popup = function(view, ids, context) { + var self = this; + var pop = new instance.web.form.SelectCreatePopup(this); + pop.select_element( + self.field.relation, + { + title: (view === 'search' ? _t("Search: ") : _t("Create: ")) + this.string, + initial_ids: ids ? _.map(ids, function(x) {return x[0];}) : undefined, + initial_view: view, + disable_multiple_selection: this.field.type != 'many2many', + }, + self.build_domain(), + new instance.web.CompoundContext(self.build_context(), context || {}) + ); + pop.on("elements_selected", self, function(element_ids) { + for(var i=0, len=element_ids.length; i + + + + + From 4cab02c5cdd41661c4e081b759976749bd11eac7 Mon Sep 17 00:00:00 2001 From: Sylvain Calador Date: Thu, 23 Apr 2015 18:51:10 +0200 Subject: [PATCH 2/7] [IMP] Makes 'many2many_tags' search box shows only unselected items --- web_completion_search/static/src/js/view_form.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web_completion_search/static/src/js/view_form.js b/web_completion_search/static/src/js/view_form.js index 43df8395..d7340a69 100644 --- a/web_completion_search/static/src/js/view_form.js +++ b/web_completion_search/static/src/js/view_form.js @@ -14,6 +14,15 @@ openerp.web_completion_search = function(instance, local) { instance.web.form.CompletionFieldMixin._search_create_popup = function(view, ids, context) { var self = this; var pop = new instance.web.form.SelectCreatePopup(this); + var domain = self.build_domain(); + + if (self.field.type == 'many2many') { + var selected_ids =self.get_search_blacklist(); + if (selected_ids.length > 0) { + domain = new instance.web.CompoundDomain(domain, ["!", ["id", "in", selected_ids]]); + } + } + pop.select_element( self.field.relation, { @@ -22,7 +31,7 @@ openerp.web_completion_search = function(instance, local) { initial_view: view, disable_multiple_selection: this.field.type != 'many2many', }, - self.build_domain(), + domain, new instance.web.CompoundContext(self.build_context(), context || {}) ); pop.on("elements_selected", self, function(element_ids) { From a57e4ff93bc76d4b6966de8ccd5d544465a3fc31 Mon Sep 17 00:00:00 2001 From: Sylvain Calador Date: Wed, 29 Apr 2015 16:50:56 +0200 Subject: [PATCH 3/7] [IMP] Avoid to hide selection list if there are less than 7 options --- web_completion_search/static/src/js/view_form.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/web_completion_search/static/src/js/view_form.js b/web_completion_search/static/src/js/view_form.js index d7340a69..a84b91fd 100644 --- a/web_completion_search/static/src/js/view_form.js +++ b/web_completion_search/static/src/js/view_form.js @@ -1,16 +1,6 @@ openerp.web_completion_search = function(instance, local) { var _t = instance.web._t; - - instance.web.form.CompletionFieldMixin.init = function() { - if (this.field.type == 'many2many') { - this.limit = 0; - } else { - this.limit = 7; - } - this.orderer = new instance.web.DropMisordered(); - }; - instance.web.form.CompletionFieldMixin._search_create_popup = function(view, ids, context) { var self = this; var pop = new instance.web.form.SelectCreatePopup(this); From e45a2980123131d8674bf56592184551880fedae Mon Sep 17 00:00:00 2001 From: Sylvain Calador Date: Wed, 29 Apr 2015 17:19:27 +0200 Subject: [PATCH 4/7] [REF] Rename the module with a more explict name --- web_completion_search/views/web_completion_search.xml | 10 ---------- .../__init__.py | 0 .../__openerp__.py | 4 ++-- .../static/src/js/view_form.js | 3 ++- .../views/web_m2m_tags_multiple_selection.xml | 10 ++++++++++ 5 files changed, 14 insertions(+), 13 deletions(-) delete mode 100644 web_completion_search/views/web_completion_search.xml rename {web_completion_search => web_m2m_tags_multiple_selection}/__init__.py (100%) rename {web_completion_search => web_m2m_tags_multiple_selection}/__openerp__.py (92%) rename {web_completion_search => web_m2m_tags_multiple_selection}/static/src/js/view_form.js (95%) create mode 100644 web_m2m_tags_multiple_selection/views/web_m2m_tags_multiple_selection.xml diff --git a/web_completion_search/views/web_completion_search.xml b/web_completion_search/views/web_completion_search.xml deleted file mode 100644 index fcffc34b..00000000 --- a/web_completion_search/views/web_completion_search.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - diff --git a/web_completion_search/__init__.py b/web_m2m_tags_multiple_selection/__init__.py similarity index 100% rename from web_completion_search/__init__.py rename to web_m2m_tags_multiple_selection/__init__.py diff --git a/web_completion_search/__openerp__.py b/web_m2m_tags_multiple_selection/__openerp__.py similarity index 92% rename from web_completion_search/__openerp__.py rename to web_m2m_tags_multiple_selection/__openerp__.py index 5c14b2b9..6c5e3b63 100644 --- a/web_completion_search/__openerp__.py +++ b/web_m2m_tags_multiple_selection/__openerp__.py @@ -20,7 +20,7 @@ ############################################################################## { - 'name': 'Web completion_search', + 'name': 'Web many2many_tags multiple selection', 'version': '0.1', 'author': 'Akretion, Odoo Community Association (OCA)', 'depends': [ @@ -29,7 +29,7 @@ 'demo': [], 'website': 'https://www.akretion.com', 'data': [ - 'views/web_completion_search.xml', + 'views/web_m2m_tags_multiple_selection.xml', ], 'installable': True, 'auto_install': False, diff --git a/web_completion_search/static/src/js/view_form.js b/web_m2m_tags_multiple_selection/static/src/js/view_form.js similarity index 95% rename from web_completion_search/static/src/js/view_form.js rename to web_m2m_tags_multiple_selection/static/src/js/view_form.js index a84b91fd..fcd6b8ab 100644 --- a/web_completion_search/static/src/js/view_form.js +++ b/web_m2m_tags_multiple_selection/static/src/js/view_form.js @@ -1,4 +1,5 @@ -openerp.web_completion_search = function(instance, local) { +openerp.web_m2m_tags_multiple_selection = function(instance, local) { + var _t = instance.web._t; instance.web.form.CompletionFieldMixin._search_create_popup = function(view, ids, context) { diff --git a/web_m2m_tags_multiple_selection/views/web_m2m_tags_multiple_selection.xml b/web_m2m_tags_multiple_selection/views/web_m2m_tags_multiple_selection.xml new file mode 100644 index 00000000..bc2cabf7 --- /dev/null +++ b/web_m2m_tags_multiple_selection/views/web_m2m_tags_multiple_selection.xml @@ -0,0 +1,10 @@ + + + + + + From 83065124827298e2aff8188fc7480d166573433c Mon Sep 17 00:00:00 2001 From: Sylvain Calador Date: Thu, 30 Apr 2015 11:46:36 +0200 Subject: [PATCH 5/7] [REF] Rename the module according to the OCA naming convention --- .../views/web_m2m_tags_multiple_selection.xml | 10 ------ .../README.rst | 33 +++++++++++++++++++ .../__init__.py | 0 .../__openerp__.py | 4 +-- .../static/src/js/view_form.js | 4 +-- ..._widget_many2many_tags_multi_selection.xml | 10 ++++++ 6 files changed, 47 insertions(+), 14 deletions(-) delete mode 100644 web_m2m_tags_multiple_selection/views/web_m2m_tags_multiple_selection.xml create mode 100644 web_widget_many2many_tags_multi_selection/README.rst rename {web_m2m_tags_multiple_selection => web_widget_many2many_tags_multi_selection}/__init__.py (100%) rename {web_m2m_tags_multiple_selection => web_widget_many2many_tags_multi_selection}/__openerp__.py (91%) rename {web_m2m_tags_multiple_selection => web_widget_many2many_tags_multi_selection}/static/src/js/view_form.js (90%) create mode 100644 web_widget_many2many_tags_multi_selection/views/web_widget_many2many_tags_multi_selection.xml diff --git a/web_m2m_tags_multiple_selection/views/web_m2m_tags_multiple_selection.xml b/web_m2m_tags_multiple_selection/views/web_m2m_tags_multiple_selection.xml deleted file mode 100644 index bc2cabf7..00000000 --- a/web_m2m_tags_multiple_selection/views/web_m2m_tags_multiple_selection.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - diff --git a/web_widget_many2many_tags_multi_selection/README.rst b/web_widget_many2many_tags_multi_selection/README.rst new file mode 100644 index 00000000..697d7a40 --- /dev/null +++ b/web_widget_many2many_tags_multi_selection/README.rst @@ -0,0 +1,33 @@ +Allows multiple selection on many2many_tags widget +================================================== + +This module allows the user to select multiple entries through the search box in the case of the "many2many_tags" widget. + +Installation +============ + +It was tested on Odoo 8.0 branch. + +Credits +======= + +Akretion + +Contributors +------------ + +* Sylvain Calador + +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_m2m_tags_multiple_selection/__init__.py b/web_widget_many2many_tags_multi_selection/__init__.py similarity index 100% rename from web_m2m_tags_multiple_selection/__init__.py rename to web_widget_many2many_tags_multi_selection/__init__.py diff --git a/web_m2m_tags_multiple_selection/__openerp__.py b/web_widget_many2many_tags_multi_selection/__openerp__.py similarity index 91% rename from web_m2m_tags_multiple_selection/__openerp__.py rename to web_widget_many2many_tags_multi_selection/__openerp__.py index 6c5e3b63..b07382c3 100644 --- a/web_m2m_tags_multiple_selection/__openerp__.py +++ b/web_widget_many2many_tags_multi_selection/__openerp__.py @@ -20,7 +20,7 @@ ############################################################################## { - 'name': 'Web many2many_tags multiple selection', + 'name': 'web_widget_many2many_tags_multi_selection', 'version': '0.1', 'author': 'Akretion, Odoo Community Association (OCA)', 'depends': [ @@ -29,7 +29,7 @@ 'demo': [], 'website': 'https://www.akretion.com', 'data': [ - 'views/web_m2m_tags_multiple_selection.xml', + 'views/web_widget_many2many_tags_multi_selection.xml', ], 'installable': True, 'auto_install': False, diff --git a/web_m2m_tags_multiple_selection/static/src/js/view_form.js b/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js similarity index 90% rename from web_m2m_tags_multiple_selection/static/src/js/view_form.js rename to web_widget_many2many_tags_multi_selection/static/src/js/view_form.js index fcd6b8ab..1d073fe6 100644 --- a/web_m2m_tags_multiple_selection/static/src/js/view_form.js +++ b/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js @@ -1,4 +1,4 @@ -openerp.web_m2m_tags_multiple_selection = function(instance, local) { +openerp.web_widget_many2many_tags_multi_selection = function(instance, local) { var _t = instance.web._t; @@ -8,7 +8,7 @@ openerp.web_m2m_tags_multiple_selection = function(instance, local) { var domain = self.build_domain(); if (self.field.type == 'many2many') { - var selected_ids =self.get_search_blacklist(); + var selected_ids = self.get_search_blacklist(); if (selected_ids.length > 0) { domain = new instance.web.CompoundDomain(domain, ["!", ["id", "in", selected_ids]]); } diff --git a/web_widget_many2many_tags_multi_selection/views/web_widget_many2many_tags_multi_selection.xml b/web_widget_many2many_tags_multi_selection/views/web_widget_many2many_tags_multi_selection.xml new file mode 100644 index 00000000..0b475748 --- /dev/null +++ b/web_widget_many2many_tags_multi_selection/views/web_widget_many2many_tags_multi_selection.xml @@ -0,0 +1,10 @@ + + + + + + From db1c966807b52ae306a980bfd9ad171fd16461b2 Mon Sep 17 00:00:00 2001 From: Sylvain Calador Date: Fri, 1 May 2015 13:46:50 +0200 Subject: [PATCH 6/7] [IMP] README.rst: more explicative description --- web_widget_many2many_tags_multi_selection/README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web_widget_many2many_tags_multi_selection/README.rst b/web_widget_many2many_tags_multi_selection/README.rst index 697d7a40..4d2b3ea3 100644 --- a/web_widget_many2many_tags_multi_selection/README.rst +++ b/web_widget_many2many_tags_multi_selection/README.rst @@ -1,7 +1,9 @@ Allows multiple selection on many2many_tags widget ================================================== -This module allows the user to select multiple entries through the search box in the case of the "many2many_tags" widget. +In a many2many_tags widget when a lot of entries should be selected it's fastidious to select 80% of them. Then you may click on 'search more', but impossible to select several attributes at once. + +This module adds a checkbox to this list so multiple entries can be selected at once. Installation ============ From 27afb702d81313db9f972b9ab91608fafb77bc56 Mon Sep 17 00:00:00 2001 From: Sylvain Calador Date: Tue, 5 May 2015 09:32:13 +0200 Subject: [PATCH 7/7] [IMP] better module name --- web_widget_many2many_tags_multi_selection/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_widget_many2many_tags_multi_selection/__openerp__.py b/web_widget_many2many_tags_multi_selection/__openerp__.py index b07382c3..4bf59acd 100644 --- a/web_widget_many2many_tags_multi_selection/__openerp__.py +++ b/web_widget_many2many_tags_multi_selection/__openerp__.py @@ -20,7 +20,7 @@ ############################################################################## { - 'name': 'web_widget_many2many_tags_multi_selection', + 'name': 'Tags multiple selection', 'version': '0.1', 'author': 'Akretion, Odoo Community Association (OCA)', 'depends': [