From c068ed0392851cf08bbca6aca9664a69a8d7bd28 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 6 May 2015 17:29:46 +0200 Subject: [PATCH 01/12] [ADD] web_advanced_search_x2x --- web_advanced_search_x2many/README.rst | 45 +++++++ web_advanced_search_x2many/__init__.py | 20 ++++ web_advanced_search_x2many/__openerp__.py | 45 +++++++ .../static/description/icon.png | Bin 0 -> 1142 bytes .../src/css/web_advanced_search_x2many.css | 4 + .../src/js/web_advanced_search_x2many.js | 112 ++++++++++++++++++ .../src/xml/web_advanced_search_x2many.xml | 9 ++ .../views/templates.xml | 11 ++ 8 files changed, 246 insertions(+) create mode 100644 web_advanced_search_x2many/README.rst create mode 100644 web_advanced_search_x2many/__init__.py create mode 100644 web_advanced_search_x2many/__openerp__.py create mode 100644 web_advanced_search_x2many/static/description/icon.png create mode 100644 web_advanced_search_x2many/static/src/css/web_advanced_search_x2many.css create mode 100644 web_advanced_search_x2many/static/src/js/web_advanced_search_x2many.js create mode 100644 web_advanced_search_x2many/static/src/xml/web_advanced_search_x2many.xml create mode 100644 web_advanced_search_x2many/views/templates.xml diff --git a/web_advanced_search_x2many/README.rst b/web_advanced_search_x2many/README.rst new file mode 100644 index 00000000..0d132b87 --- /dev/null +++ b/web_advanced_search_x2many/README.rst @@ -0,0 +1,45 @@ +Search for x2x records in advanced search +========================================= + +Standard behavior in advanced search for one2many, many2many and many2one fields is to do a `name_search`. This is not always satisfactionary as you might want to search for other properties. There might also be cases where you don't exactly know what you're searching for, then a list of possible options is necessary too. This module enables you to have a full search view to select the record in question. + +Usage +===== + +To use this module, you need to: + +* open the advanced search options in a search view +* select a one2many, many2many or many2one field +* select operator `is equal to` or `is not equal to` +* the textfield changes to a many2one selection field where you can search for the record in question +* to select multiple records, add another condition for the same field before applying the conditions (that's standard behavior) + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + +* from what we have now, it shouldn't be too difficult to add an operator `use condition`, show a search view for the field's model and use the domain filled in there. This way we can have conditions like `[('journal_id.user_id.groups_id.name', '=', 'test')]` + +Credits +======= + +Contributors +------------ + +* Holger Brunn + +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. diff --git a/web_advanced_search_x2many/__init__.py b/web_advanced_search_x2many/__init__.py new file mode 100644 index 00000000..faef9dac --- /dev/null +++ b/web_advanced_search_x2many/__init__.py @@ -0,0 +1,20 @@ +# -*- 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 . +# +############################################################################## diff --git a/web_advanced_search_x2many/__openerp__.py b/web_advanced_search_x2many/__openerp__.py new file mode 100644 index 00000000..c080359b --- /dev/null +++ b/web_advanced_search_x2many/__openerp__.py @@ -0,0 +1,45 @@ +# -*- 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 . +# +############################################################################## +{ + "name": "Search x2x fields", + "version": "1.0", + "author": "Therp BV", + "license": "AGPL-3", + "category": "Usability", + "summary": "Use a search widget in advanced search for x2x fields", + "depends": [ + 'web', + ], + "data": [ + 'views/templates.xml', + ], + "qweb": [ + 'static/src/xml/web_advanced_search_x2many.xml', + ], + "test": [ + ], + "auto_install": False, + "installable": True, + "application": False, + "external_dependencies": { + 'python': [], + }, +} diff --git a/web_advanced_search_x2many/static/description/icon.png b/web_advanced_search_x2many/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4c7ab302908e114888446d84d3493fa726033c1f GIT binary patch literal 1142 zcmeAS@N?(olHy`uVBq!ia0vp^0U*r53?z4+XPOVBSkfJR9T^xl_H+M9WCijWi-X*q z7}lMWc?skwBzpw;GB8xBF)%c=FfjZA3N^f7U???UV0e|lz+g3lfkC`r&aOZkpuXS$ zpAc7|0+Vy!%`Sd3J@*~Rz=H@Xz@vBMNCCrhU++~OAXQKjgnPb5^?zLm6yRy4l)f7mx|d; zx?*(k%?4)UEmyi0Ecrc2=k&YFn|8nX@qd4)(saLN%zo##oL4V9SpH%8W(I{5_Kby- zneS~VhopAyb6lBS&$U5E`gKppbdV7NQIC+SE zKe2ts8LoR*Hw$jqcIEDHSU_mi4;HoUDLTgOJMIHx zO|`@|q9i4;B-JXpC>2OC7#SEE>l#?<8d`)H8e5qfSQ#5>8yHy`7. +// +// 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 . +// +//############################################################################ + +openerp.web_advanced_search_x2many = function(instance) +{ + instance.web_advanced_search_x2many.ExtendedSearchPropositionMany2One = + instance.web.search.ExtendedSearchProposition.Char.extend( + instance.web.form.FieldManagerMixin, + { + template: 'web_advanced_search_x2many.extended_search.proposition.many2one', + searchfield: null, + start: function() + { + this.getParent().$('.searchview_extended_prop_op') + .on('change', this.proxy('operator_changed')); + return this._super.apply(this, arguments); + }, + get_field_desc() + { + return this.field; + }, + create_searchfield_node: function() + { + return { + attrs: { + name: this.field.name, + options: '{"no_create": true}', + }, + } + }, + create_searchfield: function() + { + if(this.searchfield) + { + this.searchfield.destroy(); + } + this.searchfield = new instance.web.form.FieldMany2One( + this, this.create_searchfield_node()); + return this.searchfield; + }, + operator_changed: function(e) + { + this.renderElement(); + if(this.show_searchfield()) + { + this.create_searchfield().appendTo(this.$el.empty()); + } + }, + show_searchfield: function() + { + if(this.isDestroyed()) + { + return false; + } + var operator = this.getParent().$('.searchview_extended_prop_op') + .val(); + return operator == '=' || operator == '!='; + }, + get_value: function() + { + if(this.show_searchfield() && this.searchfield) + { + return this.searchfield.get_value(); + } + return this._super.apply(this, arguments); + }, + format_label: function(format, field, operator) + { + if(this.show_searchfield() && this.searchfield) + { + return _.str.sprintf( + format, + { + field: field.string, + operator: operator.label || operator.text, + value: this.searchfield.display_value[ + String(this.searchfield.get_value())], + + } + ); + } + return this._super.apply(this, arguments); + }, + }); + instance.web.search.custom_filters.add( + 'one2many', + 'instance.web_advanced_search_x2many.ExtendedSearchPropositionMany2One'); + instance.web.search.custom_filters.add( + 'many2many', + 'instance.web_advanced_search_x2many.ExtendedSearchPropositionMany2One'); + instance.web.search.custom_filters.add( + 'many2one', + 'instance.web_advanced_search_x2many.ExtendedSearchPropositionMany2One'); +} diff --git a/web_advanced_search_x2many/static/src/xml/web_advanced_search_x2many.xml b/web_advanced_search_x2many/static/src/xml/web_advanced_search_x2many.xml new file mode 100644 index 00000000..e00aeb77 --- /dev/null +++ b/web_advanced_search_x2many/static/src/xml/web_advanced_search_x2many.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/web_advanced_search_x2many/views/templates.xml b/web_advanced_search_x2many/views/templates.xml new file mode 100644 index 00000000..315dc809 --- /dev/null +++ b/web_advanced_search_x2many/views/templates.xml @@ -0,0 +1,11 @@ + + + + + + From f66ddf8718fb3502415e4723b615b6267ee9e472 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 6 May 2015 17:44:45 +0200 Subject: [PATCH 02/12] [REN] to web_advanced_search_x2x and replace company icon --- .../static/description/icon.png | Bin 1142 -> 0 bytes .../README.rst | 0 .../__init__.py | 0 .../__openerp__.py | 2 +- .../static/description/icon.png | Bin 0 -> 2053 bytes .../static/src/css/web_advanced_search_x2x.css | 0 .../static/src/js/web_advanced_search_x2x.js | 12 ++++++------ .../static/src/xml/web_advanced_search_x2x.xml | 2 +- .../views/templates.xml | 6 +++--- 9 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 web_advanced_search_x2many/static/description/icon.png rename {web_advanced_search_x2many => web_advanced_search_x2x}/README.rst (100%) rename {web_advanced_search_x2many => web_advanced_search_x2x}/__init__.py (100%) rename {web_advanced_search_x2many => web_advanced_search_x2x}/__openerp__.py (96%) create mode 100644 web_advanced_search_x2x/static/description/icon.png rename web_advanced_search_x2many/static/src/css/web_advanced_search_x2many.css => web_advanced_search_x2x/static/src/css/web_advanced_search_x2x.css (100%) rename web_advanced_search_x2many/static/src/js/web_advanced_search_x2many.js => web_advanced_search_x2x/static/src/js/web_advanced_search_x2x.js (88%) rename web_advanced_search_x2many/static/src/xml/web_advanced_search_x2many.xml => web_advanced_search_x2x/static/src/xml/web_advanced_search_x2x.xml (73%) rename {web_advanced_search_x2many => web_advanced_search_x2x}/views/templates.xml (67%) diff --git a/web_advanced_search_x2many/static/description/icon.png b/web_advanced_search_x2many/static/description/icon.png deleted file mode 100644 index 4c7ab302908e114888446d84d3493fa726033c1f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1142 zcmeAS@N?(olHy`uVBq!ia0vp^0U*r53?z4+XPOVBSkfJR9T^xl_H+M9WCijWi-X*q z7}lMWc?skwBzpw;GB8xBF)%c=FfjZA3N^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GhS%FwA-eF_&?aO$L4KpW|$GdZfKp>bS5S)gFxfhiO6b%yPF#m>4Rx~$| zXY7K<;c&shd!3w|TwItrj259#I8<{aKR-WtuW@d7{5!t7yLLPNOP-PQJ9sFGB#79Z zK&2|G+%prqw6p}ck;!5#wd|BmVWMpLE5cRtA zd~#S=<-=6jf0?_C^DXhafhp{B``xK8?{Uj#AR^bqF7I~*-uqroO*LE1Z?5P?eErwR z-E)-JBO~839=v>XX|g_q@Yn;vcpISeUUR#NNIhUwF*3JAdoH~f&vOTmQ;*I`FG5u> z2@S%4{oH zHNC_x_pRyg?^jMID(w@e$v&^J8D?(&2T6tIW8!f9MlZHW^+V#d4j2QJZa$DITkf3F zTxX73$ie*gxA`BPDl4YL%c6rj5|~&1$MAln~Y^rjd+cFV4!wJ>R+#kV}4?s!nOti;aQ`FK!J4>CVM zTzKO~&wLiV?%5Sgt_2ZQGvt!`^L}03<+GHQV}kyET~yqIU?P!N<6D~a*{GQ2Xc#m32nTmOg?@a^+}hQZ zS6%(FufUQX#q=R&)?yR)*gfGgLp2Vk)}wQ`WDt?foYRZT755b2M>0Kk?l zTbN9y!_8-k!Gagf&CPXJgM7MLhg*YXj+HO&M-El9SgZoeBYJvzbuQ}c&yJj6sXPUk zraEbAXk5gv|=1S`aFC7-K9+aSCj z5?VrnZ&DH-JC9-d_!aVZjODnbez$%*vAQH3TyH1%tI@`C>*Q%N!G%fMu?sROw$*5@ zOKTmS8C9#F%-h4g)Yie2i;4ReLlq%cH!wxY*6~3Q4!Z z6r98jX&$v->2cASR{y_o^^0m|rvD)BACQ3*yz46}1Awaak^fP{yA-?z&?sN8CXdj} FzX6;-%~SvY literal 0 HcmV?d00001 diff --git a/web_advanced_search_x2many/static/src/css/web_advanced_search_x2many.css b/web_advanced_search_x2x/static/src/css/web_advanced_search_x2x.css similarity index 100% rename from web_advanced_search_x2many/static/src/css/web_advanced_search_x2many.css rename to web_advanced_search_x2x/static/src/css/web_advanced_search_x2x.css diff --git a/web_advanced_search_x2many/static/src/js/web_advanced_search_x2many.js b/web_advanced_search_x2x/static/src/js/web_advanced_search_x2x.js similarity index 88% rename from web_advanced_search_x2many/static/src/js/web_advanced_search_x2many.js rename to web_advanced_search_x2x/static/src/js/web_advanced_search_x2x.js index 3e14030b..7c0316ed 100644 --- a/web_advanced_search_x2many/static/src/js/web_advanced_search_x2many.js +++ b/web_advanced_search_x2x/static/src/js/web_advanced_search_x2x.js @@ -19,13 +19,13 @@ // //############################################################################ -openerp.web_advanced_search_x2many = function(instance) +openerp.web_advanced_search_x2x = function(instance) { - instance.web_advanced_search_x2many.ExtendedSearchPropositionMany2One = + instance.web_advanced_search_x2x.ExtendedSearchPropositionMany2One = instance.web.search.ExtendedSearchProposition.Char.extend( instance.web.form.FieldManagerMixin, { - template: 'web_advanced_search_x2many.extended_search.proposition.many2one', + template: 'web_advanced_search_x2x.extended_search.proposition.many2one', searchfield: null, start: function() { @@ -102,11 +102,11 @@ openerp.web_advanced_search_x2many = function(instance) }); instance.web.search.custom_filters.add( 'one2many', - 'instance.web_advanced_search_x2many.ExtendedSearchPropositionMany2One'); + 'instance.web_advanced_search_x2x.ExtendedSearchPropositionMany2One'); instance.web.search.custom_filters.add( 'many2many', - 'instance.web_advanced_search_x2many.ExtendedSearchPropositionMany2One'); + 'instance.web_advanced_search_x2x.ExtendedSearchPropositionMany2One'); instance.web.search.custom_filters.add( 'many2one', - 'instance.web_advanced_search_x2many.ExtendedSearchPropositionMany2One'); + 'instance.web_advanced_search_x2x.ExtendedSearchPropositionMany2One'); } diff --git a/web_advanced_search_x2many/static/src/xml/web_advanced_search_x2many.xml b/web_advanced_search_x2x/static/src/xml/web_advanced_search_x2x.xml similarity index 73% rename from web_advanced_search_x2many/static/src/xml/web_advanced_search_x2many.xml rename to web_advanced_search_x2x/static/src/xml/web_advanced_search_x2x.xml index e00aeb77..80b29371 100644 --- a/web_advanced_search_x2many/static/src/xml/web_advanced_search_x2many.xml +++ b/web_advanced_search_x2x/static/src/xml/web_advanced_search_x2x.xml @@ -1,6 +1,6 @@ - + diff --git a/web_advanced_search_x2many/views/templates.xml b/web_advanced_search_x2x/views/templates.xml similarity index 67% rename from web_advanced_search_x2many/views/templates.xml rename to web_advanced_search_x2x/views/templates.xml index 315dc809..29424680 100644 --- a/web_advanced_search_x2many/views/templates.xml +++ b/web_advanced_search_x2x/views/templates.xml @@ -1,10 +1,10 @@ -