Public release from ruodoo-project: 19.0 - 2026-09-20 21:17:41 UTC

This commit is contained in:
CI Publish Bot
2026-09-20 21:17:50 +00:00
commit ebd298dbf0
1234 changed files with 187334 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,52 @@
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { download } from "@web/core/network/download";
async function docxHandler(action, options, env) {
let reportType = null;
if (action.report_type === "docx-docx") {
reportType = "docx";
} else if (action.report_type === "docx-pdf") {
reportType = "pdf";
}
if (reportType) {
let url = `/report/${reportType}/${action.report_name}`;
const actionContext = action.context || {};
if (action.data && JSON.stringify(action.data) !== "{}") {
const options = encodeURIComponent(JSON.stringify(action.data));
const context = encodeURIComponent(JSON.stringify(actionContext));
url += `?options=${options}&context=${context}`;
} else {
if (actionContext.active_ids) {
url += `/${actionContext.active_ids.join(",")}`;
}
}
env?.services?.ui?.block?.();
try {
const template_type = (action.report_type && action.report_type.split("-")[0]) || "docx";
const type = template_type + "-" + url.split("/")[2];
await download({
url: "/report/download",
data: {
data: JSON.stringify([url, type]),
context: JSON.stringify(Object.assign({}, actionContext, env?.services?.user?.context || {})),
},
});
} finally {
env?.services?.ui?.unblock?.();
}
const onClose = options?.onClose;
if (action.close_on_report_download) {
return env?.services?.action?.doAction({ type: "ir.actions.act_window_close" }, { onClose });
} else if (onClose) {
onClose();
}
return Promise.resolve(true);
}
return Promise.resolve(false);
}
registry.category("ir.actions.report handlers").add("docx_handler", docxHandler);

View File

@@ -0,0 +1,90 @@
/** @odoo-module **/
import {FormController} from "@web/views/form/form_controller";
import {patch} from "@web/core/utils/patch";
let docxReportMap = null;
let docxReportMapLoading = false;
async function loadDocxReportMap(env) {
const orm = env.services.orm;
const templates = await orm.searchRead("docx.template", [], [
"id",
"report_id",
"global_template",
"docx_model_id",
]);
const byReportId = {};
for (const t of templates) {
const reportId = t.report_id && t.report_id[0];
if (!reportId) continue;
byReportId[reportId] = {
templateId: t.id,
globalTemplate: !!t.global_template,
isDocxBased: !!t.docx_model_id,
};
}
return { byReportId };
}
patch(FormController.prototype, {
get actionMenuItems() {
const items = super.actionMenuItems;
const record = this.model?.root;
if (!record || !("docx_template_id" in (record.data || {}))) {
return items;
}
if (!docxReportMap && !docxReportMapLoading) {
docxReportMapLoading = true;
loadDocxReportMap(this.env)
.then((map) => {
docxReportMap = map;
docxReportMapLoading = false;
})
.catch((e) => {
docxReportMapLoading = false;
});
return items;
}
if (!docxReportMap) {
return items;
}
const tplVal = record.data.docx_template_id;
const currentTemplateId = tplVal && tplVal[0];
const hasTemplate = !!currentTemplateId;
if (!items.print?.length) {
return items;
}
items.print = items.print.filter((entry) => {
const reportId = entry.id;
const info = docxReportMap.byReportId[reportId];
if (!info || !info.isDocxBased) {
return true;
}
if (info.globalTemplate) {
return true;
}
if (!hasTemplate) {
return false;
}
return info.templateId === currentTemplateId;
});
return items;
},
});