Browse Source

[MIG] web_widget_many2many_tags_multi_selection: Migration to 11.0

pull/1161/head
Maxence Groine 6 years ago
committed by Pedro M. Baeza
parent
commit
e72ee021dc
  1. 41
      web_widget_many2many_tags_multi_selection/README.rst
  2. 21
      web_widget_many2many_tags_multi_selection/__init__.py
  3. 24
      web_widget_many2many_tags_multi_selection/__manifest__.py
  4. 60
      web_widget_many2many_tags_multi_selection/static/src/js/view_form.js

41
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 <https://github.com/OCA/web/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 <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**>`_.
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/web/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 <https://odoo-community.org/logo.png>`_.
Contributors
------------
* Sylvain Calador <sylvain.calador@akretion.com>
* Jamin Shah <jaiminshah2009@gmail.com>
* Maxence Groine <mgroine@fiefmanage.ch>
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.

21
web_widget_many2many_tags_multi_selection/__init__.py

@ -1,20 +1 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# 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/>.
#
##############################################################################
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

24
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 (<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/>.
#
##############################################################################
# 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,
}

60
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<len;i++) {
self.add_id(element_ids[i]);
if (self.field.type != 'many2many') {
break;
}
}
self.focus();
}
}).open();
var domain = self.build_domain();
rel_fields.FieldMany2One.include({
_searchCreatePopup: function(view, ids, context) {
var self = this;
if (self.field.type == 'many2many') {
var selected_ids = self.get_search_blacklist();
if (selected_ids.length > 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();
},
});
});
Loading…
Cancel
Save