From 74c27d81ed299441d3ba07c2181d0e9830b1fec0 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Thu, 14 Sep 2017 16:35:14 +0200 Subject: [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. --- addons/web/static/src/js/fields/relational_fields.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') 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, }); -- cgit v1.2.3