mirror of https://github.com/OCA/web.git
[MIG] web_widget_many2many_tags_multi_selection: Migration to 11.0
parent
539c1f1129
commit
dc7ffce7cd
|
@ -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
|
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.
|
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
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
|
Bugs are tracked on `GitHub Issues
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
<https://github.com/OCA/web/issues>`_. In case of trouble, please
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
|
check there if your issue has already been reported. If you spotted it first,
|
||||||
`here <https://github.com/OCA/web/issues/new?body=module:%20web_widget_many2many_tags_multi_selection%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
help us smash it by providing detailed and welcomed feedback.
|
||||||
|
|
||||||
|
|
||||||
Credits
|
Images
|
||||||
=======
|
------
|
||||||
|
|
||||||
Akretion
|
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
|
||||||
|
|
||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Sylvain Calador <sylvain.calador@akretion.com>
|
* Sylvain Calador <sylvain.calador@akretion.com>
|
||||||
* Jamin Shah <jaiminshah2009@gmail.com>
|
* Jamin Shah <jaiminshah2009@gmail.com>
|
||||||
|
* Maxence Groine <mgroine@fiefmanage.ch>
|
||||||
|
|
||||||
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
|
||||||
.. image:: http://odoo-community.org/logo.png
|
.. image:: https://odoo-community.org/logo.png
|
||||||
:alt: Odoo Community Association
|
:alt: Odoo Community Association
|
||||||
:target: http://odoo-community.org
|
:target: https://odoo-community.org
|
||||||
|
|
||||||
This module is maintained by the OCA.
|
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.
|
||||||
|
|
|
@ -1,20 +1 @@
|
||||||
# -*- coding: utf-8 -*-
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.com>).
|
|
||||||
#
|
|
||||||
# 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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
|
@ -1,27 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.com>).
|
|
||||||
#
|
|
||||||
# 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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Tags multiple selection',
|
'name': 'Tags multiple selection',
|
||||||
'version': '10.0.1.0.0',
|
'version': '11.0.1.0.0',
|
||||||
'author': 'Akretion, Odoo Community Association (OCA), Jamin Shah',
|
'author': 'Akretion, Odoo Community Association (OCA), Jamin Shah',
|
||||||
'depends': [
|
'depends': [
|
||||||
'web',
|
'web',
|
||||||
|
@ -31,6 +12,7 @@
|
||||||
'data': [
|
'data': [
|
||||||
'views/web_widget_many2many_tags_multi_selection.xml',
|
'views/web_widget_many2many_tags_multi_selection.xml',
|
||||||
],
|
],
|
||||||
|
'license': 'AGPL-3',
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +1,41 @@
|
||||||
odoo.define('web_widget_many2many_tags_multi_selection.multiple_tags', function (require) {
|
odoo.define('web_widget_many2many_tags_multi_selection.multiple_tags', function (require) {
|
||||||
"use strict";
|
"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 core = require('web.core');
|
||||||
var data = require('web.data');
|
|
||||||
var _t = core._t;
|
var _t = core._t;
|
||||||
|
|
||||||
FormCommon.CompletionFieldMixin._search_create_popup = function(view, ids, context) {
|
rel_fields.FieldMany2One.include({
|
||||||
var self = this;
|
_searchCreatePopup: function(view, ids, context) {
|
||||||
new FormCommon.SelectCreateDialog(this, {
|
var self = this;
|
||||||
res_model: self.field.relation,
|
|
||||||
domain: self.build_domain(),
|
// Don't include already selected instances in the search domain
|
||||||
context: new data.CompoundContext(self.build_context(), context || {}),
|
var domain = self.record.getDomain({fieldName: self.name});
|
||||||
title: (view === 'search' ? _t("Search: ") : _t("Create: ")) + this.string,
|
if (self.field.type === 'many2many') {
|
||||||
initial_ids: ids ? _.map(ids, function(x) {return x[0];}) : undefined,
|
var selected_ids = self._getSearchBlacklist();
|
||||||
initial_view: view,
|
if (selected_ids.length > 0) {
|
||||||
disable_multiple_selection: this.field.type != 'many2many',
|
domain.push(['id', 'not in', selected_ids]);
|
||||||
on_selected: function(element_ids) {
|
|
||||||
for(var i=0, len=element_ids.length; i<len;i++) {
|
|
||||||
self.add_id(element_ids[i]);
|
|
||||||
if (self.field.type != 'many2many') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self.focus();
|
|
||||||
}
|
}
|
||||||
}).open();
|
|
||||||
var domain = self.build_domain();
|
|
||||||
|
|
||||||
if (self.field.type == 'many2many') {
|
new dialogs.SelectCreateDialog(self, _.extend({}, self.nodeOptions, {
|
||||||
var selected_ids = self.get_search_blacklist();
|
res_model: self.field.relation,
|
||||||
if (selected_ids.length > 0) {
|
domain: domain,
|
||||||
domain = new data.CompoundDomain(domain, ["!", ["id", "in", selected_ids]]);
|
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();
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue