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 00000000..8387d765 Binary files /dev/null and b/ext/custom-addons/dp_sale_filter_partner_addresses/static/description/icon.png differ 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 00000000..3c33e99b Binary files /dev/null and b/ext/custom-addons/dp_sale_filter_partner_addresses/static/src/img/favicon.ico differ diff --git a/ext/custom-addons/dp_sale_filter_partner_addresses/static/src/js/relational_fields.js b/ext/custom-addons/dp_sale_filter_partner_addresses/static/src/js/relational_fields.js new file mode 100644 index 00000000..6b80575a --- /dev/null +++ b/ext/custom-addons/dp_sale_filter_partner_addresses/static/src/js/relational_fields.js @@ -0,0 +1,148 @@ +odoo.define('dp_sale_filter_partner_addresses.relational_fields', function (require) { + "use strict"; + + var relational_fields = require('web.relational_fields'); + var dialogs = require('web.view_dialogs'); + var core = require('web.core'); + + var _t = core._t; + + var FieldMany2OneAlwaysSearchMore = relational_fields.FieldMany2One.include({ + // RW: Gesamte Funktion überschreiben, weil einfacher + /** + * @private + * @param {string} search_val + * @returns {Deferred} + */ + _search: function (search_val) { + var self = this; + var def = $.Deferred(); + this.orderer.add(def); + + var context = this.record.getContext(this.recordParams); + var domain = this.record.getDomain(this.recordParams); + + var blacklisted_ids = this._getSearchBlacklist(); + if (blacklisted_ids.length > 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 @@ + + + + + + + +