[FIX] web: add record in list with sample data: no flickering
Have an editable list view with sample data (sample="1" and no record). Before this commit, there was a flickering when the user clicked on "New" to add a record. Indeed, the list was first re-rendered without the sample mode (i.e. without the opacity style and no content helper), but still with the sample records. With this commit, we wait for the reload to be done before leaving the sample mode, s.t. when the list is re-rendered, we don't have sample records anymore. Part-of: odoo/odoo#132802
This commit is contained in:
@@ -210,10 +210,10 @@ export class DynamicList extends DataPoint {
|
||||
return unlinked;
|
||||
}
|
||||
|
||||
_leaveSampleMode() {
|
||||
async _leaveSampleMode() {
|
||||
if (this.model.useSampleModel) {
|
||||
await this._load(this.offset, this.limit, this.orderBy, this.domain);
|
||||
this.model.useSampleModel = false;
|
||||
return this._load(this.offset, this.limit, this.orderBy, this.domain);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19407,6 +19407,7 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.strictEqual(input, document.activeElement);
|
||||
assert.strictEqual(input.value, "Value 1");
|
||||
});
|
||||
|
||||
QUnit.test("monetary field display for rtl languages", async function (assert) {
|
||||
patchWithCleanup(localization, {
|
||||
direction: "rtl",
|
||||
@@ -19442,4 +19443,40 @@ QUnit.module("Views", (hooks) => {
|
||||
"Monetary cells should have ltr direction"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("add record in editable list view with sample data", async function (assert) {
|
||||
serverData.models.foo.records = [];
|
||||
let def;
|
||||
await makeView({
|
||||
type: "list",
|
||||
resModel: "foo",
|
||||
serverData,
|
||||
arch: '<tree sample="1" editable="top"><field name="int_field"/></tree>',
|
||||
noContentHelp: "click to add a record",
|
||||
mockRPC(route, args) {
|
||||
if (args.method === "unity_web_search_read") {
|
||||
return def;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
assert.containsOnce(target, ".o_view_sample_data");
|
||||
assert.containsOnce(target, ".o_view_nocontent");
|
||||
assert.containsN(target, ".o_data_row", 10);
|
||||
|
||||
def = makeDeferred();
|
||||
await clickAdd();
|
||||
|
||||
assert.containsOnce(target, ".o_view_sample_data");
|
||||
assert.containsOnce(target, ".o_view_nocontent");
|
||||
assert.containsN(target, ".o_data_row", 10);
|
||||
|
||||
def.resolve();
|
||||
await nextTick();
|
||||
|
||||
assert.containsNone(target, ".o_view_sample_data");
|
||||
assert.containsNone(target, ".o_view_nocontent");
|
||||
assert.containsOnce(target, ".o_data_row");
|
||||
assert.containsOnce(target, ".o_data_row.o_selected_row");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user