From 512113b78ad4b6c1fb59c313ec73f6c4a04f8737 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 19 Oct 2017 16:42:25 +0200 Subject: [FIX] web: reordering lines using the handle widget triggers onchange issue: When reorder each line trigger an onchange on the line (if they are an onchange linked to the field) and one onchange per line on the parent. Adding an option doNotNotifyChange to avoid the trigger on the parent. --- addons/web/static/src/js/views/basic/basic_model.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 717dcc9f6af..50cd7165a82 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1092,6 +1092,9 @@ var BasicModel = AbstractModel.extend({ * @param {boolean} [options.doNotSetDirty=false] if this flag is set to * true, then we will not tag the record as dirty. This should be avoided * for most situations. + * @param {boolean} [options.notifyChange=true] if this flag is set to + * false, then we will not notify and not trigger the onchange, even though + * it was changed. * @param {string} [options.viewType] current viewType. If not set, we will assume * main viewType from the record * @returns {Deferred} @@ -1119,6 +1122,10 @@ var BasicModel = AbstractModel.extend({ } } + if (options.notifyChange === false) { + return $.when(); + } + return $.when.apply($, defs).then(function () { var onChangeFields = []; // the fields that have changed and that have an on_change for (var fieldName in changes) { -- cgit v1.2.3 From d58d6e270f4106d717821438490f60bc4f71306e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 24 Oct 2017 09:11:17 +0200 Subject: [FIX] web: propagate view context in all x2m operations It could happen in some cases that a rpc coming from a view was not made with the context of the view (and from the action). For example, - enable "Lots & Serial Numbers" in the inventory settings - create a stockable product tracked by lot - go to the inventory dashboard, on the "receipts" card click on the three dots and then on "planned transfer" this link forces the context key "planned_transfer" in the action https://github.com/odoo/odoo/blob/11.0/addons/stock/views/stock_picking_views.xml#L725 - now add a stock move to move some quantity of the product you just created - see that no button appears on the one2many list - save - see that a button appears on the one2many list This is an issue because the read on the o2m at the end is made with the wrong context. The reason is that when we fetch x2m, we create a new datapoint of type 'list' which did not reuse the context of its parent. --- addons/web/static/src/js/views/basic/basic_model.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 50cd7165a82..c450e2bedc7 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2295,6 +2295,7 @@ var BasicModel = AbstractModel.extend({ var ids = record.data[fieldName] || []; var list = self._makeDataPoint({ count: ids.length, + context: record.context, fieldsInfo: fieldsInfo, fields: view ? view.fields : fieldInfo.relatedFields, limit: fieldInfo.limit, -- cgit v1.2.3