summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2019-02-06 09:43:34 +0000
committerAaron Bohy <aab@odoo.com>2019-02-06 14:03:25 +0000
commit495d475d1d3ab6726d7e5d5f2dd8044e60d1a3da (patch)
treee331e5bd0a35980f3164701071384bd65b661f30 /addons/web/static/src/js/views/basic/basic_model.js
parent5fcf891e07bf61518e6bf0be0dc4f27859d45778 (diff)
[FIX] web: only call name_get when necessary
For many2one fields, 'default_get' only returns the id, whereas 'onchange' (like 'read') returns an array with id and display_name. Before this rev., when creating a new record, we always called 'name_get' for all many2ones, whether or not their value was obtained by 'default_get' or 'onchange', i.e. even if their display_name was already known. It may just look like unnecessary RPCs, but those RPCs could actually cause a crash when the user has access to the main model (and thus can access the display_name of the many2one thanks to related sudo), but doesn't have access to the many2one comodel. closes odoo/odoo#30892
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_model.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js2
1 files changed, 1 insertions, 1 deletions
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 80ca5bc7917..b21c4b55eff 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -2400,7 +2400,7 @@ var BasicModel = AbstractModel.extend({
if (field.type === 'many2one' && !record.fieldsInfo[record.viewType][name].__no_fetch) {
var localId = (record._changes && record._changes[name]) || record.data[name];
var relatedRecord = self.localData[localId];
- if (!relatedRecord) {
+ if (!relatedRecord || relatedRecord.data.display_name) {
return;
}
toBeFetched.push({