From 0fdc914a67bc81d3b9fd64895a3808cb3b46baa7 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 11 Sep 2019 12:39:56 +0000 Subject: [FIX] web: search panel handles archived parent category Have a model with a parent field Set his parents like Parent 0 | -- Parent 1 | -- Parent 2 Now, put the Parent 1 as inactive Open a view with a search panel, which will fetch the parent field as categories Before this commit, it crashed, because the inner record memory did not contain a reference to the parent of Parent 2 After this commit, it doesn't crash, and the search panel just doesn't display parents categories that are archived, nor any children of those OPW 2070266 closes odoo/odoo#36699 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/views/kanban/search_panel.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/views') diff --git a/addons/web/static/src/js/views/kanban/search_panel.js b/addons/web/static/src/js/views/kanban/search_panel.js index d06eacbdb07..b7d2432426f 100644 --- a/addons/web/static/src/js/views/kanban/search_panel.js +++ b/addons/web/static/src/js/views/kanban/search_panel.js @@ -140,8 +140,9 @@ var SearchPanel = Widget.extend({ }); Object.keys(category.values).forEach(function (valueId) { var value = category.values[valueId]; - if (value.parentId) { - category.values[value.parentId].childrenIds.push(value.id); + var parentCategoryId = value.parentId; + if (parentCategoryId && parentCategoryId in category.values) { + category.values[parentCategoryId].childrenIds.push(value.id); } }); category.rootIds = Object.keys(category.values).filter(function (valueId) { -- cgit v1.2.3 From 057d3eba2e07fd035a826f5eeed651149ced469f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Thu, 12 Sep 2019 09:00:39 +0000 Subject: [FIX] web: use search view input with composition mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forward-port of #36688 (original: #36284) Before this commit, search view was barely usable with Japanese IME. For instance, when pressing ENTER while in composition mode and IME prompts some suggestions, it made a search with the updated input content. The expected behaviour should have been to update the input content, without making the search yet. This commit fixes the issue by turning off some actions of the search view when typing during composition mode. opw-2061590 closes odoo/odoo#36728 Signed-off-by: Alexandre Kühn (aku) --- .../src/js/views/control_panel/search/search_bar.js | 20 ++++++++++++++++++++ .../js/views/control_panel/search/search_facet.js | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'addons/web/static/src/js/views') diff --git a/addons/web/static/src/js/views/control_panel/search/search_bar.js b/addons/web/static/src/js/views/control_panel/search/search_bar.js index 6248489922c..9063b2aca50 100644 --- a/addons/web/static/src/js/views/control_panel/search/search_bar.js +++ b/addons/web/static/src/js/views/control_panel/search/search_bar.js @@ -9,6 +9,8 @@ var Widget = require('web.Widget'); var SearchBar = Widget.extend({ template: 'SearchView.SearchBar', events: _.extend({}, Widget.prototype.events, { + 'compositionend .o_searchview_input': '_onCompositionendInput', + 'compositionstart .o_searchview_input': '_onCompositionstartInput', 'keydown': '_onKeydown', }), /** @@ -34,6 +36,7 @@ var SearchBar = Widget.extend({ this.autoCompleteSources = []; this.searchFacets = []; + this._isInputComposing = false; }, /** * @override @@ -207,11 +210,28 @@ var SearchBar = Widget.extend({ }); } }, + /** + * @rivate + * @param {CompositionEvent} ev + */ + _onCompositionendInput: function () { + this._isInputComposing = false; + }, + /** + * @rivate + * @param {CompositionEvent} ev + */ + _onCompositionstartInput: function () { + this._isInputComposing = true; + }, /** * @private * @param {KeyEvent} e */ _onKeydown: function (e) { + if (this._isInputComposing) { + return; + } switch(e.which) { case $.ui.keyCode.LEFT: this._focusPreceding(); diff --git a/addons/web/static/src/js/views/control_panel/search/search_facet.js b/addons/web/static/src/js/views/control_panel/search/search_facet.js index ca9a7ad6225..3f18597cccf 100644 --- a/addons/web/static/src/js/views/control_panel/search/search_facet.js +++ b/addons/web/static/src/js/views/control_panel/search/search_facet.js @@ -10,6 +10,8 @@ var SearchFacet = Widget.extend({ template: 'SearchView.SearchFacet', events: _.extend({}, Widget.prototype.events, { 'click .o_facet_remove': '_onFacetRemove', + 'compositionend': '_onCompositionend', + 'compositionstart': '_onCompositionstart', 'keydown': '_onKeydown', }), /** @@ -26,6 +28,7 @@ var SearchFacet = Widget.extend({ }); this.separator = this._getSeparator(); this.icon = this._getIcon(); + this._isComposing = false; }, //-------------------------------------------------------------------------- @@ -105,6 +108,20 @@ var SearchFacet = Widget.extend({ // Handlers //-------------------------------------------------------------------------- + /** + * @private + * @param {CompositionEvent} ev + */ + _onCompositionend: function (ev) { + this._isComposing = false; + }, + /** + * @private + * @param {CompositionEvent} ev + */ + _onCompositionstart: function (ev) { + this._isComposing = true; + }, /** * @private */ @@ -116,6 +133,9 @@ var SearchFacet = Widget.extend({ * @param {KeyboardEvent} ev */ _onKeydown: function (ev) { + if (this._isComposing) { + return; + } switch (ev.which) { case $.ui.keyCode.BACKSPACE: this.trigger_up('facet_removed', {group: this.facet}); -- cgit v1.2.3 From 416f1794426af55132a19d388a2e5693f59dfde6 Mon Sep 17 00:00:00 2001 From: RomainLibert Date: Mon, 16 Sep 2019 08:24:40 +0000 Subject: [FIX] web: pass the context when executing an action In case you have a button of type action, the controller is doing an rpc on the model using the right method, but in this rpc, the context is not passed. This creates a translation problem (nothing is translated) since the language is not defined in the context. Task Id 2062419 Closes #36189 closes odoo/odoo#36969 Signed-off-by: Yannick Tivisse (yti) --- addons/web/static/src/js/views/abstract_controller.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'addons/web/static/src/js/views') diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js index 63d59d153fd..5b5197469db 100644 --- a/addons/web/static/src/js/views/abstract_controller.js +++ b/addons/web/static/src/js/views/abstract_controller.js @@ -19,6 +19,8 @@ var config = require('web.config'); var core = require('web.core'); var mvc = require('web.mvc'); +var session = require('web.session'); + var QWeb = core.qweb; var AbstractController = mvc.Controller.extend(ActionMixin, { @@ -476,6 +478,7 @@ var AbstractController = mvc.Controller.extend(ActionMixin, { this.dp.add(this._rpc({ model: data.model, method: data.method, + context: session.user_context, })).then(function (action) { if (action !== undefined) { self.do_action(action, options); -- cgit v1.2.3