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..7d9792a8 --- /dev/null +++ b/web_widget_many2many_tags_multi_selection/README.rst @@ -0,0 +1,58 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +================================================== +Allows multiple selection on 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. + + +Configuration +============= + +After installation, the behavior of all fields using the 'many2many_tags' widget will be changed automatically. + + + +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 smash it by providing detailed and welcomed feedback. + + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Sylvain Calador +* Jamin Shah +* Maxence Groine + +Do not contact contributors directly about support or help with technical issues. + + +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. diff --git a/web_widget_many2many_tags_multi_selection/__init__.py b/web_widget_many2many_tags_multi_selection/__init__.py new file mode 100644 index 00000000..ef5ae358 --- /dev/null +++ b/web_widget_many2many_tags_multi_selection/__init__.py @@ -0,0 +1 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). diff --git a/web_widget_many2many_tags_multi_selection/__manifest__.py b/web_widget_many2many_tags_multi_selection/__manifest__.py new file mode 100644 index 00000000..301d0a45 --- /dev/null +++ b/web_widget_many2many_tags_multi_selection/__manifest__.py @@ -0,0 +1,18 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + 'name': 'Tags multiple selection', + 'version': '11.0.1.0.0', + 'author': 'Akretion, Odoo Community Association (OCA), Jamin Shah', + 'depends': [ + 'web', + ], + 'demo': [], + 'website': 'https://www.akretion.com', + 'data': [ + 'views/web_widget_many2many_tags_multi_selection.xml', + ], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, +} diff --git a/web_widget_many2many_tags_multi_selection/i18n/lt.po b/web_widget_many2many_tags_multi_selection/i18n/lt.po new file mode 100644 index 00000000..f0631caa --- /dev/null +++ b/web_widget_many2many_tags_multi_selection/i18n/lt.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_widget_many2many_tags_multi_selection +# +# Translators: +# Viktoras Norkus , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-25 01:58+0000\n" +"PO-Revision-Date: 2018-01-25 01:58+0000\n" +"Last-Translator: Viktoras Norkus , 2018\n" +"Language-Team: Lithuanian (https://www.transifex.com/oca/teams/23907/lt/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: lt\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#. module: web_widget_many2many_tags_multi_selection +#. openerp-web +#: code:addons/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js:15 +#, python-format +msgid "Create: " +msgstr "Sukurti:" + +#. module: web_widget_many2many_tags_multi_selection +#. openerp-web +#: code:addons/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js:15 +#, python-format +msgid "Search: " +msgstr "Ieškoti:" diff --git a/web_widget_many2many_tags_multi_selection/i18n/nl_NL.po b/web_widget_many2many_tags_multi_selection/i18n/nl_NL.po new file mode 100644 index 00000000..17fd4b5c --- /dev/null +++ b/web_widget_many2many_tags_multi_selection/i18n/nl_NL.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_widget_many2many_tags_multi_selection +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 03:50+0000\n" +"PO-Revision-Date: 2018-01-03 03:50+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: nl_NL\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: web_widget_many2many_tags_multi_selection +#. openerp-web +#: code:addons/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js:15 +#, python-format +msgid "Create: " +msgstr "Aanmaken:" + +#. module: web_widget_many2many_tags_multi_selection +#. openerp-web +#: code:addons/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js:15 +#, python-format +msgid "Search: " +msgstr "Zoeken:" diff --git a/web_widget_many2many_tags_multi_selection/i18n/pt_BR.po b/web_widget_many2many_tags_multi_selection/i18n/pt_BR.po new file mode 100644 index 00000000..d3b2e433 --- /dev/null +++ b/web_widget_many2many_tags_multi_selection/i18n/pt_BR.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_widget_many2many_tags_multi_selection +# +# Translators: +# Rodrigo de Almeida Sottomaior Macedo , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-22 08:27+0000\n" +"PO-Revision-Date: 2017-06-22 08:27+0000\n" +"Last-Translator: Rodrigo de Almeida Sottomaior Macedo , 2017\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: web_widget_many2many_tags_multi_selection +#. openerp-web +#: code:addons/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js:15 +#, python-format +msgid "Create: " +msgstr "Criado:" + +#. module: web_widget_many2many_tags_multi_selection +#. openerp-web +#: code:addons/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js:15 +#, python-format +msgid "Search: " +msgstr "Pesquisa:" diff --git a/web_widget_many2many_tags_multi_selection/static/description/icon.png b/web_widget_many2many_tags_multi_selection/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/web_widget_many2many_tags_multi_selection/static/description/icon.png differ diff --git a/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js b/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js new file mode 100644 index 00000000..81b21873 --- /dev/null +++ b/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js @@ -0,0 +1,41 @@ +odoo.define('web_widget_many2many_tags_multi_selection.multiple_tags', function (require) { + "use strict"; + + var rel_fields = require('web.relational_fields'); + var dialogs = require('web.view_dialogs'); + var core = require('web.core'); + var _t = core._t; + + rel_fields.FieldMany2One.include({ + _searchCreatePopup: function(view, ids, context) { + var self = this; + + // Don't include already selected instances in the search domain + var domain = self.record.getDomain({fieldName: self.name}); + if (self.field.type === 'many2many') { + var selected_ids = self._getSearchBlacklist(); + if (selected_ids.length > 0) { + domain.push(['id', 'not in', selected_ids]); + } + } + + new dialogs.SelectCreateDialog(self, _.extend({}, self.nodeOptions, { + res_model: self.field.relation, + domain: domain, + context: _.extend({}, self.record.getContext(self.recordParams), context || {}), + title: (view === 'search' ? _t("Search: ") : _t("Create: ")) + self.string, + initial_ids: ids ? _.map(ids, function(x) {return x[0];}) : undefined, + initial_view: view, + disable_multiple_selection: self.field.type !== 'many2many', + on_selected: function(records) { + if (self.field.type !== 'many2many') { + self.reinitialize(records[0]); + } else { + self.reinitialize(records); + } + self.activate(); + } + })).open(); + }, + }); +}); 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..b542560e --- /dev/null +++ b/web_widget_many2many_tags_multi_selection/views/web_widget_many2many_tags_multi_selection.xml @@ -0,0 +1,8 @@ + + + +