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