From 3b7a0953aa8d97aa8c4a5803da904cb435debf59 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 (grafted from 2e62e2dc88702ffdcb98ac3185b92e08ae2af937) --HG-- branch : 6.0 --- sao/src/model.js | 7 +------ sao/src/window.js | 5 ++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sao/src/model.js b/sao/src/model.js index c8699ab610..46d52a9f5a 100644 --- a/sao/src/model.js +++ b/sao/src/model.js @@ -1302,12 +1302,7 @@ var values = this._get_on_change_args( Object.keys(this._changed).concat(['id'])); return this.model.execute('pre_validate', - [values], this.get_context()) - .then(function() { - return true; - }, function() { - return false; - }); + [values], this.get_context()); }, cancel: function() { this._loaded = {}; diff --git a/sao/src/window.js b/sao/src/window.js index cec0240090..2b71eea91a 100644 --- a/sao/src/window.js +++ b/sao/src/window.js @@ -430,7 +430,10 @@ this.screen.current_record) { this.screen.current_record.validate().then(function(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; }.bind(this)).then(function(validate) {