Files
odoo_source/addons/spreadsheet/static/tests/utils/chart.js
T
Rémi Rahir dfb88e4fa2 [IMP] spreadsheet: update o_spreadsheet to latest version
https://github.com/odoo/o-spreadsheet/commit/fc313d38 [IMP] images: delete images from the file store
https://github.com/odoo/o-spreadsheet/commit/d4e45186 [REF] config: move data external dependencies to config
https://github.com/odoo/o-spreadsheet/commit/3f6cd0f5 [FIX] headers: fix rounding error in header size
https://github.com/odoo/o-spreadsheet/commit/ac07e847 [FIX] functions: fix error message
https://github.com/odoo/o-spreadsheet/commit/e068c651 [IMP] clipboard: copy cell as HTML in OS clipboard

closes odoo/odoo#109497

Related: odoo/enterprise#35607
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
2023-01-10 13:39:56 +01:00

72 lines
1.8 KiB
JavaScript

/** @odoo-module */
import { nextTick } from "@web/../tests/helpers/utils";
import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended";
import { createModelWithDataSource } from "./model";
const uuidGenerator = new spreadsheet.helpers.UuidGenerator();
/** @typedef {import("@spreadsheet/o_spreadsheet/o_spreadsheet").Model} Model */
/**
*
* @param {Model} model
*/
export function insertChartInSpreadsheet(model, type = "odoo_bar") {
const definition = getChartDefinition(type);
model.dispatch("CREATE_CHART", {
sheetId: model.getters.getActiveSheetId(),
id: definition.id,
position: {
x: 10,
y: 10,
},
definition,
});
}
/**
*
* @param {Object} params
* @param {function} [params.mockRPC]
* @param {string} [params.type]
*
* @returns { Promise<{ model: Model, env: Object }>}
*/
export async function createSpreadsheetWithChart(params = {}) {
const model = await createModelWithDataSource({
mockRPC: params.mockRPC,
});
insertChartInSpreadsheet(model, params.type);
const env = model.config.custom.env;
env.model = model;
await nextTick();
return { model, env };
}
function getChartDefinition(type) {
return {
metaData: {
groupBy: ["foo", "bar"],
measure: "__count",
order: null,
resModel: "partner",
},
searchParams: {
comparison: null,
context: {},
domain: [],
groupBy: [],
orderBy: [],
},
stacked: true,
title: "Partners",
background: "#FFFFFF",
legendPosition: "top",
verticalAxisPosition: "left",
dataSourceId: uuidGenerator.uuidv4(),
id: uuidGenerator.uuidv4(),
type,
};
}