[FIX] spreadsheet: correctly migrate date offset field matching
Steps to reproduce: - Edit CRM -> Leads dashboard - Edit filter "Period" => There is no period offset for the pivot 2, 4 and 6, despite the fact that these pivots have a period offset defined in the json data This is because the field matching migration was not correct. It did not take "offset" field into account. Task-id 3138590 closes odoo/odoo#110221 X-original-commit: 2217c10ba771ece4a4d0d0485ce2f24b13754244 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com> Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
This commit is contained in:
@@ -144,6 +144,9 @@ function migrate4to5(data) {
|
||||
data.pivots[id].fieldMatching = {};
|
||||
}
|
||||
data.pivots[id].fieldMatching[filter.id] = { chain: fm.field, type: fm.type };
|
||||
if ("offset" in fm) {
|
||||
data.pivots[id].fieldMatching[filter.id].offset = fm.offset;
|
||||
}
|
||||
}
|
||||
delete filter.pivotFields;
|
||||
|
||||
@@ -156,6 +159,9 @@ function migrate4to5(data) {
|
||||
data.lists[id].fieldMatching = {};
|
||||
}
|
||||
data.lists[id].fieldMatching[filter.id] = { chain: fm.field, type: fm.type };
|
||||
if ("offset" in fm) {
|
||||
data.lists[id].fieldMatching[filter.id].offset = fm.offset;
|
||||
}
|
||||
}
|
||||
delete filter.listFields;
|
||||
|
||||
@@ -178,6 +184,9 @@ function migrate4to5(data) {
|
||||
figure.data.fieldMatching = {};
|
||||
}
|
||||
figure.data.fieldMatching[filter.id] = { chain: fm.field, type: fm.type };
|
||||
if ("offset" in fm) {
|
||||
figure.data.fieldMatching[filter.id].offset = fm.offset;
|
||||
}
|
||||
}
|
||||
delete filter.graphFields;
|
||||
}
|
||||
|
||||
@@ -226,6 +226,72 @@ QUnit.test("fieldMatchings are moved from filters to their respective datasource
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("fieldMatchings offsets are correctly preserved after migration", (assert) => {
|
||||
const data = {
|
||||
globalFilters: [
|
||||
{
|
||||
id: "Filter",
|
||||
label: "MyFilter1",
|
||||
type: "relation",
|
||||
listFields: {
|
||||
1: {
|
||||
field: "parent_id",
|
||||
type: "date",
|
||||
offset: "-1",
|
||||
},
|
||||
},
|
||||
pivotFields: {
|
||||
1: {
|
||||
field: "parent_id",
|
||||
type: "date",
|
||||
offset: "-1",
|
||||
},
|
||||
},
|
||||
graphFields: {
|
||||
fig1: {
|
||||
field: "parent_id",
|
||||
type: "date",
|
||||
offset: "-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
pivots: {
|
||||
1: {
|
||||
name: "Name",
|
||||
},
|
||||
},
|
||||
lists: {
|
||||
1: {
|
||||
name: "Name",
|
||||
},
|
||||
},
|
||||
sheets: [
|
||||
{
|
||||
figures: [
|
||||
{
|
||||
id: "fig1",
|
||||
tag: "chart",
|
||||
data: {
|
||||
type: "odoo_bar",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const migratedData = migrate(data);
|
||||
assert.deepEqual(migratedData.pivots["1"].fieldMatching, {
|
||||
Filter: { chain: "parent_id", type: "date", offset: "-1" },
|
||||
});
|
||||
assert.deepEqual(migratedData.lists["1"].fieldMatching, {
|
||||
Filter: { chain: "parent_id", type: "date", offset: "-1" },
|
||||
});
|
||||
assert.deepEqual(migratedData.sheets[0].figures[0].data.fieldMatching, {
|
||||
Filter: { chain: "parent_id", type: "date", offset: "-1" },
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("Odoo version is exported", (assert) => {
|
||||
const model = new Model();
|
||||
assert.strictEqual(model.exportData().odooVersion, ODOO_VERSION);
|
||||
|
||||
Reference in New Issue
Block a user