[FIX] web: add fields in right order in calendar
Before this commit, fields in calendar popover were added to the $fieldsList after they were appended but appending is async and so fields could be disordered. Now, we add fields before the append to have the right order. closes odoo/odoo#72262 X-original-commit: da1b85d2fdff85bee35d183a8ee4faa0897dc1b4 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Michaël Mattiello <mcm-odoo@users.noreply.github.com>
This commit is contained in:
@@ -216,9 +216,8 @@ var CalendarPopover = Widget.extend(WidgetAdapterMixin, StandaloneFieldManagerMi
|
||||
} else {
|
||||
def = fieldWidget.mount($fieldContainer[0]);
|
||||
}
|
||||
defs.push(def.then(function () {
|
||||
self.$fieldsList.push($field);
|
||||
}));
|
||||
self.$fieldsList.push($field);
|
||||
defs.push(def);
|
||||
});
|
||||
return Promise.all(defs);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
odoo.define('web.calendar_tests', function (require) {
|
||||
"use strict";
|
||||
|
||||
const AbstractField = require('web.AbstractField');
|
||||
var AbstractStorageService = require('web.AbstractStorageService');
|
||||
const BasicModel = require('web.BasicModel');
|
||||
var CalendarView = require('web.CalendarView');
|
||||
@@ -4080,6 +4081,54 @@ QUnit.module('Views', {
|
||||
|
||||
testUtils.mock.unpatch(CalendarRenderer);
|
||||
});
|
||||
|
||||
QUnit.test("fields are added in the right order in popover", async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
const def = testUtils.makeTestPromise();
|
||||
const DeferredWidget = AbstractField.extend({
|
||||
async start() {
|
||||
await this._super(...arguments);
|
||||
await def;
|
||||
}
|
||||
});
|
||||
fieldRegistry.add("deferred_widget", DeferredWidget);
|
||||
|
||||
const calendar = await createCalendarView({
|
||||
View: CalendarView,
|
||||
model: 'event',
|
||||
data: this.data,
|
||||
arch:
|
||||
`<calendar
|
||||
date_start="start"
|
||||
date_stop="stop"
|
||||
all_day="allday"
|
||||
mode="month"
|
||||
>
|
||||
<field name="user_id" widget="deferred_widget" />
|
||||
<field name="name" />
|
||||
</calendar>`,
|
||||
archs: archs,
|
||||
viewOptions: {
|
||||
initialDate: initialDate,
|
||||
},
|
||||
});
|
||||
|
||||
await testUtils.dom.click(calendar.$(`[data-event-id="4"]`));
|
||||
assert.containsNone(calendar, ".o_cw_popover");
|
||||
|
||||
def.resolve();
|
||||
await testUtils.nextTick();
|
||||
assert.containsOnce(calendar, ".o_cw_popover");
|
||||
|
||||
assert.strictEqual(
|
||||
calendar.$(".o_cw_popover .o_cw_popover_fields_secondary").text(),
|
||||
"user : name : event 4"
|
||||
);
|
||||
|
||||
calendar.destroy();
|
||||
delete fieldRegistry.map.deferred_widget;
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user