From 3a0f9da0ebf5d8438effd2f656b87b64cbe5237a Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Mon, 29 Oct 2018 14:10:06 +0000 Subject: [FIX] web: load SubViews without previous' view _view_ref context keys On a form view (of model A), define a many2one (model B) with a [form|tree]_view_ref context key In that view, have a x2m field (model C) with a different [form|tree]_view_ref context key Before this commit, the second load_views (i.e. on the model C) crashed because the wrong context key was sent to the server, which returned the view to which the _view_ref points i.e. the view of the model B After this commit, we clean the context of subviews loading, because those keys are only useful for the python and one shot. Hence, there is no crash OPW 1903780 closes odoo/odoo#28260 --- addons/web/static/src/js/views/view_dialogs.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/view_dialogs.js b/addons/web/static/src/js/views/view_dialogs.js index f16317a29e3..163131d47f3 100644 --- a/addons/web/static/src/js/views/view_dialogs.js +++ b/addons/web/static/src/js/views/view_dialogs.js @@ -168,9 +168,12 @@ var FormViewDialog = ViewDialog.extend({ if (self.recordID) { self.model.addFieldsInfo(self.recordID, viewInfo); } + var refinedContext = _.pick(self.context, function (value, key) { + return key.indexOf('_view_ref') === -1; + }); var formview = new FormView(viewInfo, { modelName: self.res_model, - context: self.context, + context: refinedContext, ids: self.res_id ? [self.res_id] : [], currentId: self.res_id || undefined, index: 0, -- cgit v1.2.3 From aa18aaa2925badcace4a3b88607b8f332e99d2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 14 Nov 2018 09:44:53 +0000 Subject: [FIX] web: restore formview mode when coming back (breadcrumbs) Before this commit, when the user is in a form view (edit mode) and click on a stat button, a new action is added to the action stack. When the user then comes back to the form view by clicking on the breadcrumb, it is supposed to be in readonly mode. Before this commit, this was not the case. This bug comes from the action manager refactoring, which removed the view manager. With this commit, we add a new action lifecycle method which is called when the action is restored. Note that this commit implicitely changes the semantic of actions with 'target=inline'. As far as I can tell, this only applies to the settings form view, which can easily be fixed by overriding the restore hook. closes odoo/odoo#28663 --- addons/web/static/src/js/chrome/abstract_action.js | 7 +++++++ addons/web/static/src/js/chrome/action_manager_act_window.js | 6 ++++-- addons/web/static/src/js/views/form/form_controller.js | 11 ++++++++++- addons/web/static/src/js/views/graph/graph_controller.js | 1 - addons/web/static/src/js/views/graph/graph_model.js | 3 --- 5 files changed, 21 insertions(+), 7 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome/abstract_action.js b/addons/web/static/src/js/chrome/abstract_action.js index 5b0f7e3aeca..c4755338bf0 100644 --- a/addons/web/static/src/js/chrome/abstract_action.js +++ b/addons/web/static/src/js/chrome/abstract_action.js @@ -32,6 +32,13 @@ var AbstractAction = Widget.extend({ * Called each time the action is detached from the DOM. */ on_detach_callback: function () {}, + /** + * Called by the action manager when action is restored (typically, when the + * user clicks on the action in the breadcrumb) + * + * @returns {Deferred|undefined} + */ + willRestore: function () {}, //-------------------------------------------------------------------------- // Public diff --git a/addons/web/static/src/js/chrome/action_manager_act_window.js b/addons/web/static/src/js/chrome/action_manager_act_window.js index d121ec929f0..0f6c88a1188 100644 --- a/addons/web/static/src/js/chrome/action_manager_act_window.js +++ b/addons/web/static/src/js/chrome/action_manager_act_window.js @@ -646,8 +646,10 @@ ActionManager.include({ }); } else { viewOptions = _.extend(viewOptions || {}, action.env); - return controller.widget.reload(viewOptions).then(function () { - return controller; + return $.when(controller.widget.willRestore()).then(function () { + return controller.widget.reload(viewOptions).then(function () { + return controller; + }); }); } }); diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index 7586dcc4bab..b7c8e8a6214 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -40,6 +40,15 @@ var FormController = BasicController.extend({ this.hasSidebar = params.hasSidebar; this.toolbarActions = params.toolbarActions || {}; }, + /** + * Force mode back to readonly. Whenever we leave a form view, it is saved, + * and should no longer be in edit mode. + * + * @override + */ + willRestore: function () { + this.mode = 'readonly'; + }, //-------------------------------------------------------------------------- // Public @@ -242,7 +251,7 @@ var FormController = BasicController.extend({ * @override */ update: function (params, options) { - params = _.extend({viewType: 'form'}, params); + params = _.extend({viewType: 'form', mode: this.mode}, params); return this._super(params, options); }, diff --git a/addons/web/static/src/js/views/graph/graph_controller.js b/addons/web/static/src/js/views/graph/graph_controller.js index 48f15de8902..4e998377fa7 100644 --- a/addons/web/static/src/js/views/graph/graph_controller.js +++ b/addons/web/static/src/js/views/graph/graph_controller.js @@ -179,7 +179,6 @@ var GraphController = AbstractController.extend(GroupByMenuInterfaceMixin,{ */ _onButtonClick: function (event) { var $target = $(event.target); - var parent; var field; if ($target.hasClass('o_graph_button')) { this._setMode($target.data('mode')); diff --git a/addons/web/static/src/js/views/graph/graph_model.js b/addons/web/static/src/js/views/graph/graph_model.js index adefe1e8953..26c1aec6545 100644 --- a/addons/web/static/src/js/views/graph/graph_model.js +++ b/addons/web/static/src/js/views/graph/graph_model.js @@ -6,11 +6,8 @@ odoo.define('web.GraphModel', function (require) { * server. It basically just do a read_group and format/normalize data. */ -var core = require('web.core'); var AbstractModel = require('web.AbstractModel'); -var _t = core._t; - return AbstractModel.extend({ /** * @override -- cgit v1.2.3 From 353748c66417e6db7ce9b9d07fa71f8d70a6f9b3 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 14 Nov 2018 13:24:24 +0000 Subject: [FIX] web: handle auto margins for auto more menus The auto more menu feature is used to enforce that all items of a menu stay on one line by adding the ones that would overflow in a dropdown menu. The feature first need to compute the maximum width the menu can have. This computation was not correct as it was not considering auto margins. This is particularly important with BS4 where all standard menus have auto margins. closes odoo/odoo#28683 --- addons/web/static/src/js/core/dom.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/core/dom.js b/addons/web/static/src/js/core/dom.js index 725658a351b..2a961596862 100644 --- a/addons/web/static/src/js/core/dom.js +++ b/addons/web/static/src/js/core/dom.js @@ -397,9 +397,10 @@ return { if (options.maxWidth) { maxWidth = options.maxWidth(); } else { - var rect = $el[0].getBoundingClientRect(); + var mLeft = $el.is('.ml-auto, .mx-auto, .m-auto'); + var mRight = $el.is('.mr-auto, .mx-auto, .m-auto'); + maxWidth = computeFloatOuterWidthWithMargins($el[0], mLeft, mRight); var style = window.getComputedStyle($el[0]); - maxWidth = (rect.right - rect.left); maxWidth -= (parseFloat(style.paddingLeft) + parseFloat(style.paddingRight) + parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth)); maxWidth -= _.reduce($unfoldableItems, function (sum, el) { return sum + computeFloatOuterWidthWithMargins(el); @@ -434,10 +435,17 @@ return { $extraItemsToggle.find('.nav-link').toggleClass('active', $extraItems.children().hasClass('active')); } - function computeFloatOuterWidthWithMargins(el) { + function computeFloatOuterWidthWithMargins(el, mLeft, mRight) { var rect = el.getBoundingClientRect(); var style = window.getComputedStyle(el); - return rect.right - rect.left + parseFloat(style.marginLeft) + parseFloat(style.marginRight); + var outerWidth = rect.right - rect.left; + if (mLeft !== false) { + outerWidth += parseFloat(style.marginLeft); + } + if (mRight !== false) { + outerWidth += parseFloat(style.marginRight); + } + return outerWidth; } }, /** -- cgit v1.2.3 From f3f20653d34bf307ea4aeb36830a378e85c02bf6 Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Mon, 2 Jul 2018 17:56:42 +0530 Subject: [FIX] web: update renderer when _callButtonAction failed Before this rev., the following scenario didn't work: Open manufacturing order and click on Produce button (note that bom product should have Serial number enabled) then add quantity in Done field in o2m and press Record Production button in wizard, it will produce UserError and after then if you change Lot number field in wizard's o2m then the many2one value doesn't get selected. This occured because the renderer wasn't updated after the RPC fail and thus still got an outdated version of the state. The issue raised after commit: 02eef78bbd3 which was done to remove useless rpc call, it's OK to remove rpc call but let's keep updating renderer. Related to task ID: #1852715 Co-authored-by: Tejas Shahu --- addons/web/static/src/js/views/basic/basic_controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 5767969d15c..edf345b41f2 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -261,7 +261,9 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { resIDs: record.res_ids, }, on_success: def.resolve.bind(def), - on_fail: def.reject.bind(def), + on_fail: function () { + self.update({}, {reload: false}).always(def.reject.bind(def)); + }, on_closed: reload, }); return this.alive(def); -- cgit v1.2.3 From 990dce6e2a2ed4ef614c0e9efb2371076397bac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 15 Nov 2018 13:51:45 +0000 Subject: [FIX] web: prevent crash in ungrouped kanban views with progressbar The progressbar widget is not supposed to be displayed in non grouped mode. Before this commit, this situation resulted in a traceback. For example, if the user has an activity on the subscription model, and tries to open it, it will open an ungrouped kanban view. With this commit, we check first that the kanban view is in grouped mode, before loading the progress bar data. --- addons/web/static/src/js/views/kanban/kanban_model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/kanban/kanban_model.js b/addons/web/static/src/js/views/kanban/kanban_model.js index fd21ed4df86..bfb6f5e0cc9 100644 --- a/addons/web/static/src/js/views/kanban/kanban_model.js +++ b/addons/web/static/src/js/views/kanban/kanban_model.js @@ -305,7 +305,7 @@ var KanbanModel = BasicModel.extend({ * @override */ _load: function (dataPoint, options) { - if (dataPoint.progressBar) { + if (dataPoint.groupedBy.length && dataPoint.progressBar) { return this._readProgressBarGroup(dataPoint, options); } return this._super.apply(this, arguments); -- cgit v1.2.3