diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-08-07 10:32:54 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-08-07 11:24:15 +0200 |
| commit | 8a386b9a08d1dcd8eac66623f2743291bf677c00 (patch) | |
| tree | fa852ee8576d190e61fc005f8f8b9eaa8f1373df /addons/web/static/src | |
| parent | 144d8e42fcf956a02854148f65085a8915bdc37e (diff) | |
[FIX] web: BasicModel: domain returned by onchanges
Onchange RPCs return an object that may contain a 'domain' key.
When it does, its value is an object whose keys are field names and
values are the new domain for the corresponding field.
Commit 8473bde8 added the support of the 'domain' key, but stored
it directly in the fieldsInfo (an object gathering information of
the fields in the view, and which is shared between all records).
This was wrong as the domain isn't necessarily the same for all
records. To reproduce, with the UOMs activated, go to Sales >
Quotation, in the form view, add an order line, set a product
(e.g. Graphic Card), the onchange sets the domain for the uom
field (matching uoms like 'unit', 'dozens'). Add a second line
with a service product, the onchange returns another domain for
the uom field (matching uoms like 'hours', days'). Click again on
the uom field of the first line, the domain is the one of the
second record, which is wrong.
This rev. directly stores the domains returned by the onchange on
the object representing the record, so that this information isn't
shared between records anymore.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 14 |
1 files changed, 8 insertions, 6 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 04fe384afdc..966a6ef3a78 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2435,6 +2435,12 @@ var BasicModel = AbstractModel.extend({ */ _getDomain: function (element, options) { if (options && options.fieldName) { + if (element._domains[options.fieldName]) { + return Domain.prototype.stringToArray( + element._domains[options.fieldName], + this._getEvalContext(element, true) + ); + } var viewType = options.viewType || element.viewType; var fieldInfo = element.fieldsInfo[viewType][options.fieldName]; if (fieldInfo && fieldInfo.domain) { @@ -2697,6 +2703,7 @@ var BasicModel = AbstractModel.extend({ var dataPoint = { _cache: type === 'list' ? {} : undefined, _changes: null, + _domains: {}, aggregateValues: params.aggregateValues || {}, context: params.context || {}, count: params.count || res_ids.length, @@ -3021,12 +3028,7 @@ var BasicModel = AbstractModel.extend({ record._warning = true; } if (result.domain) { - var fieldsInfo = record.fieldsInfo[viewType || record.viewType]; - for (var fieldName in result.domain) { - if (fieldsInfo[fieldName]) { - fieldsInfo[fieldName].domain = result.domain[fieldName]; - } - } + record._domains = _.extend(record._domains, result.domain); } return self._applyOnChange(result.value, record).then(function () { return result; |
