Validate current record before switching to next/previous record in window form

Closes #14994
(grafted from 9711708ebcd6242e98a4602da530369f176d6654)

--HG--
branch : 8.0
This commit is contained in:
Cédric Krier
2026-08-05 17:39:38 +02:00
parent 5fbf6bbda4
commit f5b81e02f7
2 changed files with 35 additions and 4 deletions
+20 -2
View File
@@ -540,11 +540,29 @@
undelete: function() {
this.screen.unremove();
},
validate: function() {
let prm = jQuery.Deferred();
this.screen.current_view.set_value();
var record = this.screen.current_record;
if (record) {
var fields = this.screen.current_view.get_fields();
if (!record.validate(fields)) {
this.screen.display(true).always(() => prm.reject());
return prm;
}
if (this.screen.pre_validate) {
return record.pre_validate().then(
prm.resolve, prm.reject);
}
}
prm.resolve();
return prm;
},
previous: function() {
return this.screen.display_previous();
return this.validate().then(() => this.screen.display_previous());
},
next: function() {
return this.screen.display_next();
return this.validate().then(() => this.screen.display_next());
},
switch_: function() {
return this.screen.switch_view();