Browse Source

Merge pull request #129 from akretion/8-m2m

8 add checkbox in m2m tree view
pull/138/head
Sylvain LE GAL 10 years ago
parent
commit
e03ece1db4
  1. 35
      web_widget_many2many_tags_multi_selection/README.rst
  2. 20
      web_widget_many2many_tags_multi_selection/__init__.py
  3. 36
      web_widget_many2many_tags_multi_selection/__openerp__.py
  4. 38
      web_widget_many2many_tags_multi_selection/static/src/js/view_form.js
  5. 10
      web_widget_many2many_tags_multi_selection/views/web_widget_many2many_tags_multi_selection.xml

35
web_widget_many2many_tags_multi_selection/README.rst

@ -0,0 +1,35 @@
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.
Installation
============
It was tested on Odoo 8.0 branch.
Credits
=======
Akretion
Contributors
------------
* Sylvain Calador <sylvain.calador@akretion.com>
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.

20
web_widget_many2many_tags_multi_selection/__init__.py

@ -0,0 +1,20 @@
# -*- 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/>.
#
##############################################################################

36
web_widget_many2many_tags_multi_selection/__openerp__.py

@ -0,0 +1,36 @@
# -*- 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/>.
#
##############################################################################
{
'name': 'Tags multiple selection',
'version': '0.1',
'author': 'Akretion, Odoo Community Association (OCA)',
'depends': [
'web',
],
'demo': [],
'website': 'https://www.akretion.com',
'data': [
'views/web_widget_many2many_tags_multi_selection.xml',
],
'installable': True,
'auto_install': False,
}

38
web_widget_many2many_tags_multi_selection/static/src/js/view_form.js

@ -0,0 +1,38 @@
openerp.web_widget_many2many_tags_multi_selection = function(instance, local) {
var _t = instance.web._t;
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,
{
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',
},
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<len;i++) {
self.add_id(element_ids[i]);
if (self.field.type != 'many2many') {
break;
}
}
self.focus();
});
};
}

10
web_widget_many2many_tags_multi_selection/views/web_widget_many2many_tags_multi_selection.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets_backend" name="web_widget_many2many_tags_multi_selection" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js"></script>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save