From 6c8e1d94fc1f0ce140b716c1b001744c748767ee Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 10:03:27 +0200 Subject: [PATCH 01/18] [IMP] awesome_owl: Add owl component --- awesome_owl/static/src/counter/counter.js | 14 ++++++++++++++ awesome_owl/static/src/counter/counter.xml | 9 +++++++++ awesome_owl/static/src/playground.js | 15 +++++++++++++-- awesome_owl/static/src/playground.xml | 9 +++++++-- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 awesome_owl/static/src/counter/counter.js create mode 100644 awesome_owl/static/src/counter/counter.xml diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js new file mode 100644 index 00000000000..9d62b92e854 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.js @@ -0,0 +1,14 @@ +import { Component, useState } from "@odoo/owl"; + + +export class Counter extends Component { + static template = "awesome_owl.counter"; + + setup() { + this.state = useState({ value: 0 }); + } + + increment() { + this.state.value++; + } +} \ No newline at end of file diff --git a/awesome_owl/static/src/counter/counter.xml b/awesome_owl/static/src/counter/counter.xml new file mode 100644 index 00000000000..5e6370933f4 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.xml @@ -0,0 +1,9 @@ + + + + +

Counter:

+ +
+ +
\ No newline at end of file diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 4ac769b0aa5..87f061a8115 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,5 +1,16 @@ -import { Component } from "@odoo/owl"; +import { Component, useState } from "@odoo/owl"; + +import { Counter } from "./counter/counter"; export class Playground extends Component { static template = "awesome_owl.playground"; -} + static components = { Counter }; + + setup() { + this.state = useState({ value: 0 }); + } + + increment() { + this.state.value++; + } +} \ No newline at end of file diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4fb905d59f9..4e77bce2fd2 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -2,8 +2,13 @@ -
- hello world + Hello World +
+

Counter:

+ +
+
+
From b05df533421cac8e6f83c8657e38cbd2ece73c79 Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 10:24:56 +0200 Subject: [PATCH 02/18] [IMP] awesome_owl: Add card component --- awesome_owl/static/src/card/card.js | 7 +++++++ awesome_owl/static/src/card/card.xml | 15 +++++++++++++++ awesome_owl/static/src/playground.js | 3 ++- awesome_owl/static/src/playground.xml | 3 +++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 awesome_owl/static/src/card/card.js create mode 100644 awesome_owl/static/src/card/card.xml diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js new file mode 100644 index 00000000000..774e65d5974 --- /dev/null +++ b/awesome_owl/static/src/card/card.js @@ -0,0 +1,7 @@ +import { Component, useState } from "@odoo/owl"; + + +export class Card extends Component { + static template = "awesome_owl.card"; + static props = ['title', 'content']; +} \ No newline at end of file diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml new file mode 100644 index 00000000000..e47103fbd9f --- /dev/null +++ b/awesome_owl/static/src/card/card.xml @@ -0,0 +1,15 @@ + + + + +
+
+
+

+ +

