/** @odoo-module **/

import { registry } from "@web/core/registry";

registry.category("actions").add("download_file", async function (action, env, params) {
    const { model, id, field, filename } = action.params;
    const url = `/web/content/${model}/${id}/${field}/${filename}?download=true`;
    const link = document.createElement("a");
    link.href = url;
    link.download = filename;
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
});