From 5dd53890c94d7d08b5ba205108da21d83e4f4c04 Mon Sep 17 00:00:00 2001 From: Roman Widmann Date: Wed, 31 Jan 2018 12:17:47 +0100 Subject: [PATCH] Fall 1278: Feedback vom Workshop - 09.01.2018, US03 umgesetzt. --- .../dp_sale_filter_partner_addresses/LICENSE | 27 ++++ .../__init__.py | 0 .../__manifest__.py | 22 +++ .../static/description/icon.png | Bin 0 -> 2225 bytes .../static/src/img/favicon.ico | Bin 0 -> 26622 bytes .../static/src/js/relational_fields.js | 148 ++++++++++++++++++ .../views/sale_order.xml | 23 +++ .../views/templates.xml | 13 ++ 8 files changed, 233 insertions(+) create mode 100644 ext/custom-addons/dp_sale_filter_partner_addresses/LICENSE create mode 100644 ext/custom-addons/dp_sale_filter_partner_addresses/__init__.py create mode 100644 ext/custom-addons/dp_sale_filter_partner_addresses/__manifest__.py create mode 100644 ext/custom-addons/dp_sale_filter_partner_addresses/static/description/icon.png create mode 100644 ext/custom-addons/dp_sale_filter_partner_addresses/static/src/img/favicon.ico create mode 100644 ext/custom-addons/dp_sale_filter_partner_addresses/static/src/js/relational_fields.js create mode 100644 ext/custom-addons/dp_sale_filter_partner_addresses/views/sale_order.xml create mode 100644 ext/custom-addons/dp_sale_filter_partner_addresses/views/templates.xml diff --git a/ext/custom-addons/dp_sale_filter_partner_addresses/LICENSE b/ext/custom-addons/dp_sale_filter_partner_addresses/LICENSE new file mode 100644 index 00000000..1a40586b --- /dev/null +++ b/ext/custom-addons/dp_sale_filter_partner_addresses/LICENSE @@ -0,0 +1,27 @@ +Odoo Proprietary License v1.0 + +This software and associated files (the "Software") may only be used (executed, +modified, executed after modifications) if you have purchased a valid license +from the authors, typically via Odoo Apps, or if you have received a written +agreement from the authors of the Software (see the COPYRIGHT file). + +You may develop Odoo modules that use the Software as a library (typically by +depending on it, importing it and using its resources), but without copying any +source code or material from the Software. You may distribute those modules +under the license of your choice, provided that this license is compatible with +the terms of the Odoo Proprietary License (For example: LGPL, MIT, +or proprietary licenses similar to this one). + +It is forbidden to publish, distribute, sublicense, or sell copies of the Software +or modified copies of the Software. + +The above copyright notice and this permission notice must be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/ext/custom-addons/dp_sale_filter_partner_addresses/__init__.py b/ext/custom-addons/dp_sale_filter_partner_addresses/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ext/custom-addons/dp_sale_filter_partner_addresses/__manifest__.py b/ext/custom-addons/dp_sale_filter_partner_addresses/__manifest__.py new file mode 100644 index 00000000..2abeae0c --- /dev/null +++ b/ext/custom-addons/dp_sale_filter_partner_addresses/__manifest__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2018-Today datenpol gmbh() +# License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). + + +# noinspection PyStatementEffect +{ + 'name': 'Dp Sale Filter Partner Addresses', + 'version': '11.0.1.0.0', + 'license': 'OPL-1', + 'author': 'datenpol gmbh', + 'website': 'https://www.datenpol.at', + 'depends': [ + 'sale', + ], + 'data': [ + 'views/templates.xml', + 'views/sale_order.xml', + ], + 'installable': True, + 'auto_install': False, +} diff --git a/ext/custom-addons/dp_sale_filter_partner_addresses/static/description/icon.png b/ext/custom-addons/dp_sale_filter_partner_addresses/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..8387d76554e8c52cf9256f9dc3f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t9~0|^8sJp#MB+Q&dRs(hvIdps?!oR>bsP%9BeVgjR&z)829_9`QbW1UDj zi}el7_s6PcZxc$~o=mxlZ34SH_MKG^paDFSOc_MB!IZoMO1iEB7 zuXu=3X&J~QdDC<$9qJCXeK(!CjdUI!yxjNpvWluOfVIk>Jj*Mp?ps{E?nE*@92wd3 zHf~uj1Wu}w7i%_r%x-VX^m!H?i%itH6kBA0LH<;%Te|RgT3qgu|NJ!3x&T~~aD7on zm6@Sqv4i~=ddeyubQ5T`@^$W&jBhPlS@qw0OV+(HThi$D2P+Hj8hw>O8xnm~hU?3^ zO7v!}<)48*B5Y5$%jm;mTT}85HNuFG1qz~tn{<{Z&-$ek47^5!U86Tjdv#U$`}~1& zQ-~mef|#axF()pah?fK#*PaY9@k<0cl?s_Yf1q5F@hB4-)pY!n_vF&GCl-~iYYM>L z#XAuO&I!UGOY}3uJMmQkEX4vMS<1vqh-oE&O4zt_iwFlzc5TmONpi-oewsY6i9R)x zdSw8)fAv#BA}5=yHzBz|9(m-EM;>|Pk)!w@TDLdXvm#rS00000NkvXXu0mjf$QcM^ literal 0 HcmV?d00001 diff --git a/ext/custom-addons/dp_sale_filter_partner_addresses/static/src/img/favicon.ico b/ext/custom-addons/dp_sale_filter_partner_addresses/static/src/img/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..3c33e99bbdd94ba4a177804b29d9dfa9769712e6 GIT binary patch literal 26622 zcmeHQJ#X7a7-r!D2D-RQyA|q~wQCk<$Py_=48%4H{{Yo?Q6O8#sK^j>>)xeX|A2mg zf^1&BdT<5--RzNrVD@>AN8|2zCyUg3G$ot@nlDe}@$PxQU!IsO`wIUK4>SDzG5hbA zEc-sovS--Pl>LK^?dg*cNC+eZ5&{WRy21XTDP4>ii zif#Pv@bKHsL819be>;Bl-Py_TPXWwA_~zuv+1pn?H6LAnuTZ!t-L&*Egn?B1bQ^G_ zUSXr{dJGrnA#9(vZCbxyLY~y7j%g!H`K7+DruXQN{OhlD`A2r~^P3;EFIa}#T;TzX z+V}zGci=~qPg%~NIq~<8w12HyR+h*d<*XfMq1h74(tn3-1bNklPoaCpXa_F8hjo>) z$LM8@`&NA_xu*>X%j2}Kep=fmpT1HS$6fNCz61BX^5ZzX?3+ytV>i5{OjPpG<(~Ws zk85<*7Yu_s3q9&m=0d#D_Snp2w2llf#|H=Bgs$tNU5~A%vll0?Ctcis)q7}tuKP5^ z+pG2=eV)!+>wJX|k-nEie@igze7ux_O2fL#0 zHZO#!_9vzs6s%u_&X;KS)CA_6q_-{xs@`MkQV~lAwePa|g}lri(xPTP#Luh+mX@i~JjgSn&*qi-komX+_P#+9`!2S3CzGPPcxedtT=OcHnK@TG~N zR6c?}UD>{p9Cu&(s^@gWnZ(#?{YH+_CC1#Q508(Wx9P{d2J&a;yFIP%x#Mnn?91mQ zd-a&ud<(#^_ zmn$n0x`sXbY)t?rZyWvH)rb_on`AKWCi%y@$;6{{amgPE6mlxPa=L!`J0P$vt#fi)eo9M zW}ThtR~8(t4j_Y;50;24TMZ=AMZVlus(#8Lr~3VRjPumSw)^=JVvh9?v#-{%k(Gx) zCOcm@XOBwe$YG2V?eP{=iZUuwqa+qQlv z>KZosbO*me>N%gubIOHUuY~(i?qk#(z3ZVmcs2(7?0gvY>2>pLu0vv7LfcsDd4a*N zYqi!#pr)?SnC})_s7;A3gYHs%6B82 zK89o9_X`EvSDm}md0LNa@UB*k)i{JD<1*}vaUS8})kx;$+gGgfnqy;pfetzO-U&seJCv@vd65F3lO{g=N>snr^m z&M%^_Z`AusD$L6md*%1%M8TFexo>`=!e`Yz$1jwtHNki*-rrSvK52ioZ2aJ#g}{l zxzfB_?A>MAe#z7O-5F%8 0) { + domain.push(['id', 'not in', blacklisted_ids]); + } + + this._rpc({ + model: this.field.relation, + method: "name_search", + kwargs: { + name: search_val, + args: domain, + operator: "ilike", + limit: this.limit + 1, + context: context, + }}) + .then(function (result) { + // possible selections for the m2o + var values = _.map(result, function (x) { + x[1] = self._getDisplayName(x[1]); + return { + label: _.str.escapeHTML(x[1].trim()) || data.noDisplayContent, + value: x[1], + name: x[1], + id: x[0], + }; + }); + + // search more... if more results than limit + // RW Start, Check ob in der View (xml) die search_more option am Feld gesetzt ist (eg: options='{"search_more": True}') + // wenn ja, dann immer "Search More..." Option im Dropdown + if ((values.length > self.limit) || (self.nodeOptions.search_more)) { + // RW End + values = values.slice(0, self.limit); + values.push({ + label: _t("Search More..."), + action: function () { + self._rpc({ + model: self.field.relation, + method: 'name_search', + kwargs: { + name: search_val, + args: domain, + operator: "ilike", + limit: 160, + context: context, + }, + }) + .then(self._searchCreatePopup.bind(self, "search")); + }, + classname: 'o_m2o_dropdown_option', + }); + } + var create_enabled = self.can_create && !self.nodeOptions.no_create; + // quick create + var raw_result = _.map(result, function (x) { return x[1]; }); + if (create_enabled && !self.nodeOptions.no_quick_create && + search_val.length > 0 && !_.contains(raw_result, search_val)) { + values.push({ + label: _.str.sprintf(_t('Create "%s"'), + $('').text(search_val).html()), + action: self._quickCreate.bind(self, search_val), + classname: 'o_m2o_dropdown_option' + }); + } + // create and edit ... + if (create_enabled && !self.nodeOptions.no_create_edit) { + var createAndEditAction = function () { + // Clear the value in case the user clicks on discard + self.$('input').val(''); + return self._searchCreatePopup("form", false, self._createContext(search_val)); + }; + values.push({ + label: _t("Create and Edit..."), + action: createAndEditAction, + classname: 'o_m2o_dropdown_option', + }); + } else if (values.length === 0) { + values.push({ + label: _t("No results to show..."), + }); + } + + def.resolve(values); + }); + + return def; + }, + // RW: Gesamte Funktion überschreiben, weil einfacher + /** + * all search/create popup handling + * + * @private + * @param {any} view + * @param {any} ids + * @param {any} context + */ + _searchCreatePopup: function (view, ids, context) { + var self = this; + // RW Start, wenn search_more am Feld gesetzt, dann im Popup immer alle Records laden + var domain = this.record.getDomain({fieldName: this.name}); + var initial_ids = ids ? _.map(ids, function (x) { return x[0]; }) : undefined; + if (self.nodeOptions.search_more) { + domain = []; + initial_ids = undefined; + } + // RW End + return new dialogs.SelectCreateDialog(this, _.extend({}, this.nodeOptions, { + res_model: this.field.relation, + domain: domain, + context: _.extend({}, this.record.getContext(this.recordParams), context || {}), + title: (view === 'search' ? _t("Search: ") : _t("Create: ")) + this.string, + initial_ids: initial_ids, + initial_view: view, + disable_multiple_selection: true, + on_selected: function (records) { + self.reinitialize(records[0]); + self.activate(); + } + })).open(); + }, + + }) +}); + diff --git a/ext/custom-addons/dp_sale_filter_partner_addresses/views/sale_order.xml b/ext/custom-addons/dp_sale_filter_partner_addresses/views/sale_order.xml new file mode 100644 index 00000000..3fecf32b --- /dev/null +++ b/ext/custom-addons/dp_sale_filter_partner_addresses/views/sale_order.xml @@ -0,0 +1,23 @@ + + + + + + + sale.order.form (in dp_sale_filter_partner_addresses) + sale.order + + + + [('commercial_partner_id', '=', partner_id)] + {"always_reload": True, "search_more": True} + + + [('commercial_partner_id', '=', partner_id)] + {"always_reload": True, "search_more": True} + + + + + diff --git a/ext/custom-addons/dp_sale_filter_partner_addresses/views/templates.xml b/ext/custom-addons/dp_sale_filter_partner_addresses/views/templates.xml new file mode 100644 index 00000000..ea1a5554 --- /dev/null +++ b/ext/custom-addons/dp_sale_filter_partner_addresses/views/templates.xml @@ -0,0 +1,13 @@ + + + + + + + +