mirror of
https://github.com/bringout/oca-ocb-report.git
synced 2026-04-18 22:02:03 +02:00
Initial commit: Report packages
This commit is contained in:
commit
bc5e1e9efa
604 changed files with 474102 additions and 0 deletions
|
|
@ -0,0 +1,73 @@
|
|||
/** @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 {object} [params.serverData]
|
||||
* @param {string} [params.type]
|
||||
*
|
||||
* @returns { Promise<{ model: Model, env: Object }>}
|
||||
*/
|
||||
export async function createSpreadsheetWithChart(params = {}) {
|
||||
const model = await createModelWithDataSource({
|
||||
mockRPC: params.mockRPC,
|
||||
serverData: params.serverData,
|
||||
});
|
||||
|
||||
insertChartInSpreadsheet(model, params.type);
|
||||
|
||||
const env = model.config.evalContext.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,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue