From d24ea500e6ecfdd6c3d7b10d84367d1f4b4945f9 Mon Sep 17 00:00:00 2001 From: Parth Gajjar Date: Wed, 31 May 2017 19:30:46 +0530 Subject: [FIX] web: basicmodel: properly link parent in m2m In some cases, the parentID was not properly set, which is a problem when we need to evaluate the parent in a context. Note: I also added a better error explanation in the mock server, to make it better for the developper to see what is wrong. --- 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 742e59a61c5..eef858ddcfa 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1168,6 +1168,7 @@ var BasicModel = AbstractModel.extend({ fieldsInfo: view ? view.fieldsInfo : fieldInfo.fieldsInfo, res_id: d.id, viewType: view ? view.type : fieldInfo.viewType, + parentID: list.id, }); list_records[d.id] = rec; list._changes.push(rec.id); -- cgit v1.2.3 From 19cbbb21fb42e208bef55b4bcc62ed08cea4c742 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Thu, 1 Jun 2017 11:51:21 +0200 Subject: =?UTF-8?q?[FIX]=20web:=20handle=20=C2=B4domain=C2=B4=20widget=20r?= =?UTF-8?q?endering=20without=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When creating a new record where the ´domain´ widget is set in the view with an associated model but this model field has no value, an rpc (search_count) was done on an unknown model, that causes a traceback. To avoid this, the rpc is not done if the model is not set. --- addons/web/static/src/js/views/basic/basic_model.js | 5 +++++ 1 file changed, 5 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 eef858ddcfa..16970b2c21b 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1645,6 +1645,11 @@ var BasicModel = AbstractModel.extend({ }); if (!hasChanged) { return $.when(); + } else if (!domainModel) { + return $.when({ + model: domainModel, + nbRecords: 0, + }); } var def = $.Deferred(); -- cgit v1.2.3 From 1749ac2cd1c29311a1b1a5ab0863529211022434 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 1 Jun 2017 15:09:09 +0200 Subject: [FIX] web: allow to unset and reset same many2one value Suppose that we have a many2one which is set (has a value) in a form view. Before this rev., if the user unset the value (by erasing the input content in edit mode), and then reset the same value, the input remained empty, and the old value wasn't actually reset. --- addons/web/static/src/js/views/basic/basic_model.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (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 16970b2c21b..60abfde4344 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -974,7 +974,12 @@ var BasicModel = AbstractModel.extend({ // user edited a manyone (with the small form view button) with an // onchange. In that case, the onchange is triggered, but the actual // value did not change. - var relatedID = (record._changes && record._changes[fieldName]) || record.data[fieldName]; + var relatedID; + if (record._changes && fieldName in record._changes) { + relatedID = record._changes[fieldName]; + } else { + relatedID = record.data[fieldName]; + } var relatedRecord = this.localData[relatedID]; if (relatedRecord && (data.id === this.localData[relatedID].res_id)) { return $.when(); -- cgit v1.2.3