+
+
+
+ +
\ No newline at end of file diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 87f061a8115..833a5184586 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,10 +1,11 @@ import { Component, useState } from "@odoo/owl"; import { Counter } from "./counter/counter"; +import { Card } from "./card/card"; export class Playground extends Component { static template = "awesome_owl.playground"; - static components = { Counter }; + static components = { Counter, Card }; setup() { this.state = useState({ value: 0 }); diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4e77bce2fd2..f14b695986c 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -10,6 +10,9 @@
+ + + From ea305c5933b97eb17c6775273f7fa059064114be Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 10:29:33 +0200 Subject: [PATCH 03/18] [IMP] awesome_owl: Add props validation --- awesome_owl/static/src/card/card.js | 5 ++++- awesome_owl/static/src/card/card.xml | 2 +- awesome_owl/static/src/playground.js | 2 +- awesome_owl/static/src/playground.xml | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js index 774e65d5974..f1a85fd4892 100644 --- a/awesome_owl/static/src/card/card.js +++ b/awesome_owl/static/src/card/card.js @@ -3,5 +3,8 @@ import { Component, useState } from "@odoo/owl"; export class Card extends Component { static template = "awesome_owl.card"; - static props = ['title', 'content']; + static props = { + title: {type: String}, + content: {type: String}, + }; } \ No newline at end of file diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml index e47103fbd9f..0deccbfa274 100644 --- a/awesome_owl/static/src/card/card.xml +++ b/awesome_owl/static/src/card/card.xml @@ -6,7 +6,7 @@

- +

diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 833a5184586..d349cc2045a 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,4 +1,4 @@ -import { Component, useState } from "@odoo/owl"; +import { Component, useState, markup } from "@odoo/owl"; import { Counter } from "./counter/counter"; import { Card } from "./card/card"; diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index f14b695986c..57719e6f316 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -11,6 +11,7 @@ +
From a91d27868e032d96034b64312a5cc2ae887a8782 Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 10:41:16 +0200 Subject: [PATCH 04/18] [IMP] aweome_owl: sum method --- awesome_owl/static/src/counter/counter.js | 9 +++++++++ awesome_owl/static/src/playground.js | 6 +++--- awesome_owl/static/src/playground.xml | 9 ++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js index 9d62b92e854..b1992a3c5c4 100644 --- a/awesome_owl/static/src/counter/counter.js +++ b/awesome_owl/static/src/counter/counter.js @@ -3,6 +3,12 @@ import { Component, useState } from "@odoo/owl"; export class Counter extends Component { static template = "awesome_owl.counter"; + static props = { + onChange: { + type: Function, + optional: true, + }, + }; setup() { this.state = useState({ value: 0 }); @@ -10,5 +16,8 @@ export class Counter extends Component { increment() { this.state.value++; + if(this.props.onChange !== undefined) { + this.props.onChange(); + } } } \ No newline at end of file diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index d349cc2045a..b6c40fc4308 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -8,10 +8,10 @@ export class Playground extends Component { static components = { Counter, Card }; setup() { - this.state = useState({ value: 0 }); + this.state = useState({ sum: 2 }); } - increment() { - this.state.value++; + incrementSum() { + this.state.sum++; } } \ No newline at end of file diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 57719e6f316..e70410d463c 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -4,12 +4,11 @@ Hello World
-

Counter:

- -
-
- + + +
+
The sum is:
From 7979eeb5f5970651ea14c1df523f5e76ba234b41 Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 11:16:53 +0200 Subject: [PATCH 05/18] [IMP] awesome_owl: Add dynamic attributes --- awesome_owl/static/src/playground.js | 3 ++- awesome_owl/static/src/playground.xml | 4 ++++ awesome_owl/static/src/todo/todoitem.js | 15 +++++++++++++++ awesome_owl/static/src/todo/todoitem.xml | 9 +++++++++ awesome_owl/static/src/todo/todolist.js | 15 +++++++++++++++ awesome_owl/static/src/todo/todolist.xml | 12 ++++++++++++ 6 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 awesome_owl/static/src/todo/todoitem.js create mode 100644 awesome_owl/static/src/todo/todoitem.xml create mode 100644 awesome_owl/static/src/todo/todolist.js create mode 100644 awesome_owl/static/src/todo/todolist.xml diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index b6c40fc4308..5465be086f7 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -2,10 +2,11 @@ import { Component, useState, markup } from "@odoo/owl"; import { Counter } from "./counter/counter"; import { Card } from "./card/card"; +import { TodoList } from "./todo/todolist"; export class Playground extends Component { static template = "awesome_owl.playground"; - static components = { Counter, Card }; + static components = { Counter, Card, TodoList }; setup() { this.state = useState({ sum: 2 }); diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index e70410d463c..83ac104d342 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -3,6 +3,10 @@ Hello World +
+ +
+
diff --git a/awesome_owl/static/src/todo/todoitem.js b/awesome_owl/static/src/todo/todoitem.js new file mode 100644 index 00000000000..dfc9b857dca --- /dev/null +++ b/awesome_owl/static/src/todo/todoitem.js @@ -0,0 +1,15 @@ +import { Component, useState } from "@odoo/owl"; + +export class TodoItem extends Component { + static template = "awesome_owl.todoitem"; + static props = { + todo: { + type: Object, + shape: { + id: Number, + description: String, + isCompleted: Boolean, + }, + }, + }; +} \ No newline at end of file diff --git a/awesome_owl/static/src/todo/todoitem.xml b/awesome_owl/static/src/todo/todoitem.xml new file mode 100644 index 00000000000..636a7bd61b3 --- /dev/null +++ b/awesome_owl/static/src/todo/todoitem.xml @@ -0,0 +1,9 @@ + + + + +
+ +
+
+
\ No newline at end of file diff --git a/awesome_owl/static/src/todo/todolist.js b/awesome_owl/static/src/todo/todolist.js new file mode 100644 index 00000000000..a881e1b94e9 --- /dev/null +++ b/awesome_owl/static/src/todo/todolist.js @@ -0,0 +1,15 @@ +import { Component, useState } from "@odoo/owl"; +import { TodoItem } from "./todoitem"; + +export class TodoList extends Component { + static template = "awesome_owl.todolist"; + static components = { TodoItem }; + + setup() { + this.todos = useState([ + { id: 3, description: "buy milk", isCompleted: false }, + { id: 4, description: "FIX MACHINE PLX", isCompleted: false }, + { id: 5, description: "WAKE UP", isCompleted: true }, + ]); + } +} \ No newline at end of file diff --git a/awesome_owl/static/src/todo/todolist.xml b/awesome_owl/static/src/todo/todolist.xml new file mode 100644 index 00000000000..509b168f7ab --- /dev/null +++ b/awesome_owl/static/src/todo/todolist.xml @@ -0,0 +1,12 @@ + + + + +
+ + + +
+
+ +
\ No newline at end of file From 6394aea22f6d9f734b7b6a69fc57c38b2939e20b Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 11:52:20 +0200 Subject: [PATCH 06/18] [IMP] awesome_owl: Adding a todo --- awesome_owl/static/src/todo/todolist.js | 26 +++++++++++++++++++----- awesome_owl/static/src/todo/todolist.xml | 5 +++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/awesome_owl/static/src/todo/todolist.js b/awesome_owl/static/src/todo/todolist.js index a881e1b94e9..e5eeba98c37 100644 --- a/awesome_owl/static/src/todo/todolist.js +++ b/awesome_owl/static/src/todo/todolist.js @@ -6,10 +6,26 @@ export class TodoList extends Component { static components = { TodoItem }; setup() { - this.todos = useState([ - { id: 3, description: "buy milk", isCompleted: false }, - { id: 4, description: "FIX MACHINE PLX", isCompleted: false }, - { id: 5, description: "WAKE UP", isCompleted: true }, - ]); + // this.todos = useState([ + // { id: 3, description: "buy milk", isCompleted: false }, + // { id: 4, description: "FIX MACHINE PLX", isCompleted: false }, + // { id: 5, description: "WAKE UP", isCompleted: true }, + // ]); + this.todos = useState([]); + } + + addTodo(event) { + // console.warn("addTodo"); + // console.log(event); + if (event.keyCode === 13) { + let description = event.target.value; + if (description.length == 0) { + return; + } + let next_id = 1 + Math.max(...this.todos.map(item => item.id), 0); + this.todos.push({ id: next_id, description: description, isCompleted: false }); + // Reset input + event.target.value = ''; + } } } \ No newline at end of file diff --git a/awesome_owl/static/src/todo/todolist.xml b/awesome_owl/static/src/todo/todolist.xml index 509b168f7ab..5648c0d0612 100644 --- a/awesome_owl/static/src/todo/todolist.xml +++ b/awesome_owl/static/src/todo/todolist.xml @@ -2,6 +2,11 @@ +
+ +
From 2ee2e6bb5c96f2d6ff06f054d369ddcba60573df Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 13:57:53 +0200 Subject: [PATCH 07/18] [IMP] awesome_owl: Add autofocus (hook) --- awesome_owl/static/src/todo/todolist.js | 2 ++ awesome_owl/static/src/todo/todolist.xml | 3 ++- awesome_owl/static/src/utils.js | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 awesome_owl/static/src/utils.js diff --git a/awesome_owl/static/src/todo/todolist.js b/awesome_owl/static/src/todo/todolist.js index e5eeba98c37..6cc799d6854 100644 --- a/awesome_owl/static/src/todo/todolist.js +++ b/awesome_owl/static/src/todo/todolist.js @@ -1,5 +1,6 @@ import { Component, useState } from "@odoo/owl"; import { TodoItem } from "./todoitem"; +import { useAutoFocus } from "../utils"; export class TodoList extends Component { static template = "awesome_owl.todolist"; @@ -12,6 +13,7 @@ export class TodoList extends Component { // { id: 5, description: "WAKE UP", isCompleted: true }, // ]); this.todos = useState([]); + useAutoFocus("list_input"); } addTodo(event) { diff --git a/awesome_owl/static/src/todo/todolist.xml b/awesome_owl/static/src/todo/todolist.xml index 5648c0d0612..1f54c28b018 100644 --- a/awesome_owl/static/src/todo/todolist.xml +++ b/awesome_owl/static/src/todo/todolist.xml @@ -3,7 +3,8 @@
-
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js new file mode 100644 index 00000000000..06a33c4cbb8 --- /dev/null +++ b/awesome_owl/static/src/utils.js @@ -0,0 +1,13 @@ +import { useRef } from "@odoo/owl"; +import { onMounted } from "@odoo/owl"; + +export function useAutoFocus(name) { + // NOTE; Object remains alive due to (weak)ref stored inside the closure + // of 'onMounted'. + let theElement = useRef(name); + + onMounted(() => { + theElement.el.focus(); + console.log("Executed autofocus"); + }); +} \ No newline at end of file From f2ed09ecbde4ed9673135c4e0de2dd4d6d0cd977 Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 14:11:32 +0200 Subject: [PATCH 08/18] [IMP] awesome_owl: add todo manipulation --- awesome_owl/static/src/todo/todoitem.js | 15 +++++++++++++++ awesome_owl/static/src/todo/todoitem.xml | 6 +++++- awesome_owl/static/src/todo/todolist.js | 19 +++++++++++++++++++ awesome_owl/static/src/todo/todolist.xml | 2 +- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/awesome_owl/static/src/todo/todoitem.js b/awesome_owl/static/src/todo/todoitem.js index dfc9b857dca..06f4d36c078 100644 --- a/awesome_owl/static/src/todo/todoitem.js +++ b/awesome_owl/static/src/todo/todoitem.js @@ -11,5 +11,20 @@ export class TodoItem extends Component { isCompleted: Boolean, }, }, + toggleState: { + type: Function, + }, + removeTodo: { + type: Function, + }, }; + + change(event) { + let isCompleted = event.target.checked; + this.props.toggleState(this.props.todo.id, isCompleted); + } + + remove() { + this.props.removeTodo(this.props.todo.id); + } } \ No newline at end of file diff --git a/awesome_owl/static/src/todo/todoitem.xml b/awesome_owl/static/src/todo/todoitem.xml index 636a7bd61b3..c88a1385a4c 100644 --- a/awesome_owl/static/src/todo/todoitem.xml +++ b/awesome_owl/static/src/todo/todoitem.xml @@ -3,7 +3,11 @@
- + +
\ No newline at end of file diff --git a/awesome_owl/static/src/todo/todolist.js b/awesome_owl/static/src/todo/todolist.js index 6cc799d6854..86f90070d42 100644 --- a/awesome_owl/static/src/todo/todolist.js +++ b/awesome_owl/static/src/todo/todolist.js @@ -30,4 +30,23 @@ export class TodoList extends Component { event.target.value = ''; } } + + toggleState(id, newState) { + let todo = this.todos.find((el) => el.id == id); + if(todo === undefined) { + return; + } + + todo.isCompleted = newState; + } + + removeTodo(id) { + const index = this.todos.findIndex((el) => el.id ===id); + if(index < 0) { + return; + } + + // Inplace manipulation + this.todos.splice(index, 1); + } } \ No newline at end of file diff --git a/awesome_owl/static/src/todo/todolist.xml b/awesome_owl/static/src/todo/todolist.xml index 1f54c28b018..e12735cbb03 100644 --- a/awesome_owl/static/src/todo/todolist.xml +++ b/awesome_owl/static/src/todo/todolist.xml @@ -10,7 +10,7 @@
- +
From 1623a03ad8ee35546621048c0e37d4a655fc95f7 Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 15:04:56 +0200 Subject: [PATCH 09/18] [IMP] awesome_owl: Implement advanced card mechanics --- awesome_owl/static/src/card/card.js | 10 +++++++++- awesome_owl/static/src/card/card.xml | 9 +++++---- awesome_owl/static/src/playground.xml | 9 ++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js index f1a85fd4892..a7229af7f2d 100644 --- a/awesome_owl/static/src/card/card.js +++ b/awesome_owl/static/src/card/card.js @@ -5,6 +5,14 @@ export class Card extends Component { static template = "awesome_owl.card"; static props = { title: {type: String}, - content: {type: String}, + slots: {type: Object, optional: true}, }; + + setup() { + this.opened = useState({r: true}); + } + + toggleOpened() { + this.opened.v = !this.opened.v; + } } \ No newline at end of file diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml index 0deccbfa274..7ec53d243f2 100644 --- a/awesome_owl/static/src/card/card.xml +++ b/awesome_owl/static/src/card/card.xml @@ -4,10 +4,11 @@
-
-

- -

+
+ +
+ +
diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 83ac104d342..f84411b1b72 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -14,9 +14,12 @@
The sum is:
- - - + + + + +

Goedemorgen!

+
From f58a41a1f60f127fa7d423fdf9f8c2d2301980f3 Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 16:10:21 +0200 Subject: [PATCH 10/18] [IMP] awesome_dashboard: set component to use search/layout --- awesome_dashboard/static/src/dashboard.js | 2 ++ awesome_dashboard/static/src/dashboard.scss | 3 +++ awesome_dashboard/static/src/dashboard.xml | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 awesome_dashboard/static/src/dashboard.scss diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index c4fb245621b..e1297aadeb4 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -1,8 +1,10 @@ import { Component } from "@odoo/owl"; import { registry } from "@web/core/registry"; +import { Layout } from "@web/search/layout"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; + static components = { Layout }; } registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard); diff --git a/awesome_dashboard/static/src/dashboard.scss b/awesome_dashboard/static/src/dashboard.scss new file mode 100644 index 00000000000..19074e8e411 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard.scss @@ -0,0 +1,3 @@ +.o_dashboard { + background-color: aquamarine; +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml index 1a2ac9a2fed..2044f2e24ce 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -2,7 +2,10 @@ - hello dashboard + From 9741c4ecc03ea296447ce17923b3876411e941ad Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 16:23:12 +0200 Subject: [PATCH 11/18] [IMP] awesome_dahboard: Add nav butons --- awesome_dashboard/static/src/dashboard.js | 13 +++++++++++++ awesome_dashboard/static/src/dashboard.xml | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index e1297aadeb4..7d05a583c52 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -1,10 +1,23 @@ import { Component } from "@odoo/owl"; import { registry } from "@web/core/registry"; +import { useService } from "@web/core/utils/hooks"; import { Layout } from "@web/search/layout"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; static components = { Layout }; + + setup() { + this.action = useService("action"); + } + + async openCustomers() { + this.action.doAction("base.action_partner_form", {}); + } + + async openLeads() { + this.action.doAction("crm.crm_lead_all_leads"); + } } registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard); diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml index 2044f2e24ce..81d4517baf6 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -2,6 +2,15 @@ +
+ + +
+ Date: Thu, 23 Jul 2026 16:42:37 +0200 Subject: [PATCH 12/18] [IMP] awesome_dashboard: Add cards to dashboard --- awesome_dashboard/static/src/dashboard.js | 4 +++- awesome_dashboard/static/src/dashboard.xml | 8 +++++++- .../static/src/dashboard_item/dashboard_item.js | 15 +++++++++++++++ .../static/src/dashboard_item/dashboard_item.xml | 10 ++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 awesome_dashboard/static/src/dashboard_item/dashboard_item.js create mode 100644 awesome_dashboard/static/src/dashboard_item/dashboard_item.xml diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index 7d05a583c52..a884bf3609e 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -3,9 +3,11 @@ import { registry } from "@web/core/registry"; import { useService } from "@web/core/utils/hooks"; import { Layout } from "@web/search/layout"; +import {DashboardItem} from "./dashboard_item/dashboard_item"; + class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; - static components = { Layout }; + static components = { Layout, DashboardItem }; setup() { this.action = useService("action"); diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml index 81d4517baf6..57d8612b710 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -14,7 +14,13 @@ + > +
+ Card 1 + Long schlong + TWOOOooooo +
+
diff --git a/awesome_dashboard/static/src/dashboard_item/dashboard_item.js b/awesome_dashboard/static/src/dashboard_item/dashboard_item.js new file mode 100644 index 00000000000..75a3f50dd01 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard_item/dashboard_item.js @@ -0,0 +1,15 @@ +import { Component } from "@odoo/owl"; + +export class DashboardItem extends Component { + static template = "awesome_dashboard.DashboardItem"; + static props = { + size: { + type: Number, + default: 1, + optional: true, + }, + slots: { + type: Object, + } + } +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard_item/dashboard_item.xml b/awesome_dashboard/static/src/dashboard_item/dashboard_item.xml new file mode 100644 index 00000000000..ddcc3fefdfe --- /dev/null +++ b/awesome_dashboard/static/src/dashboard_item/dashboard_item.xml @@ -0,0 +1,10 @@ + + + + +
+ +
+
+ +
\ No newline at end of file From 94b07768853f2408dfb761758b105a70f4eb7142 Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 17:06:23 +0200 Subject: [PATCH 13/18] [IMP] awesome_dashboard: rpc and caching --- awesome_dashboard/static/src/dashboard.js | 13 +++++++++++-- awesome_dashboard/static/src/dashboard.xml | 7 ++++--- awesome_dashboard/static/src/statistics.js | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 awesome_dashboard/static/src/statistics.js diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index a884bf3609e..58778736d9e 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -1,9 +1,9 @@ -import { Component } from "@odoo/owl"; +import { Component, onWillStart, useState } from "@odoo/owl"; import { registry } from "@web/core/registry"; import { useService } from "@web/core/utils/hooks"; import { Layout } from "@web/search/layout"; -import {DashboardItem} from "./dashboard_item/dashboard_item"; +import { DashboardItem } from "./dashboard_item/dashboard_item"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; @@ -11,6 +11,15 @@ class AwesomeDashboard extends Component { setup() { this.action = useService("action"); + this.statistics = useService("statistics"); + this.stats = useState({}); + + onWillStart(async () => { + const result = await this.statistics.loadStatistics(); + for (const [key, value] of Object.entries(result)) { + this.stats[key] = value; + } + }); } async openCustomers() { diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml index 57d8612b710..a56e855ac2a 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -16,9 +16,10 @@ display="{controlPanel: {}}" >
- Card 1 - Long schlong - TWOOOooooo + Number of new orders this month: + Total orders: + Average amount of t-shirt by order: + Average time order goes from NEW to SENT/CANCELLED:
diff --git a/awesome_dashboard/static/src/statistics.js b/awesome_dashboard/static/src/statistics.js new file mode 100644 index 00000000000..8d5aa3436c0 --- /dev/null +++ b/awesome_dashboard/static/src/statistics.js @@ -0,0 +1,17 @@ +import { registry } from "@web/core/registry"; +import { memoize } from "@web/core/utils/functions"; +import { rpc } from "@web/core/network/rpc"; + +const statisticsService = { + start() { + return { + loadStatistics: memoize(async () => { + const result = await rpc("/awesome_dashboard/statistics"); + console.log(result); + return result; + }), + } + } +}; + +registry.category("services").add("statistics", statisticsService); \ No newline at end of file From bc0d6f7b1c94efa3532072a3fc60cbbc1b5195ec Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Thu, 23 Jul 2026 17:44:30 +0200 Subject: [PATCH 14/18] [IMP] awesome_dashboard: Add pie chart --- awesome_dashboard/static/src/dashboard.js | 4 +- awesome_dashboard/static/src/dashboard.xml | 1 + awesome_dashboard/static/src/pie_chart.js | 66 ++++++++++++++++++++++ awesome_dashboard/static/src/pie_chart.xml | 12 ++++ 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 awesome_dashboard/static/src/pie_chart.js create mode 100644 awesome_dashboard/static/src/pie_chart.xml diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index 58778736d9e..16106543c7f 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -4,10 +4,10 @@ import { useService } from "@web/core/utils/hooks"; import { Layout } from "@web/search/layout"; import { DashboardItem } from "./dashboard_item/dashboard_item"; - +import { PieChart } from "./pie_chart"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; - static components = { Layout, DashboardItem }; + static components = { Layout, DashboardItem, PieChart }; setup() { this.action = useService("action"); diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml index a56e855ac2a..a59699e499c 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -20,6 +20,7 @@ Total orders: Average amount of t-shirt by order: Average time order goes from NEW to SENT/CANCELLED: + Shirt orders by size: diff --git a/awesome_dashboard/static/src/pie_chart.js b/awesome_dashboard/static/src/pie_chart.js new file mode 100644 index 00000000000..65ec6ad7472 --- /dev/null +++ b/awesome_dashboard/static/src/pie_chart.js @@ -0,0 +1,66 @@ +import { Component, onWillStart, useEffect, onWillUnmount, useRef } from "@odoo/owl"; +import { loadJS } from "@web/core/assets"; + +export class PieChart extends Component { + static template = "awesome_dashboard.PieChart"; + static props = { + // ERROR; Redirection through props/useState fails meta-function application! + // eg this.props.stats.keys() won't return what you think! + stats: { + type: Object, + shape: { + m: Number, + s: Number, + xl: Number, + } + }, + slots: { type: Object, optional: true }, + }; + + setup() { + this.chart = null; + this.canvasRef = useRef("canvas"); + + onWillStart(async () => { + // Injects the script directly into the frontend + await loadJS("/web/static/lib/Chart/Chart.js"); + }); + useEffect(() => this.renderChart()); + onWillUnmount(this.onWillUnmount); + } + + onWillUnmount() { + if (this.chart) { + this.chart.destroy(); + } + } + + getChartConfig() { + const stats = this.props.stats; + console.log(stats); + return { + type: 'doughnut', + data: { + datasets: [{ + data: [stats.m, stats.s, stats.xl], + }], + labels: ["m", "s", "xl"], + }, + options: {}, + }; + } + + // NOTE; Ripped from https://github.com/odoo/odoo/blob/1f4e583ba20a01f4c44b0a4ada42c4d3bb074273/addons/web/static/src/views/graph/graph_renderer.js#L618 + renderChart() { + if (this.chart) { + this.chart.destroy(); + } + const config = this.getChartConfig(); + this.chart = new Chart(this.canvasRef.el, config); + // To perform its animations, ChartJS will perform each animation + // step in the next animation frame. The initial rendering itself + // is delayed for consistency. We can avoid this by manually + // advancing the animation service. + // (?) Chart.animationService.advance(); + } +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/pie_chart.xml b/awesome_dashboard/static/src/pie_chart.xml new file mode 100644 index 00000000000..c96665f48b0 --- /dev/null +++ b/awesome_dashboard/static/src/pie_chart.xml @@ -0,0 +1,12 @@ + + + + +
+
+ +
+
+
+ +
\ No newline at end of file From 00cea30e07ecaaaedae6e9c838f4c084a5bbbe0e Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Fri, 24 Jul 2026 10:27:53 +0200 Subject: [PATCH 15/18] [IMP] awesome_dashboard: automated statistics --- awesome_dashboard/static/src/dashboard.js | 4 +++- awesome_dashboard/static/src/statistics.js | 24 +++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index 16106543c7f..d75b62f0ae4 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -12,10 +12,12 @@ class AwesomeDashboard extends Component { setup() { this.action = useService("action"); this.statistics = useService("statistics"); - this.stats = useState({}); + this.stats = this.statistics.onUpdate; onWillStart(async () => { const result = await this.statistics.loadStatistics(); + // WARN; Perform immediate/synchronous update of state because sub-components + // logic isn't safeguarded against undefined values. for (const [key, value] of Object.entries(result)) { this.stats[key] = value; } diff --git a/awesome_dashboard/static/src/statistics.js b/awesome_dashboard/static/src/statistics.js index 8d5aa3436c0..f66e37b2d42 100644 --- a/awesome_dashboard/static/src/statistics.js +++ b/awesome_dashboard/static/src/statistics.js @@ -1,16 +1,30 @@ import { registry } from "@web/core/registry"; -import { memoize } from "@web/core/utils/functions"; import { rpc } from "@web/core/network/rpc"; +import { reactive } from "@odoo/owl"; const statisticsService = { start() { - return { - loadStatistics: memoize(async () => { + let reactivePayload = reactive({}); + let state = { timer: undefined}; + const service = { + onUpdate: () => reactivePayload, + loadStatistics: async () => { const result = await rpc("/awesome_dashboard/statistics"); console.log(result); - return result; - }), + let data = {}; + for (const [key, value] of Object.entries(result)) { + data[key] = value; + } + reactivePayload = data; + if(state.timer === undefined) { + // state.timer = setInterval(() => service.loadStatistics(), 600000); // 10 minutes + state.timer = setInterval(() => service.loadStatistics(), 10000); // 10 seconds + } + return data; + }, } + + return service; } }; From eb3a3a60e97305f191f460ce3034d72dc83e852b Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Fri, 24 Jul 2026 10:50:44 +0200 Subject: [PATCH 16/18] [IMP] awesome_dashboard: lazy load the dashboard --- .../static/src/{ => dashboard}/dashboard.js | 3 ++- .../static/src/{ => dashboard}/dashboard.scss | 0 .../static/src/{ => dashboard}/dashboard.xml | 0 .../dashboard_item/dashboard_item.js | 0 .../dashboard_item/dashboard_item.xml | 0 .../static/src/{ => dashboard}/pie_chart.js | 0 .../static/src/{ => dashboard}/pie_chart.xml | 0 .../static/src/lazy_dashboard_loader.js | 19 +++++++++++++++++++ 8 files changed, 21 insertions(+), 1 deletion(-) rename awesome_dashboard/static/src/{ => dashboard}/dashboard.js (93%) rename awesome_dashboard/static/src/{ => dashboard}/dashboard.scss (100%) rename awesome_dashboard/static/src/{ => dashboard}/dashboard.xml (100%) rename awesome_dashboard/static/src/{ => dashboard}/dashboard_item/dashboard_item.js (100%) rename awesome_dashboard/static/src/{ => dashboard}/dashboard_item/dashboard_item.xml (100%) rename awesome_dashboard/static/src/{ => dashboard}/pie_chart.js (100%) rename awesome_dashboard/static/src/{ => dashboard}/pie_chart.xml (100%) create mode 100644 awesome_dashboard/static/src/lazy_dashboard_loader.js diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js similarity index 93% rename from awesome_dashboard/static/src/dashboard.js rename to awesome_dashboard/static/src/dashboard/dashboard.js index d75b62f0ae4..4c2f50b58bf 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -5,6 +5,7 @@ import { Layout } from "@web/search/layout"; import { DashboardItem } from "./dashboard_item/dashboard_item"; import { PieChart } from "./pie_chart"; + class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; static components = { Layout, DashboardItem, PieChart }; @@ -33,4 +34,4 @@ class AwesomeDashboard extends Component { } } -registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard); +registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard); diff --git a/awesome_dashboard/static/src/dashboard.scss b/awesome_dashboard/static/src/dashboard/dashboard.scss similarity index 100% rename from awesome_dashboard/static/src/dashboard.scss rename to awesome_dashboard/static/src/dashboard/dashboard.scss diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml similarity index 100% rename from awesome_dashboard/static/src/dashboard.xml rename to awesome_dashboard/static/src/dashboard/dashboard.xml diff --git a/awesome_dashboard/static/src/dashboard_item/dashboard_item.js b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.js similarity index 100% rename from awesome_dashboard/static/src/dashboard_item/dashboard_item.js rename to awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.js diff --git a/awesome_dashboard/static/src/dashboard_item/dashboard_item.xml b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.xml similarity index 100% rename from awesome_dashboard/static/src/dashboard_item/dashboard_item.xml rename to awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.xml diff --git a/awesome_dashboard/static/src/pie_chart.js b/awesome_dashboard/static/src/dashboard/pie_chart.js similarity index 100% rename from awesome_dashboard/static/src/pie_chart.js rename to awesome_dashboard/static/src/dashboard/pie_chart.js diff --git a/awesome_dashboard/static/src/pie_chart.xml b/awesome_dashboard/static/src/dashboard/pie_chart.xml similarity index 100% rename from awesome_dashboard/static/src/pie_chart.xml rename to awesome_dashboard/static/src/dashboard/pie_chart.xml diff --git a/awesome_dashboard/static/src/lazy_dashboard_loader.js b/awesome_dashboard/static/src/lazy_dashboard_loader.js new file mode 100644 index 00000000000..a5d46931a3d --- /dev/null +++ b/awesome_dashboard/static/src/lazy_dashboard_loader.js @@ -0,0 +1,19 @@ +import { Component, xml } from "@odoo/owl"; +import { registry } from "@web/core/registry"; +import { LazyComponent } from "@web/core/assets"; + +class LazyDashboardLoader extends Component { + static components = {LazyComponent}; + static template = xml` + + `; +} + +class DashboardAction extends Component { + static components = {LazyDashboardLoader}; + static template = xml` + + `; +} + +registry.category("actions").add("awesome_dashboard.dashboard", DashboardAction); \ No newline at end of file From 5be8f7a4b158cfbd8ce0c8a15688b0f104e3de17 Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Fri, 24 Jul 2026 11:13:25 +0200 Subject: [PATCH 17/18] [IMP] awesome_dashboard: Make dashboard generic --- .../static/src/dashboard/dashboard.js | 10 ++-- .../static/src/dashboard/dashboard.xml | 15 +++-- .../dashboard_item/dashboard_items.js | 60 +++++++++++++++++++ .../dashboard/dashboard_item/number_card.js | 17 ++++++ .../dashboard/dashboard_item/number_card.xml | 9 +++ .../dashboard_item/pie_chart_card.js | 19 ++++++ .../dashboard_item/pie_chart_card.xml | 9 +++ 7 files changed, 127 insertions(+), 12 deletions(-) create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_items.js create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_item/number_card.js create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_item/number_card.xml create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_item/pie_chart_card.js create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_item/pie_chart_card.xml diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index 4c2f50b58bf..c99c2f6e71c 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -5,6 +5,7 @@ import { Layout } from "@web/search/layout"; import { DashboardItem } from "./dashboard_item/dashboard_item"; import { PieChart } from "./pie_chart"; +import { items } from "./dashboard_item/dashboard_items"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; @@ -12,15 +13,16 @@ class AwesomeDashboard extends Component { setup() { this.action = useService("action"); - this.statistics = useService("statistics"); - this.stats = this.statistics.onUpdate; + this.statService = useService("statistics"); + this.statistics = this.statService.onUpdate; + this.items = items; onWillStart(async () => { - const result = await this.statistics.loadStatistics(); + const result = await this.statService.loadStatistics(); // WARN; Perform immediate/synchronous update of state because sub-components // logic isn't safeguarded against undefined values. for (const [key, value] of Object.entries(result)) { - this.stats[key] = value; + this.statistics[key] = value; } }); } diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml index a59699e499c..18077b45e7a 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -12,16 +12,15 @@ -
- Number of new orders this month: - Total orders: - Average amount of t-shirt by order: - Average time order goes from NEW to SENT/CANCELLED: - Shirt orders by size: -
+ + + + + +
diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_items.js b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_items.js new file mode 100644 index 00000000000..b9d8ffd03da --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_items.js @@ -0,0 +1,60 @@ +import { NumberCard } from "./number_card"; +import { PieChartCard } from "./pie_chart_card"; + +export const items = [ + { + id: "average_quantity", + description: "Average amount of t-shirt", + Component: NumberCard, + props: (data) => ({ + title: "Average amount of t-shirt by order this month", + value: data.average_quantity, + }) + }, + { + id: "average_time", + description: "Average time for an order", + Component: NumberCard, + props: (data) => ({ + title: "Average time for an order to go from 'new' to 'sent' or 'cancelled'", + value: data.average_time, + }) + }, + { + id: "number_new_orders", + description: "New orders this month", + Component: NumberCard, + props: (data) => ({ + title: "Number of new orders this month", + value: data.nb_new_orders, + }) + }, + { + id: "cancelled_orders", + description: "Cancelled orders this month", + Component: NumberCard, + props: (data) => ({ + title: "Number of cancelled orders this month", + value: data.nb_cancelled_orders, + }) + }, + { + id: "amount_new_orders", + description: "amount orders this month", + Component: NumberCard, + props: (data) => ({ + title: "Total amount of new orders this month", + value: data.total_amount, + }) + }, + { + id: "pie_chart", + description: "Shirt orders by size", + Component: PieChartCard, + size: 2, + props: (data) => ({ + title: "Shirt orders by size", + values: data.orders_by_size, + }) + } +] \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item/number_card.js b/awesome_dashboard/static/src/dashboard/dashboard_item/number_card.js new file mode 100644 index 00000000000..3b1e614ad34 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_item/number_card.js @@ -0,0 +1,17 @@ +import { Component } from "@odoo/owl"; + +export class NumberCard extends Component { + static template = "awesome_dashboard.NumberCard"; + static props = { + size: { + type: Number, + default: 1, + optional: true, + }, + title: {type: String}, + value: {type: String}, + slots: { + type: Object, + } + } +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item/number_card.xml b/awesome_dashboard/static/src/dashboard/dashboard_item/number_card.xml new file mode 100644 index 00000000000..f5ac696dcef --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_item/number_card.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item/pie_chart_card.js b/awesome_dashboard/static/src/dashboard/dashboard_item/pie_chart_card.js new file mode 100644 index 00000000000..c8d866c0c45 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_item/pie_chart_card.js @@ -0,0 +1,19 @@ +import { Component } from "@odoo/owl"; +import { PieChart } from "../pie_chart"; + +export class PieChartCard extends Component { + static components = { PieChart }; + static template = "awesome_dashboard.PieChartCard"; + static props = { + size: { + type: Number, + default: 1, + optional: true, + }, + title: {type: String}, + values: {type: Object}, + slots: { + type: Object, + } + } +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item/pie_chart_card.xml b/awesome_dashboard/static/src/dashboard/dashboard_item/pie_chart_card.xml new file mode 100644 index 00000000000..73ddb049805 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_item/pie_chart_card.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file From 4b13312519efdc1e98c15857f05f7848cfd61dfc Mon Sep 17 00:00:00 2001 From: "bepro@odoo" Date: Fri, 24 Jul 2026 11:31:44 +0200 Subject: [PATCH 18/18] [IMP] awesome_dashboard: dynamic dashboard items --- .../static/src/dashboard/dashboard.js | 58 ++++++++++++++++++- .../static/src/dashboard/dashboard.xml | 21 ++++++- .../dashboard_item/dashboard_items.js | 11 +++- 3 files changed, 85 insertions(+), 5 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index c99c2f6e71c..2dc2a3bbb51 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -2,10 +2,47 @@ import { Component, onWillStart, useState } from "@odoo/owl"; import { registry } from "@web/core/registry"; import { useService } from "@web/core/utils/hooks"; import { Layout } from "@web/search/layout"; +import { Dialog } from "@web/core/dialog/dialog"; +import { browser } from "@web/core/browser/browser"; +import { CheckBox } from "@web/core/checkbox/checkbox"; + import { DashboardItem } from "./dashboard_item/dashboard_item"; import { PieChart } from "./pie_chart"; -import { items } from "./dashboard_item/dashboard_items"; + +class ConfigurationDialog extends Component { + static template = "awesome_dashboard.ConfigurationDialog"; + static components = { Dialog, CheckBox }; + static props = ["close", "items", "disabledItems", "onUpdateConfiguration"]; + + setup() { + this.items = useState(this.props.items.map((item) => { + return { + ...item, + enabled: !this.props.disabledItems.includes(item.id), + } + })); + } + + done() { + this.props.close(); + } + + onChange(checked, changedItem) { + changedItem.enabled = checked; + const newDisabledItems = Object.values(this.items).filter( + (item) => !item.enabled + ).map((item) => item.id) + + browser.localStorage.setItem( + "disabledDashboardItems", + newDisabledItems, + ); + + this.props.onUpdateConfiguration(newDisabledItems); + } + +} class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; @@ -15,7 +52,12 @@ class AwesomeDashboard extends Component { this.action = useService("action"); this.statService = useService("statistics"); this.statistics = this.statService.onUpdate; - this.items = items; + this.items = registry.category("awesome_dashboard").getAll(); + this.dialog = useService("dialog"); + this.state = useState({ + // NOTE; ConfigurationDialog performs saving into browser local storage + disabledItems: browser.localStorage.getItem("disabledDashboardItems")?.split(",") || [], + }) onWillStart(async () => { const result = await this.statService.loadStatistics(); @@ -34,6 +76,18 @@ class AwesomeDashboard extends Component { async openLeads() { this.action.doAction("crm.crm_lead_all_leads"); } + + async openSettings() { + this.dialog.add(ConfigurationDialog, { + items: this.items, + disabledItems: this.state.disabledItems, + onUpdateConfiguration: this.updateConfiguration.bind(this), + }) + } + + async updateConfiguration(newDisabledItems) { + this.state.disabledItems = newDisabledItems; + } } registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard); diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml index 18077b45e7a..56989c3471d 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -9,6 +9,9 @@ + - + @@ -24,4 +27,20 @@ + + + Which cards do you whish to see ? + + + + + + + + + + + diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_items.js b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_items.js index b9d8ffd03da..4ba1c2d1e5c 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_items.js +++ b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_items.js @@ -1,7 +1,9 @@ +import { registry } from "@web/core/registry"; + import { NumberCard } from "./number_card"; import { PieChartCard } from "./pie_chart_card"; -export const items = [ +const items = [ { id: "average_quantity", description: "Average amount of t-shirt", @@ -57,4 +59,9 @@ export const items = [ values: data.orders_by_size, }) } -] \ No newline at end of file +]; + +const dashboard_registry = registry.category("awesome_dashboard"); +items.forEach(element => { + dashboard_registry.add(element.description, element); +}); \ No newline at end of file