19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:02 +01:00
parent 62d197ac8b
commit 184bb0e321
667 changed files with 691406 additions and 239886 deletions

View file

@ -1,25 +0,0 @@
/** @odoo-module */
import { _lt } from "@web/core/l10n/translation";
export const FILTER_DATE_OPTION = {
quarter: ["first_quarter", "second_quarter", "third_quarter", "fourth_quarter"],
year: ["this_year", "last_year", "antepenultimate_year"],
};
// TODO Remove this mapping, We should only need number > description to avoid multiple conversions
// This would require a migration though
export const monthsOptions = [
{ id: "january", description: _lt("January") },
{ id: "february", description: _lt("February") },
{ id: "march", description: _lt("March") },
{ id: "april", description: _lt("April") },
{ id: "may", description: _lt("May") },
{ id: "june", description: _lt("June") },
{ id: "july", description: _lt("July") },
{ id: "august", description: _lt("August") },
{ id: "september", description: _lt("September") },
{ id: "october", description: _lt("October") },
{ id: "november", description: _lt("November") },
{ id: "december", description: _lt("December") },
];

View file

@ -1,48 +1,49 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { getBundle, loadBundle } from "@web/core/assets";
import { sprintf } from "@web/core/utils/strings";
import { loadBundle } from "@web/core/assets";
const actionRegistry = registry.category("actions");
/**
*
* @param {object} env
* Add a new function client action which loads the spreadsheet bundle, then
* launch the actual action.
* The action should be redefine in the bundle with `{ force: true }`
* and the actual action component or function
* @param {string} actionName
* @param {function} actionLazyLoader
* @param {string} [path]
* @param {string} [displayName]
*/
export async function loadSpreadsheetAction(env, actionName, actionLazyLoader) {
const desc = await getBundle("spreadsheet.o_spreadsheet");
await loadBundle(desc);
export function addSpreadsheetActionLazyLoader(actionName, path, displayName) {
const actionLazyLoader = async (env, action) => {
// load the bundle which should redefine the action in the registry
await loadBundle("spreadsheet.o_spreadsheet");
if (actionRegistry.get(actionName) === actionLazyLoader) {
// At this point, the real spreadsheet client action should be loaded and have
// replaced this function in the action registry. If it's not the case,
// it probably means that there was a crash in the bundle (e.g. syntax
// error). In this case, this action will remain in the registry, which
// will lead to an infinite loop. To prevent that, we push another action
// in the registry.
actionRegistry.add(
actionName,
() => {
const msg = sprintf(env._t("%s couldn't be loaded"), actionName);
env.services.notification.add(msg, { type: "danger" });
},
{ force: true }
);
if (actionRegistry.get(actionName) === actionLazyLoader) {
// At this point, the real spreadsheet client action should be loaded and have
// replaced this function in the action registry. If it's not the case,
// it probably means that there was a crash in the bundle (e.g. syntax
// error). In this case, this action will remain in the registry, which
// will lead to an infinite loop. To prevent that, we push another action
// in the registry.
actionRegistry.add(
actionName,
() => {
const msg = _t("%s couldn't be loaded", actionName);
env.services.notification.add(msg, { type: "danger" });
},
{ force: true }
);
}
// then do the action again, with the actual definition registered
return action;
};
if (path) {
actionLazyLoader.path = path;
}
if (displayName) {
actionLazyLoader.displayName = displayName;
}
actionRegistry.add(actionName, actionLazyLoader);
}
const loadSpreadsheetDownloadAction = async (env, context) => {
await loadSpreadsheetAction(env, "action_download_spreadsheet", loadSpreadsheetDownloadAction);
return {
...context,
target: "current",
tag: "action_download_spreadsheet",
type: "ir.actions.client",
};
};
actionRegistry.add("action_download_spreadsheet", loadSpreadsheetDownloadAction);
addSpreadsheetActionLazyLoader("action_download_spreadsheet");

View file

@ -0,0 +1,19 @@
import { registry } from "@web/core/registry";
import { BinaryField, binaryField } from "@web/views/fields/binary/binary_field";
export class SpreadsheetBinaryField extends BinaryField {
static template = "spreadsheet.SpreadsheetBinaryField";
setup() {
super.setup();
}
async onFileDownload() {}
}
export const spreadsheetBinaryField = {
...binaryField,
component: SpreadsheetBinaryField,
};
registry.category("fields").add("binary_spreadsheet", spreadsheetBinaryField);

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="spreadsheet.SpreadsheetBinaryField" t-inherit="web.BinaryField" t-inherit-mode="primary">
<xpath expr="//t[@name='download']" position="replace"></xpath>
<xpath expr="//span[hasclass('fa-download')]" position="replace">
<span class="fa fa-file-text-o me-2" />
</xpath>
</t>
</templates>