diff --git a/web_widget_many2many_tags_multi_selection/README.rst b/web_widget_many2many_tags_multi_selection/README.rst index 8dd0c571..7d9792a8 100644 --- a/web_widget_many2many_tags_multi_selection/README.rst +++ b/web_widget_many2many_tags_multi_selection/README.rst @@ -1,3 +1,8 @@ +.. 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 ================================================== @@ -5,41 +10,49 @@ In a many2many_tags widget when a lot of entries should be selected it's fastidi This module adds a checkbox to this list so multiple entries can be selected at once. -Installation -============ -It was tested on Odoo 10.0 branch. +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 smashing it by providing a detailed and welcomed feedback -`here `_. +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. -Credits -======= +Images +------ -Akretion +* 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:: http://odoo-community.org/logo.png +.. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: http://odoo-community.org + :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. +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. diff --git a/web_widget_many2many_tags_multi_selection/__init__.py b/web_widget_many2many_tags_multi_selection/__init__.py index 56bc1ffd..ef5ae358 100644 --- a/web_widget_many2many_tags_multi_selection/__init__.py +++ b/web_widget_many2many_tags_multi_selection/__init__.py @@ -1,20 +1 @@ -# -*- 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 . -# -############################################################################## +# 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 index 4fd84839..301d0a45 100644 --- a/web_widget_many2many_tags_multi_selection/__manifest__.py +++ b/web_widget_many2many_tags_multi_selection/__manifest__.py @@ -1,27 +1,8 @@ -# -*- 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 . -# -############################################################################## +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { 'name': 'Tags multiple selection', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'author': 'Akretion, Odoo Community Association (OCA), Jamin Shah', 'depends': [ 'web', @@ -31,6 +12,7 @@ '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/static/src/js/view_form.js b/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js index c432ef96..81b21873 100644 --- 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 @@ -1,39 +1,41 @@ odoo.define('web_widget_many2many_tags_multi_selection.multiple_tags', function (require) { "use strict"; - var FormCommon = require('web.form_common'); + var rel_fields = require('web.relational_fields'); + var dialogs = require('web.view_dialogs'); var core = require('web.core'); - var data = require('web.data'); var _t = core._t; - FormCommon.CompletionFieldMixin._search_create_popup = function(view, ids, context) { - var self = this; - new FormCommon.SelectCreateDialog(this, { - res_model: self.field.relation, - domain: self.build_domain(), - context: new data.CompoundContext(self.build_context(), context || {}), - 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', - on_selected: function(element_ids) { - for(var i=0, len=element_ids.length; i 0) { - domain = new data.CompoundDomain(domain, ["!", ["id", "in", selected_ids]]); + // 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(); + }, + }); });