From a67370c57f99ab12fdf66deb44002634ec38e122 Mon Sep 17 00:00:00 2001 From: cubells Date: Tue, 14 Feb 2017 15:11:51 +0100 Subject: [PATCH] [9.0][MIG] web_advanced_search_x2x module --- web_advanced_search_x2x/README.rst | 23 +++- web_advanced_search_x2x/__init__.py | 21 +-- web_advanced_search_x2x/__openerp__.py | 32 +---- .../static/src/js/web_advanced_search_x2x.js | 129 ++++-------------- web_advanced_search_x2x/views/templates.xml | 20 +-- 5 files changed, 58 insertions(+), 167 deletions(-) diff --git a/web_advanced_search_x2x/README.rst b/web_advanced_search_x2x/README.rst index f9346d82..2a8c3c46 100644 --- a/web_advanced_search_x2x/README.rst +++ b/web_advanced_search_x2x/README.rst @@ -1,3 +1,8 @@ +.. image:: https://img.shields.io/badge/license-LGPL--3-blue.svg + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +========================================= Search for x2x records in advanced search ========================================= @@ -27,9 +32,10 @@ In both cases, don't forget to click `Apply` to actually execute the search. Note that you can stack searching for properties: Simply add another advanced search in the selection search window. You can do this indefinetely, so it is possible to search for moves belonging to a journal which has a user who is member of a certain group etc. -For further information, please visit: +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/154/9.0 -* https://www.odoo.com/forum/help-1 Credits ======= @@ -38,16 +44,19 @@ Contributors ------------ * Holger Brunn +* Vicent Cubells Maintainer ---------- -.. image:: http://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: http://odoo-community.org +.. 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. +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_advanced_search_x2x/__init__.py b/web_advanced_search_x2x/__init__.py index faef9dac..723825bd 100644 --- a/web_advanced_search_x2x/__init__.py +++ b/web_advanced_search_x2x/__init__.py @@ -1,20 +1,3 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2015 Therp BV . -# -# 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 . -# -############################################################################## +# Copyright 2015 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/web_advanced_search_x2x/__openerp__.py b/web_advanced_search_x2x/__openerp__.py index be2fa24b..dcdae99d 100644 --- a/web_advanced_search_x2x/__openerp__.py +++ b/web_advanced_search_x2x/__openerp__.py @@ -1,26 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2015 Therp BV . -# -# 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 . -# -############################################################################## +# Copyright 2015 Therp BV +# Copyright 2017 Tecnativa - Vicent Cubells +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + { "name": "Search x2x fields", - "version": "8.0.1.0.0", + "version": "9.0.1.0.0", "author": "Therp BV, " "Odoo Community Association (OCA)", "license": "AGPL-3", @@ -35,12 +20,7 @@ "qweb": [ 'static/src/xml/web_advanced_search_x2x.xml', ], - "test": [ - ], "auto_install": False, - 'installable': False, + 'installable': True, "application": False, - "external_dependencies": { - 'python': [], - }, } diff --git a/web_advanced_search_x2x/static/src/js/web_advanced_search_x2x.js b/web_advanced_search_x2x/static/src/js/web_advanced_search_x2x.js index f233c235..ba2ae5ee 100644 --- a/web_advanced_search_x2x/static/src/js/web_advanced_search_x2x.js +++ b/web_advanced_search_x2x/static/src/js/web_advanced_search_x2x.js @@ -19,11 +19,18 @@ // //############################################################################ -openerp.web_advanced_search_x2x = function(instance) -{ - instance.web_advanced_search_x2x.ExtendedSearchPropositionMany2One = - instance.web.search.ExtendedSearchProposition.Char.extend( - instance.web.form.FieldManagerMixin, +odoo.define('web_advanced_search_x2x.search_filters', function (require) { + "use strict"; + + var filters = require('web.search_filters'); + var form_common = require('web.form_common'); + var SearchView = require('web.SearchView'); + var data = require('web.data'); + var session = require('web.session'); + var core = require('web.core'); + + var searchfilters = filters.ExtendedSearchProposition.Char.extend( + form_common.FieldManagerMixin, { template: 'web_advanced_search_x2x.extended_search.proposition.many2one', searchfield: null, @@ -44,7 +51,7 @@ openerp.web_advanced_search_x2x = function(instance) } }); this.operators.push({ - 'value': 'domain', 'text': instance.web._lt('is in selection'), + 'value': 'domain', 'text': data._lt('is in selection'), }); return this._super.apply(this, arguments); }, @@ -74,7 +81,7 @@ openerp.web_advanced_search_x2x = function(instance) { this.searchfield.destroy(); } - this.searchfield = new instance.web.form.FieldMany2One( + this.searchfield = new form_common.FieldMany2One( this, this.create_searchfield_node()); return this.searchfield; }, @@ -154,11 +161,11 @@ openerp.web_advanced_search_x2x = function(instance) var self = this; if(!this.domain || this.domain.length == 0) { - throw new instance.web.search.Invalid( + throw new filters.Invalid( this.field.string, this.domain_representation, - instance.web._lt('invalid search domain')); + data._lt('invalid search domain')); } - return _.extend(new instance.web.CompoundDomain(), { + return _.extend(new data.CompoundDomain(), { __domains: [ _.map(this.domain, function(leaf) { @@ -180,7 +187,7 @@ openerp.web_advanced_search_x2x = function(instance) popup_domain_selection: function() { var self = this, - popup = new instance.web_advanced_search_x2x.SelectCreatePopup(this); + popup = new form_common.SelectCreatePopup(this); popup.on('domain_selected', this, function(domain, domain_representation) { self.$el.filter('.web_advanced_search_x2x_domain').text( @@ -190,100 +197,13 @@ openerp.web_advanced_search_x2x = function(instance) }); popup.select_element( this.field.relation, {}, this.field.domain, - new instance.web.CompoundContext( - instance.session.user_context, this.field.context)); + new data.CompoundContext( + session.user_context, this.field.context)); }, }); - instance.web.search.custom_filters.add( - 'one2many', - 'instance.web_advanced_search_x2x.ExtendedSearchPropositionMany2One'); - instance.web.search.custom_filters.add( - 'many2many', - 'instance.web_advanced_search_x2x.ExtendedSearchPropositionMany2One'); - instance.web.search.custom_filters.add( - 'many2one', - 'instance.web_advanced_search_x2x.ExtendedSearchPropositionMany2One'); - instance.web_advanced_search_x2x.SelectCreatePopup = instance.web.form.SelectCreatePopup.extend({ - setup_search_view: function() - { - var self = this; - this._super.apply(this, arguments); - this.searchview.on("search_view_loaded", this, function() - { - self.view_list.on("list_view_loaded", self, function() - { - self.$buttonpane.find(".oe_selectcreatepopup-search-create").remove(); - self.$buttonpane.prepend( - jQuery('