From 7221aa7db443b5da8df50b24ea6afb31b86043d4 Mon Sep 17 00:00:00 2001 From: Vincent Schippefilt Date: Thu, 7 Mar 2019 14:29:30 +0000 Subject: [PATCH] [FIX] account: add missing class on section and note field after the update of jquery, all promises are asynchronous. In the invoices, a class was added to the section and note field before it was rendered. To fix this, we are now waiting for the rendering to be completed before adding the class. closes odoo/odoo#31666 Signed-off-by: Aaron Bohy (aab) --- .../static/src/js/section_and_note_fields_backend.js | 7 ++++--- addons/account/static/tests/section_and_note_tests.js | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/account/static/src/js/section_and_note_fields_backend.js b/addons/account/static/src/js/section_and_note_fields_backend.js index 624a7ce3a5c..26328cc045b 100644 --- a/addons/account/static/src/js/section_and_note_fields_backend.js +++ b/addons/account/static/src/js/section_and_note_fields_backend.js @@ -68,9 +68,10 @@ var SectionAndNoteListRenderer = ListRenderer.extend({ * @private */ _renderView: function () { - var def = this._super(); - this.$el.find('> table').addClass('o_section_and_note_list_view'); - return def; + var self = this; + return this._super.apply(this, arguments).then(function () { + self.$('> table').addClass('o_section_and_note_list_view'); + }); }, /** * Add support for product configurator diff --git a/addons/account/static/tests/section_and_note_tests.js b/addons/account/static/tests/section_and_note_tests.js index 0cc19043674..7dcef00aa6a 100644 --- a/addons/account/static/tests/section_and_note_tests.js +++ b/addons/account/static/tests/section_and_note_tests.js @@ -47,7 +47,7 @@ QUnit.module('section_and_note', { }, }, function () { QUnit.test('correct display of section and note fields', async function (assert) { - assert.expect(4); + assert.expect(5); var form = await createView({ View: FormView, model: 'invoice', @@ -64,6 +64,8 @@ QUnit.module('section_and_note', { res_id: 1, }); + assert.hasClass(form.$('[name="invoice_line_ids"] table'), 'o_section_and_note_list_view'); + // section should be displayed correctly var $tr0 = form.$('tr.o_data_row:eq(0)');