From e72445bf9ddfb967eb0d7f970c833fd5249c072c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 28 Sep 2018 17:21:35 +0200 Subject: [PATCH] Manage exclude_field as group attribute We can not rely on the screen linked to the group to provide this information because if the group is the value of a One2Many inside a One2Many, the screen is shared between multiple records and so only one record is linked to the screen. So when the top record is validated all the records not linked to the screen may be considered invalid because the exclude_field will not be excluded from the validation. issue7715 review46651002 --- src/model.js | 12 +++++------- src/screen.js | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/model.js b/src/model.js index 0da8f61f36..18a5e96bc2 100644 --- a/src/model.js +++ b/src/model.js @@ -92,6 +92,7 @@ array.record_removed = []; array.record_deleted = []; array.__readonly = false; + array.exclude_field = null; array.skip_model_access = false; array.forEach(function(e, i, a) { e.group = a; @@ -884,6 +885,9 @@ if (!(fname in this.model.fields)) { continue; } + if (fname == this.group.exclude_field) { + continue; + } if ((this.model.fields[fname] instanceof Sao.field.Many2One) || (this.model.fields[fname] instanceof Sao.field.Reference)) { var field_rec_name = fname + '.rec_name'; @@ -1150,12 +1154,6 @@ validate: function(fields, softvalidation, pre_validate, sync) { var validate_fields = function() { var result = true; - var exclude_fields = []; - this.group.screens.forEach(function(screen) { - if (screen.exclude_field) { - exclude_fields.push(screen.exclude_field); - } - }); for (var fname in this.model.fields) { // Skip not loaded fields if sync and record is not new if (sync && this.id >= 0 && !(fname in this._loaded)) { @@ -1171,7 +1169,7 @@ if (field.description.readonly) { continue; } - if (~exclude_fields.indexOf(fname)) { + if (fname == this.group.exclude_field) { continue; } if (!field.validate(this, softvalidation, pre_validate)) { diff --git a/src/screen.js b/src/screen.js index 1cb11c60d3..fb81a5482c 100644 --- a/src/screen.js +++ b/src/screen.js @@ -1043,6 +1043,7 @@ var views = fields_views[name]; views.forEach(views_add); } + this.group.exclude_field = this.exclude_field; }, new_group: function(context) { if (!context) {