19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:30:27 +01:00
parent d1963a3c3a
commit 2d3ee4855a
7430 changed files with 2687981 additions and 2965473 deletions

View file

@ -1,12 +1,11 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { Dropdown } from "@web/core/dropdown/dropdown";
import { rpc } from "@web/core/network/rpc";
import { registry } from "@web/core/registry";
import { useAutofocus, useService } from "@web/core/utils/hooks";
import { sprintf } from "@web/core/utils/strings";
import { Component, useState } from "@odoo/owl";
const { Component, useState } = owl;
const favoriteMenuRegistry = registry.category("favoriteMenu");
const cogMenuRegistry = registry.category("cogMenu");
/**
* 'Add to board' menu
@ -22,9 +21,12 @@ const favoriteMenuRegistry = registry.category("favoriteMenu");
* @extends Component
*/
export class AddToBoard extends Component {
static template = "board.AddToBoard";
static components = { Dropdown };
static props = {};
setup() {
this.notification = useService("notification");
this.rpc = useService("rpc");
this.state = useState({ name: this.env.config.getDisplayName() });
useAutofocus();
@ -37,7 +39,6 @@ export class AddToBoard extends Component {
async addToBoard() {
const { domain, globalContext } = this.env.searchModel;
const { context, groupBys, orderBy } = this.env.searchModel.getPreFavoriteValues();
const comparison = this.env.searchModel.comparison;
const contextToSave = {
...Object.fromEntries(
Object.entries(globalContext).filter(
@ -49,11 +50,8 @@ export class AddToBoard extends Component {
group_by: groupBys,
dashboard_merge_domains_contexts: false,
};
if (comparison) {
contextToSave.comparison = comparison;
}
const result = await this.rpc("/board/add_to_dashboard", {
const result = await rpc("/board/add_to_dashboard", {
action_id: this.env.config.actionId || false,
context_to_save: contextToSave,
domain,
@ -63,15 +61,15 @@ export class AddToBoard extends Component {
if (result) {
this.notification.add(
this.env._t("Please refresh your browser for the changes to take effect."),
_t("Please refresh your browser for the changes to take effect."),
{
title: sprintf(this.env._t(`"%s" added to dashboard`), this.state.name),
title: _t("“%s” added to dashboard", this.state.name),
type: "warning",
}
);
this.state.name = this.env.config.getDisplayName();
} else {
this.notification.add(this.env._t("Could not add filter to dashboard"), {
this.notification.add(_t("Could not add filter to dashboard"), {
type: "danger",
});
}
@ -92,13 +90,13 @@ export class AddToBoard extends Component {
}
}
AddToBoard.template = "board.AddToBoard";
AddToBoard.components = { Dropdown };
export const addToBoardItem = {
Component: AddToBoard,
groupNumber: 4,
isDisplayed: ({ config }) => config.actionType === "ir.actions.act_window" && config.actionId,
groupNumber: 20,
isDisplayed: ({ config }) => {
const { actionType, actionId, viewType } = config;
return actionType === "ir.actions.act_window" && actionId && viewType !== "form";
},
};
favoriteMenuRegistry.add("add-to-board", addToBoardItem, { sequence: 10 });
cogMenuRegistry.add("add-to-board", addToBoardItem, { sequence: 10 });

View file

@ -1,16 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="board.AddToBoard" owl="1">
<Dropdown class="'o_add_to_board'">
<t t-set-slot="toggler">Add to my dashboard</t>
<div class="px-3 py-2">
<input type="text" class="o_input" t-ref="autofocus" t-model.trim="state.name" t-on-keydown="onInputKeydown" />
</div>
<div class="px-3 py-2">
<button type="button" class="btn btn-primary" t-on-click="addToBoard">Add</button>
</div>
</Dropdown>
<t t-name="board.AddToBoard">
<div class="o_add_to_board">
<Dropdown>
<button>
<t t-call="Dashboard.DashboardIcon"/>
Dashboard
</button>
<t t-set-slot="content">
<div class="px-3 pb-2">
<label class="mb-2">Add to my dashboard</label>
<input type="text" class="o_input mb-3" t-ref="autofocus" t-model.trim="state.name" t-on-keydown="onInputKeydown" />
<button type="button" class="btn btn-primary" t-on-click="addToBoard">Add</button>
</div>
</t>
</Dropdown>
</div>
</t>
<t t-name="Dashboard.DashboardIcon">
<svg viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg" class="o_ui_app_icon oi-large">
<path d="M4 8C4 5.79086 5.79086 4 8 4H25V21C25 23.2091 23.2091 25 21 25H4V8Z" fill="var(--oi-color, #FC868B)"/>
<path d="M4 35C4 32.7909 5.79086 31 8 31H19V42C19 44.2091 17.2091 46 15 46H4V35Z" fill="var(--oi-color, #F9464C)"/>
<path d="M25 46H29C31.2091 46 33 44.2091 33 42V31H29C26.7909 31 25 32.7909 25 35V46Z" fill="var(--oi-color, #FBB945)"/>
<path d="M31 17L31 21C31 23.2091 32.7909 25 35 25L46 25V21C46 18.7909 44.2091 17 42 17L31 17Z" fill="var(--oi-color, #088BF5)"/>
<path d="M31 4L31 8C31 10.2091 32.7909 12 35 12L46 12V8C46 5.79086 44.2091 4 42 4L31 4Z" fill="var(--oi-color, #2EBCFA)"/>
<path d="M38 46H42C44.2091 46 46 44.2091 46 42V31H42C39.7909 31 38 32.7909 38 35V46Z" fill="var(--oi-color, #F78613)"/>
</svg>
</t>
</templates>

View file

@ -1,160 +0,0 @@
odoo.define("board.AddToBoardMenu", function (require) {
"use strict";
const Context = require("web.Context");
const Domain = require("web.Domain");
const { Dropdown } = require("@web/core/dropdown/dropdown");
const FavoriteMenu = require("web.FavoriteMenu");
const { sprintf } = require("web.utils");
const { useAutofocus } = require("@web/core/utils/hooks");
const { Component, useState } = owl;
/**
* 'Add to board' menu
*
* Component consisiting of a toggle button, a text input and an 'Add' button.
* The first button is simply used to toggle the component and will determine
* whether the other elements should be rendered.
* The input will be given the name (or title) of the view that will be added.
* Finally, the last button will send the name as well as some of the action
* properties to the server to add the current view (and its context) to the
* user's dashboard.
* This component is only available in actions of type 'ir.actions.act_window'.
*/
class AddToBoardMenu extends Component {
setup() {
this.interactive = true;
this.state = useState({
name: this.env.action.name || "",
open: false,
});
useAutofocus();
}
//---------------------------------------------------------------------
// Private
//---------------------------------------------------------------------
/**
* This is the main function for actually saving the dashboard. This method
* is supposed to call the route /board/add_to_dashboard with proper
* information.
* @private
*/
async addToBoard() {
const searchQuery = this.env.searchModel.get("query");
const context = new Context(this.env.action.context);
context.add(searchQuery.context);
context.add({
group_by: searchQuery.groupBy,
orderedBy: searchQuery.orderedBy,
});
if (
searchQuery.timeRanges &&
Object.prototype.hasOwnProperty.call(searchQuery.timeRanges, "fieldName")
) {
context.add({
comparison: searchQuery.timeRanges,
});
}
let controllerQueryParams;
this.env.searchModel.trigger("get-controller-query-params", (params) => {
controllerQueryParams = params || {};
});
controllerQueryParams.context = controllerQueryParams.context || {};
const queryContext = controllerQueryParams.context;
delete controllerQueryParams.context;
context.add(Object.assign(controllerQueryParams, queryContext));
const domainArray = new Domain(this.env.action.domain || []);
const domain = Domain.prototype.normalizeArray(
domainArray.toArray().concat(searchQuery.domain)
);
const evalutatedContext = context.eval();
for (const key in evalutatedContext) {
if (
Object.prototype.hasOwnProperty.call(evalutatedContext, key) &&
/^search_default_/.test(key)
) {
delete evalutatedContext[key];
}
}
evalutatedContext.dashboard_merge_domains_contexts = false;
Object.assign(this.state, {
name: $(".o_input").val() || "",
open: false,
});
const result = await this.env.services.rpc({
route: "/board/add_to_dashboard",
params: {
action_id: this.env.action.id || false,
context_to_save: evalutatedContext,
domain: domain,
view_mode: this.env.view.type,
name: this.state.name,
},
});
if (result) {
this.env.services.notification.notify({
title: sprintf(this.env._t("'%s' added to dashboard"), this.state.name),
message: this.env._t(
"Please refresh your browser for the changes to take effect."
),
type: "warning",
});
} else {
this.env.services.notification.notify({
message: this.env._t("Could not add filter to dashboard"),
type: "danger",
});
}
}
//---------------------------------------------------------------------
// Handlers
//---------------------------------------------------------------------
/**
* @private
* @param {KeyboardEvent} ev
*/
onInputKeydown(ev) {
switch (ev.key) {
case "Enter":
ev.preventDefault();
this.addToBoard();
break;
case "Escape":
// Gives the focus back to the component.
ev.preventDefault();
ev.target.blur();
break;
}
}
//---------------------------------------------------------------------
// Static
//---------------------------------------------------------------------
/**
* @param {Object} env
* @returns {boolean}
*/
static shouldBeDisplayed(env) {
return env.action.type === "ir.actions.act_window";
}
}
AddToBoardMenu.props = {};
AddToBoardMenu.template = "board.AddToBoard";
AddToBoardMenu.components = { Dropdown };
FavoriteMenu.registry.add("add-to-board-menu", AddToBoardMenu, 10);
return AddToBoardMenu;
});

View file

@ -1,15 +1,20 @@
/** @odoo-module **/
import { rpc } from "@web/core/network/rpc";
import { useService } from "@web/core/utils/hooks";
import { View } from "@web/views/view";
import { makeContext } from "@web/core/context";
const { Component, onWillStart } = owl;
import { user } from "@web/core/user";
import { Component, onWillStart } from "@odoo/owl";
export class BoardAction extends Component {
static template = "board.BoardAction";
static components = { View };
static props = {
action: Object,
actionId: { type: Number, optional: true },
className: { type: String, optional: true },
};
static cache = {};
setup() {
const rpc = useService("rpc");
const userService = useService("user");
this.actionService = useService("action");
const action = this.props.action;
this.formViewId = false;
@ -47,27 +52,11 @@ export class BoardAction extends Component {
];
if (action.context) {
this.viewProps.context = makeContext([
action.context,
{ lang: userService.context.lang },
]);
this.viewProps.context = makeContext([action.context, { lang: user.context.lang }]);
if ("group_by" in this.viewProps.context) {
const groupBy = this.viewProps.context.group_by;
this.viewProps.groupBy = typeof groupBy === "string" ? [groupBy] : groupBy;
}
if ("comparison" in this.viewProps.context) {
const comparison = this.viewProps.context.comparison;
if (
comparison !== null &&
typeof comparison === "object" &&
"domains" in comparison &&
"fieldName" in comparison
) {
// Some comparison object with the wrong form might have been stored in db.
// This is why we make the checks on the keys domains and fieldName
this.viewProps.comparison = comparison;
}
}
}
if (action.domain) {
this.viewProps.domain = action.domain;
@ -86,6 +75,3 @@ export class BoardAction extends Component {
});
}
}
BoardAction.template = "board.BoardAction";
BoardAction.components = { View };
BoardAction.cache = {};

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="board.BoardAction" owl="1">
<t t-name="board.BoardAction">
<t t-if="isValid">
<View t-props="viewProps"/>
</t>

View file

@ -1,21 +1,26 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { browser } from "@web/core/browser/browser";
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { Dropdown } from "@web/core/dropdown/dropdown";
import { DropdownItem } from "@web/core/dropdown/dropdown_item";
import { rpc, rpcBus } from "@web/core/network/rpc";
import { useService } from "@web/core/utils/hooks";
import { renderToString } from "@web/core/utils/render";
import { useSortable } from "@web/core/utils/sortable";
import { useSortable } from "@web/core/utils/sortable_owl";
import { standardViewProps } from "@web/views/standard_view_props";
import { BoardAction } from "./board_action";
const { blockDom, Component, useState, useRef } = owl;
import { blockDom, Component, useState, useRef } from "@odoo/owl";
export class BoardController extends Component {
static template = "board.BoardView";
static components = { BoardAction, Dropdown, DropdownItem };
static props = {
...standardViewProps,
board: Object,
};
setup() {
this.board = useState(this.props.board);
this.rpc = useService("rpc");
this.dialogService = useService("dialog");
if (this.env.isSmall) {
this.selectLayout("1", false);
@ -92,7 +97,7 @@ export class BoardController extends Component {
closeAction(column, action) {
this.dialogService.add(ConfirmationDialog, {
body: this.env._t("Are you sure that you want to remove this item?"),
body: _t("Are you sure that you want to remove this item?"),
confirm: () => {
const index = column.actions.indexOf(action);
column.actions.splice(index, 1);
@ -117,19 +122,12 @@ export class BoardController extends Component {
const result = xmlSerializer.serializeToString(root);
const arch = result.slice(result.indexOf("<", 1), result.indexOf("</rendertostring>"));
this.rpc("/web/view/edit_custom", {
rpc("/web/view/edit_custom", {
custom_id: this.board.customViewId,
arch,
});
this.env.bus.trigger("CLEAR-CACHES");
rpcBus.trigger("CLEAR-CACHES");
}
}
BoardController.template = "board.BoardView";
BoardController.components = { BoardAction, Dropdown, DropdownItem };
BoardController.props = {
...standardViewProps,
board: Object,
};
const xmlSerializer = new XMLSerializer();

View file

@ -30,10 +30,22 @@
align-self: start;
> .o_view_controller {
padding: 0 12px 12px 12px;
padding: 0 6px 6px 6px;
.o_content {
max-height: 80vh;
overflow: auto;
> .o_renderer {
min-width: 1200px;
}
}
// graph view
.o_graph_renderer canvas {
height: 300px;
}
// calendar view
.o_calendar_wrapper {
height: 400px;
}
}
.o_column_quick_create, .o_control_panel {

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="board.BoardView" owl="1">
<t t-name="board.BoardView">
<div class="o_dashboard d-flex flex-column">
<t t-if="board.isEmpty">
<t t-call="board.NoContent"/>
@ -12,18 +12,20 @@
</div>
</t>
<t t-name="board.Content" owl="1">
<t t-name="board.Content">
<div t-if="!env.isSmall" class="o-dashboard-header d-flex justify-content-end">
<Dropdown togglerClass="'btn btn-secondary m-2 p-2'">
<t t-set-slot="toggler">
<Dropdown>
<button class="btn btn-secondary m-2 p-2">
<img t-attf-src="/board/static/img/layout_{{board.layout}}.png" width="16" height="16" alt=""/>
Change Layout
</t>
<t t-foreach="'1 1-1 1-1-1 1-2 2-1'.split(' ')" t-as="layout" t-key="layout">
<DropdownItem onSelected="() => this.selectLayout(layout)">
<img t-attf-src="/board/static/img/layout_{{layout}}.png" alt=""/>
<i t-if="layout == board.layout" class="fa fa-check fa-lg text-success" aria-label='Layout' role="img" title="Layout"/>
</DropdownItem>
</button>
<t t-set-slot="content">
<t t-foreach="'1 1-1 1-1-1 1-2 2-1'.split(' ')" t-as="layout" t-key="layout">
<DropdownItem onSelected="() => this.selectLayout(layout)">
<img t-attf-src="/board/static/img/layout_{{layout}}.png" alt=""/>
<i t-if="layout == board.layout" class="fa fa-check fa-lg text-success" aria-label='Layout' role="img" title="Layout"/>
</DropdownItem>
</t>
</t>
</Dropdown>
</div>
@ -46,7 +48,7 @@
</div>
</t>
<t t-name="board.NoContent" owl="1">
<t t-name="board.NoContent">
<div class="o_view_nocontent">
<div class="o_nocontent_help">
<p class="o_view_nocontent_neutral_face">
@ -65,7 +67,7 @@
</div>
</t>
<t t-name="board.arch" owl="1">
<t t-name="board.arch">
<form t-att-string="title">
<board t-att-style="layout">
<column t-foreach="columns" t-as="column" t-key="column_index">

View file

@ -1,12 +1,8 @@
/** @odoo-module **/
import { _lt } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { BoardController } from "./board_controller";
import { XMLParser } from "@web/core/utils/xml";
import { visitXML } from "@web/core/utils/xml";
import { Domain } from "@web/core/domain";
export class BoardArchParser extends XMLParser {
export class BoardArchParser {
parse(arch, customViewId) {
let nextId = 1;
const archInfo = {
@ -19,7 +15,7 @@ export class BoardArchParser extends XMLParser {
};
let currentIndex = -1;
this.visitXML(arch, (node) => {
visitXML(arch, (node) => {
switch (node.tagName) {
case "form":
archInfo.title = node.getAttribute("string");
@ -36,7 +32,7 @@ export class BoardArchParser extends XMLParser {
const isFolded = Boolean(
node.hasAttribute("fold") ? parseInt(node.getAttribute("fold"), 10) : 0
);
let action = {
const action = {
id: nextId++,
title: node.getAttribute("string"),
actionId: parseInt(node.getAttribute("name"), 10),
@ -45,11 +41,7 @@ export class BoardArchParser extends XMLParser {
isFolded,
};
if (node.hasAttribute("domain")) {
let domain = node.getAttribute("domain");
// Since bfadb8e491fe2acda63a79f9577eaaec8a1c8d9c some databases might have
// double-encoded domains in the db, so we need to unescape them before use.
// TODO: remove unescape in saas-16.3
domain = _.unescape(domain);
const domain = node.getAttribute("domain");
action.domain = new Domain(domain).toList();
// so it can be serialized when reexporting board xml
action.domain.toString = () => node.getAttribute("domain");
@ -65,7 +57,6 @@ export class BoardArchParser extends XMLParser {
export const boardView = {
type: "form",
display_name: _lt("Board"),
Controller: BoardController,
props: (genericProps, view) => {