diff options
| author | Julien Mougenot <jum@odoo.com> | 2020-12-22 16:59:46 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2021-02-11 07:44:15 +0000 |
| commit | 953fb092636b9919aaa6c6a6cfaffd003ba951d5 (patch) | |
| tree | f1af3b961f3475c31a7de4560467774135541714 /addons/web/static/src/js/views/form | |
| parent | 1f99f5df22b3d36775a7386af170c126a481279b (diff) | |
[FIX] web,mail: Call on_attach_callback when appending content
Before this commit, the form renderer would call "on_attach_callback"
only when the whole _render process was over. The problem was that this
process is asynchronous and this callback should be invoked as soon as
the widgets are appended.
As such, any asynchronous operation is performed before appending the
content in a new function "__renderView".
Task 2346540
closes odoo/odoo#60791
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/views/form')
| -rw-r--r-- | addons/web/static/src/js/views/form/form_renderer.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js index b6e1593b215..c758c6a03fd 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -1029,7 +1029,7 @@ var FormRenderer = BasicRenderer.extend({ var $form = this._renderNode(this.arch).addClass(this.className); delete this.defs; - return Promise.all(defs).then(function () { + return Promise.all(defs).then(() => this.__renderView()).then(function () { self._updateView($form.contents()); if (self.state.res_id in self.alertFields) { self.displayTranslationAlert(); @@ -1043,6 +1043,14 @@ var FormRenderer = BasicRenderer.extend({ }); }, /** + * Meant to be overridden if asynchronous work needs to be done when + * rendering the view. This is called right before attaching the new view + * content. + * @private + * @returns {Promise<any>} + */ + async __renderView() {}, + /** * This method is overridden to activate the first notebook page if the * current active page is invisible due to modifiers. This is done after * all modifiers are applied on all page elements. |
