From 45043d706ead18cd0373a749e43f7944a2bb5460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Wed, 25 Jan 2023 15:14:26 +0100 Subject: [PATCH] Use a promise based API for Record.pre_validate() Closes #12039 --- sao/src/model.js | 3 +-- sao/src/window.js | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sao/src/model.js b/sao/src/model.js index 7390b74ab6..8a9c4b832f 100644 --- a/sao/src/model.js +++ b/sao/src/model.js @@ -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 = {}; diff --git a/sao/src/window.js b/sao/src/window.js index 5aad6ede91..5e8b218c26 100644 --- a/sao/src/window.js +++ b/sao/src/window.js @@ -479,7 +479,10 @@ this.screen.current_record) { this.screen.current_record.validate().then(validate => { if (validate && this.screen.attributes.pre_validate) { - return this.screen.current_record.pre_validate(); + return this.screen.current_record.pre_validate().then( + function () { return true; }, + function () { return false; } + ); } return validate; }).then(validate => {