summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/relational_fields.js
diff options
context:
space:
mode:
authorMartin Geubelle <mge@odoo.com>2017-09-14 16:35:14 +0200
committerMartin Geubelle <mge@odoo.com>2017-09-15 11:03:09 +0200
commit74c27d81ed299441d3ba07c2181d0e9830b1fec0 (patch)
tree44eb1fe7a51d0e523323e8c4a7b025b70566a37c /addons/web/static/src/js/fields/relational_fields.js
parent135a6fb45b0e1278f7a11399a0893fc2137dccda (diff)
[FIX] web: deal with `can_create` and `can_write` option in M2O
The server postproccess the view to add attributes on many2one fields, i.e. `can_create` and `can_write`, according to access rights. These attributes are parsed by the client as string but should also be parsed by the many2one when evaluating them. The mock server has also been adapted to set these attributes.
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index c2bd4f5d5b8..4cbbf498e82 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -93,8 +93,12 @@ var FieldMany2One = AbstractField.extend({
this._super.apply(this, arguments);
this.limit = 7;
this.orderer = new concurrency.DropMisordered();
- this.can_create = ('can_create' in this.attrs ? this.attrs.can_create : true) && !this.nodeOptions.no_create;
- this.can_write = 'can_write' in this.attrs ? this.attrs.can_write : true;
+
+ // should normally also be set, except in standalone M20
+ this.can_create = ('can_create' in this.attrs ? JSON.parse(this.attrs.can_create) : true) &&
+ !this.nodeOptions.no_create;
+ this.can_write = 'can_write' in this.attrs ? JSON.parse(this.attrs.can_write) : true;
+
this.nodeOptions = _.defaults(this.nodeOptions, {
quick_create: true,
});