Commit 505f2ae5 authored by Nicolas Évrard's avatar Nicolas Évrard
Browse files

Use a promise based API for Record.pre_validate()

Closes #12039
parent 9d21aacdc5f8
Pipeline #61767 passed with stages
in 10 minutes and 55 seconds
* Use a promise based API for Record.pre_validate()
* Do not select first record by default
* Use ``&`` and ``|`` as boolean operator in search widget
* Use toggle button and label on translate dialog
......
......@@ -1262,8 +1262,7 @@
var values = this._get_on_change_args(
Object.keys(this.modified_fields).concat(['id']));
return this.model.execute('pre_validate',
[values], this.get_context())
.then(() => true, () => false);
[values], this.get_context());
},
cancel: function() {
this._loaded = {};
......
......@@ -478,4 +478,5 @@
!readonly &&
this.screen.current_record) {
this.screen.current_record.validate().then(validate => {
var prm = jQuery.Deferred();
if (validate && this.screen.attributes.pre_validate) {
......@@ -481,3 +482,8 @@
if (validate && this.screen.attributes.pre_validate) {
return this.screen.current_record.pre_validate();
this.screen.current_record.pre_validate().then(
() => { prm.resolve(true); },
() => { prm.resolve(false); }
);
} else {
prm.resolve(validate);
}
......@@ -483,5 +489,5 @@
}
return validate;
return prm;
}).then(validate => {
var closing_prm = jQuery.Deferred();
if (validate && this.save_current) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment