summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2017-03-08 16:03:28 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit228e18e81ae2439c307825cd8127e800dfec571c (patch)
tree61219a17a268be24cac236b4d517b0364d59dd88 /addons/web/static/src
parent61b09bbe47ca88f411840778a2134d8c7f860338 (diff)
[REF] web, mail: include evaled field options in datapoint
Field options do not depend on any context/data. They can so be "computed" once and for all in the BasicView implementation instead of in the AbstractField's one. Also, remove the flag __always_reload and leave it be in the options object (always_reload).
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/fields/abstract_field.js3
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js2
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js9
-rw-r--r--addons/web/static/src/js/views/basic/basic_view.js8
4 files changed, 9 insertions, 13 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js
index 57a3ea00941..e1ff2e8cca9 100644
--- a/addons/web/static/src/js/fields/abstract_field.js
+++ b/addons/web/static/src/js/fields/abstract_field.js
@@ -31,7 +31,6 @@ odoo.define('web.AbstractField', function (require) {
*/
var field_utils = require('web.field_utils');
-var pyeval = require('web.pyeval');
var Widget = require('web.Widget');
var Domain = require('web.Domain');
@@ -114,7 +113,7 @@ var AbstractField = Widget.extend({
// Widget can often be configured in the 'options' attribute in the
// xml 'field' tag. These options are saved (and evaled) in nodeOptions
- this.nodeOptions = pyeval.py_eval(this.attrs.options || '{}', this.recordData);
+ this.nodeOptions = this.attrs.options || {};
// dataPointID is the id corresponding to the current record in the model.
// Its intended use is to be able to tag any messages going upstream,
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index f4c55c25202..0aa6b3440bc 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -222,7 +222,7 @@ var FieldMany2One = AbstractField.extend({
// really a bad way to do it. Now, we need to remove the extra lines
// and hope for the best that noone tries to uses this mechanism to do
// something else.
- if (this.field.__always_reload) {
+ if (this.nodeOptions.always_reload) {
value = value.split('\n')[0];
}
this.$input.val(value);
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 764406eca61..ab2b7dcbbee 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -81,7 +81,6 @@ var concurrency = require('web.concurrency');
var Context = require('web.Context');
var Domain = require('web.Domain');
var fieldUtils = require('web.field_utils');
-var pyeval = require('web.pyeval');
var session = require('web.session');
var x2ManyCommands = {
@@ -1829,7 +1828,8 @@ var BasicModel = AbstractModel.extend({
var defs = [];
_.each(record.fieldNames, function (name) {
var field = record.fields[name];
- var attrs = record.fieldAttrs[name];
+ var attrs = record.fieldAttrs[name] || {};
+ var options = attrs.options || {};
if (field.__fetch_status && !field.__status_information) {
var field_values = _.mapObject(record.data, function (val, key) {
var fieldType = record.fields[key].type;
@@ -1839,9 +1839,8 @@ var BasicModel = AbstractModel.extend({
return val;
});
var domain = Domain.prototype.stringToArray(field.domain || [], field_values);
- var fold_field = pyeval.py_eval(attrs.options || '{}').fold_field;
var fetch_status_information = self._rpc(field.relation, 'search_read')
- .withFields(['id'].concat(fold_field ? [fold_field] : []))
+ .withFields(['id'].concat(options.fold_field ? [options.fold_field] : []))
.withDomain(domain)
.exec()
.then(function (result) {
@@ -1862,7 +1861,7 @@ var BasicModel = AbstractModel.extend({
});
defs.push(fetch_status_information);
}
- if (field.__always_reload) {
+ if (options.always_reload) {
if (record.data[name] instanceof Array) {
defs.push(self._rpc(field.relation, 'name_get')
.args([record.data[name][0]])
diff --git a/addons/web/static/src/js/views/basic/basic_view.js b/addons/web/static/src/js/views/basic/basic_view.js
index d8e41b99835..d493bcb9729 100644
--- a/addons/web/static/src/js/views/basic/basic_view.js
+++ b/addons/web/static/src/js/views/basic/basic_view.js
@@ -164,12 +164,10 @@ var BasicView = AbstractView.extend({
* @param {Object} attrs
*/
_processField: function (field, node, attrs) {
- if (attrs.options) {
- var options = pyeval.py_eval(attrs.options || '{}');
- if (options.always_reload) {
- field.__always_reload = true;
- }
+ if (!_.isObject(attrs.options)) { // parent arch could have already been processed (TODO this should not happen)
+ attrs.options = attrs.options ? pyeval.py_eval(attrs.options) : {};
}
+
if (field.type === 'many2one') {
if (node.attrs.widget === 'statusbar' || node.attrs.widget === 'radio') {
field.__fetch_status = true;