Fall 1278: Feedback vom Workshop - 09.01.2018, US03 umgesetzt.
							parent
							
								
									c4b7f76025
								
							
						
					
					
						commit
						5dd53890c9
					
				|  | @ -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. | ||||
|  | @ -0,0 +1,22 @@ | |||
| # -*- coding: utf-8 -*- | ||||
| # Copyright 2018-Today datenpol gmbh(<http://www.datenpol.at>) | ||||
| # 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, | ||||
| } | ||||
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 2.2 KiB | 
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 26 KiB | 
|  | @ -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 "<strong>%s</strong>"'), | ||||
|                                 $('<span />').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(); | ||||
|         }, | ||||
| 
 | ||||
|     }) | ||||
| }); | ||||
| 
 | ||||
|  | @ -0,0 +1,23 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <!-- Copyright 2018-Today datenpol gmbh(<http://www.datenpol.at>) | ||||
|      License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). --> | ||||
| 
 | ||||
| <odoo> | ||||
| 
 | ||||
|     <record model="ir.ui.view" id="sale_order_form_view"> | ||||
|         <field name="name">sale.order.form (in dp_sale_filter_partner_addresses)</field> | ||||
|         <field name="model">sale.order</field> | ||||
|         <field name="inherit_id" ref="sale.view_order_form"/> | ||||
|         <field name="arch" type="xml"> | ||||
|             <field name="partner_invoice_id" position="attributes"> | ||||
|                 <attribute name="domain">[('commercial_partner_id', '=', partner_id)]</attribute> | ||||
|                 <attribute name="options">{"always_reload": True, "search_more": True}</attribute> | ||||
|             </field> | ||||
|             <field name="partner_shipping_id" position="attributes"> | ||||
|                 <attribute name="domain">[('commercial_partner_id', '=', partner_id)]</attribute> | ||||
|                 <attribute name="options">{"always_reload": True, "search_more": True}</attribute> | ||||
|             </field> | ||||
|         </field> | ||||
|     </record> | ||||
| 
 | ||||
| </odoo> | ||||
|  | @ -0,0 +1,13 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <!-- Copyright 2018-Today datenpol gmbh(<http://www.datenpol.at>) | ||||
|      License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). --> | ||||
| 
 | ||||
| <odoo> | ||||
| 
 | ||||
|     <template id="assets_backend" name="dp_sale_filter_partner_addresses assets" inherit_id="web.assets_backend"> | ||||
|         <xpath expr="." position="inside"> | ||||
|             <script type="text/javascript" src="/dp_sale_filter_partner_addresses/static/src/js/relational_fields.js"></script> | ||||
|         </xpath> | ||||
|     </template> | ||||
| 
 | ||||
| </odoo> | ||||
		Loading…
	
		Reference in New Issue