summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-05-02 12:45:07 +0200
committerAaron Bohy <aab@odoo.com>2017-05-02 15:34:43 +0200
commitc891463e509a327fc8bc1a2c4fa0fae1e00f0bab (patch)
treedf33035a58d3e8d6aa5bbb1299483f52ad2617a2 /addons/web/static/src/js/views/basic/basic_model.js
parente9dce2c7b655d0f0b2b1075c05a37a190f1f6473 (diff)
[FIX] web: BasicModel: apply onchange after x2m edition
When a record is added in an x2many field with an onchange, the onchange is only triggered once the new record is valid (i.e. when all its required fields have a correct value). However, there was an issue in the code checking the validity of a record, as it iterated on all known fields of the model (instead of those in the view), so if there were required fields that weren't, the record was always invalid (as those fields obviously never had a value), and thus the onchange was never done. This wasn't a problem with embedded views as in this case, the known fields are those in the view. But when the view isn't embedded, all fields of the related model are known, even if only some of them are in the view. This was the case for example in the stock.picking form view, when adding a line in the stock.move o2m: the onchange wasn't done and thus, the schedule date wasn't correctly set.
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.js4
1 files changed, 2 insertions, 2 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 9bd33b90a3d..36b86cb0098 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -2005,11 +2005,11 @@ var BasicModel = AbstractModel.extend({
var isValid = true;
var element = this.get(id, {raw: true});
_.each(element.data, function (rec) {
- for (var fieldName in rec.fields) {
+ _.each(rec.getFieldNames(), function (fieldName) {
if (rec.fields[fieldName].required && !rec.data[fieldName]) {
isValid = false;
}
- }
+ });
});
return isValid;
},