From 019f96559f5350a90bdb8913f5a39ae373f6e445 Mon Sep 17 00:00:00 2001 From: Adrien Widart Date: Mon, 27 Jun 2022 09:31:56 +0000 Subject: [PATCH] [FIX] stock: prevent edit mode when resolving WO conflicts To reproduce the issue: (Install mrp) 1. Create a conflict between two work orders 2. Open one MO > Work Orders, click on the danger symbol Error: The form has switched into edit mode In case of a 2many field, if one of the inner fields has the class `o_widget`, the quick edit feature is disabled for that inner field: https://github.com/odoo/odoo/blob/7ad3c62b60965139fab06227cb4e941720fed8c2/addons/web/static/src/legacy/js/fields/relational_fields.js#L1121-L1125 This class is automatically added on JS-side, during the rendering thanks to `_renderWidget`: https://github.com/odoo/odoo/blob/80acf449bcaf5ff3d2ba81d84efc0498bc78c533/addons/web/static/src/legacy/js/views/basic/basic_renderer.js#L842 However, in the above case, because this is a widget defined explicitly on the field: https://github.com/odoo/odoo/blob/5682015958d03f4a65969afe3fce9b9b05e5b505/addons/mrp/views/mrp_workorder_views.xml#L101 It leads to `_renderFieldWidget` which does not automatically add the class `o_widget` https://github.com/odoo/odoo/blob/80acf449bcaf5ff3d2ba81d84efc0498bc78c533/addons/web/static/src/legacy/js/views/basic/basic_renderer.js#L726 OPW-2887413 X-original-commit: b7225f415a545e7fd204a7ab4d1114ac680aeea1 Part-of: odoo/odoo#95087 --- addons/stock/static/src/js/popover_widget.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/stock/static/src/js/popover_widget.js b/addons/stock/static/src/js/popover_widget.js index 965c3c55fe6..1eea84a2e6c 100644 --- a/addons/stock/static/src/js/popover_widget.js +++ b/addons/stock/static/src/js/popover_widget.js @@ -35,6 +35,7 @@ var PopoverWidgetField = AbstractField.extend({ } this.$el.css('max-width', '17px'); this.$el.html(QWeb.render(this.buttonTemplape, _.defaults(value, {color: this.color, icon: this.icon}))); + this.$el.addClass('o_widget'); this.$el.find('a').prop('special_click', true); this.$popover = $(QWeb.render(value.popoverTemplate || this.popoverTemplate, value)); this.$popover.on('click', '.action_open_forecast', this._openForecast.bind(this));