From dfc238748dc2c20c430074d96b5630ab681cacd0 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Mon, 22 Sep 2025 16:17:34 +0200 Subject: [PATCH 01/32] [IMP] awesome_owl: free me from this pain --- awesome_owl/static/src/card/card.js | 10 ++++++++++ awesome_owl/static/src/card/card.xml | 15 +++++++++++++++ awesome_owl/static/src/counter/counter.js | 13 +++++++++++++ awesome_owl/static/src/counter/counter.xml | 11 +++++++++++ awesome_owl/static/src/playground.js | 5 +++-- awesome_owl/static/src/playground.xml | 3 +++ 6 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 awesome_owl/static/src/card/card.js create mode 100644 awesome_owl/static/src/card/card.xml 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/card/card.js b/awesome_owl/static/src/card/card.js new file mode 100644 index 00000000000..74c61f2e79b --- /dev/null +++ b/awesome_owl/static/src/card/card.js @@ -0,0 +1,10 @@ +import { Component, useState } from "@odoo/owl"; + +export class Card extends Component { + static template = "awesome_owl.card"; + static props = { title: {type: String}, content: {type: String}} + + setup() { + this.state = { title: this.props.title, content: this.props.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..03cd1ebaac4 --- /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/counter/counter.js b/awesome_owl/static/src/counter/counter.js new file mode 100644 index 00000000000..d7d577e830e --- /dev/null +++ b/awesome_owl/static/src/counter/counter.js @@ -0,0 +1,13 @@ +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..70a2b0655fa --- /dev/null +++ b/awesome_owl/static/src/counter/counter.xml @@ -0,0 +1,11 @@ + + + + +
+

Counter:

+ +
+
+ +
\ No newline at end of file diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 657fb8b07bb..aaf1f79299f 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,7 +1,8 @@ -/** @odoo-module **/ - import { Component } 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, Card } } diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4fb905d59f9..4a01c414589 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -5,6 +5,9 @@
hello world
+ + + From f7b4680fbda0f468470dc25495167eadb2bcb05f Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Mon, 22 Sep 2025 16:53:29 +0200 Subject: [PATCH 02/32] [IMP] awesome_owl: save this counter implementation because I like it better than the actual solution --- awesome_owl/static/src/card/card.js | 3 ++- awesome_owl/static/src/card/card.xml | 4 ++-- awesome_owl/static/src/counter/counter.js | 7 ++++++- awesome_owl/static/src/playground.js | 13 ++++++++++++- awesome_owl/static/src/playground.xml | 6 +++++- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js index 74c61f2e79b..f75c3f35473 100644 --- a/awesome_owl/static/src/card/card.js +++ b/awesome_owl/static/src/card/card.js @@ -5,6 +5,7 @@ export class Card extends Component { static props = { title: {type: String}, content: {type: String}} setup() { - this.state = { title: this.props.title, content: this.props.content }; + this.title = this.props.title; + this.content = this.props.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 index 03cd1ebaac4..b2f5c97f749 100644 --- a/awesome_owl/static/src/card/card.xml +++ b/awesome_owl/static/src/card/card.xml @@ -4,9 +4,9 @@
-
+

- +

diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js index d7d577e830e..30697178f0b 100644 --- a/awesome_owl/static/src/counter/counter.js +++ b/awesome_owl/static/src/counter/counter.js @@ -2,12 +2,17 @@ import { Component, useState } from "@odoo/owl"; export class Counter extends Component { static template = "awesome_owl.counter"; + static props = { + value: {optional: true}, + side_effect: {type: Function, optional: true} + } setup() { - this.state = useState({ value: 0 }); + this.state = useState({ value: this.props.value? this.props.value : 0 }); } increment() { + this.props.side_effect ? this.props.side_effect() : true; this.state.value++; } } \ No newline at end of file diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index aaf1f79299f..d3d26c5cd76 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,8 +1,19 @@ -import { Component } from "@odoo/owl"; +import { Component, markup, 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, Card } + + setup() { + this.str1 = "
some content
"; + this.str2 = markup("
some content
"); + this.state = useState({ val1: 0, val2: 10 }) + } + + get sum() { + return this.state.val1 + this.state.val2 + } + } diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4a01c414589..3c059847ec5 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -5,9 +5,13 @@
hello world
- + + +
The sum is:
+ +
From dc2211ed84b82699de69ed1fdd9e856453884799 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Mon, 22 Sep 2025 17:29:12 +0200 Subject: [PATCH 03/32] [IMP] awesome_owl: add up to section 7 --- awesome_owl/static/src/card/card.xml | 4 ++-- awesome_owl/static/src/playground.js | 3 ++- awesome_owl/static/src/playground.xml | 2 ++ awesome_owl/static/src/todo_list/todo_item.js | 10 ++++++++++ awesome_owl/static/src/todo_list/todo_item.xml | 12 ++++++++++++ awesome_owl/static/src/todo_list/todo_list.js | 11 +++++++++++ awesome_owl/static/src/todo_list/todo_list.xml | 14 ++++++++++++++ 7 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 awesome_owl/static/src/todo_list/todo_item.js create mode 100644 awesome_owl/static/src/todo_list/todo_item.xml create mode 100644 awesome_owl/static/src/todo_list/todo_list.js create mode 100644 awesome_owl/static/src/todo_list/todo_list.xml diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml index b2f5c97f749..aa84288ea58 100644 --- a/awesome_owl/static/src/card/card.xml +++ b/awesome_owl/static/src/card/card.xml @@ -4,9 +4,9 @@
-
+

- +

diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index d3d26c5cd76..4dd10ad255c 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,10 +1,11 @@ import { Component, markup, useState } from "@odoo/owl"; import { Counter } from "./counter/counter"; import { Card } from "./card/card"; +import { TodoList } from "./todo_list/todo_list"; export class Playground extends Component { static template = "awesome_owl.playground"; - static components = { Counter, Card } + static components = { Counter, Card, TodoList } setup() { this.str1 = "
some content
"; diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 3c059847ec5..22b858bd2bf 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -12,6 +12,8 @@ + +
diff --git a/awesome_owl/static/src/todo_list/todo_item.js b/awesome_owl/static/src/todo_list/todo_item.js new file mode 100644 index 00000000000..639eb322bf6 --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_item.js @@ -0,0 +1,10 @@ +import { Component, useState } from "@odoo/owl"; + +export class TodoItem extends Component { + static template = "awesome_owl.todo_item" + static props = { todo: {type: {id: Number, description: String, isCompleted: Boolean}} } + + setup() { + this.todo = useState(this.props.todo) + } +} \ No newline at end of file diff --git a/awesome_owl/static/src/todo_list/todo_item.xml b/awesome_owl/static/src/todo_list/todo_item.xml new file mode 100644 index 00000000000..009c07ef390 --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_item.xml @@ -0,0 +1,12 @@ + + + + +
+

+ . +

+
+
+ +
\ No newline at end of file diff --git a/awesome_owl/static/src/todo_list/todo_list.js b/awesome_owl/static/src/todo_list/todo_list.js new file mode 100644 index 00000000000..a1fe3cc54cf --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_list.js @@ -0,0 +1,11 @@ +import { Component, useState } from "@odoo/owl"; +import { TodoItem } from "./todo_item"; + +export class TodoList extends Component { + static template = "awesome_owl.todo_list" + static components = { TodoItem } + + setup() { + this.todos = useState([{ id: 3, description: "buy milk", isCompleted: false }]); + } +} \ No newline at end of file diff --git a/awesome_owl/static/src/todo_list/todo_list.xml b/awesome_owl/static/src/todo_list/todo_list.xml new file mode 100644 index 00000000000..a39aa0cf306 --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_list.xml @@ -0,0 +1,14 @@ + + + + +
+
+ + + +
+
+
+ +
\ No newline at end of file From a22285a28f5c0af93e3077a44a6864d7e39335e8 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 08:58:27 +0200 Subject: [PATCH 04/32] [IMP] awesome_owl: apply PR suggestions --- awesome_owl/static/src/card/card.js | 2 +- awesome_owl/static/src/card/card.xml | 4 ++-- awesome_owl/static/src/counter/counter.js | 2 +- awesome_owl/static/src/counter/counter.xml | 2 +- awesome_owl/static/src/todo_list/todo_item.js | 2 +- awesome_owl/static/src/todo_list/todo_item.xml | 2 +- awesome_owl/static/src/todo_list/todo_list.js | 2 +- awesome_owl/static/src/todo_list/todo_list.xml | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js index f75c3f35473..7269802b664 100644 --- a/awesome_owl/static/src/card/card.js +++ b/awesome_owl/static/src/card/card.js @@ -8,4 +8,4 @@ export class Card extends Component { this.title = this.props.title; this.content = this.props.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 index aa84288ea58..02a3b647317 100644 --- a/awesome_owl/static/src/card/card.xml +++ b/awesome_owl/static/src/card/card.xml @@ -6,10 +6,10 @@

- +

- \ No newline at end of file + diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js index 30697178f0b..7c6bd3deb59 100644 --- a/awesome_owl/static/src/counter/counter.js +++ b/awesome_owl/static/src/counter/counter.js @@ -15,4 +15,4 @@ export class Counter extends Component { this.props.side_effect ? this.props.side_effect() : true; 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 index 70a2b0655fa..f20e162d294 100644 --- a/awesome_owl/static/src/counter/counter.xml +++ b/awesome_owl/static/src/counter/counter.xml @@ -8,4 +8,4 @@ - \ No newline at end of file + diff --git a/awesome_owl/static/src/todo_list/todo_item.js b/awesome_owl/static/src/todo_list/todo_item.js index 639eb322bf6..95e0a5dfa7c 100644 --- a/awesome_owl/static/src/todo_list/todo_item.js +++ b/awesome_owl/static/src/todo_list/todo_item.js @@ -7,4 +7,4 @@ export class TodoItem extends Component { setup() { this.todo = useState(this.props.todo) } -} \ No newline at end of file +} diff --git a/awesome_owl/static/src/todo_list/todo_item.xml b/awesome_owl/static/src/todo_list/todo_item.xml index 009c07ef390..8488259c404 100644 --- a/awesome_owl/static/src/todo_list/todo_item.xml +++ b/awesome_owl/static/src/todo_list/todo_item.xml @@ -9,4 +9,4 @@ - \ No newline at end of file + diff --git a/awesome_owl/static/src/todo_list/todo_list.js b/awesome_owl/static/src/todo_list/todo_list.js index a1fe3cc54cf..b8d705ccc3a 100644 --- a/awesome_owl/static/src/todo_list/todo_list.js +++ b/awesome_owl/static/src/todo_list/todo_list.js @@ -8,4 +8,4 @@ export class TodoList extends Component { setup() { this.todos = useState([{ id: 3, description: "buy milk", isCompleted: false }]); } -} \ No newline at end of file +} diff --git a/awesome_owl/static/src/todo_list/todo_list.xml b/awesome_owl/static/src/todo_list/todo_list.xml index a39aa0cf306..b6fd8566805 100644 --- a/awesome_owl/static/src/todo_list/todo_list.xml +++ b/awesome_owl/static/src/todo_list/todo_list.xml @@ -11,4 +11,4 @@ - \ No newline at end of file + From 8611d610ec4401e486429ab9e8097ce085f60b69 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 09:46:19 +0200 Subject: [PATCH 05/32] [IMP] awesome_owl: add sections 8-10 --- awesome_owl/static/src/todo_list/todo_item.xml | 2 +- awesome_owl/static/src/todo_list/todo_list.js | 18 ++++++++++++++++-- awesome_owl/static/src/todo_list/todo_list.xml | 10 ++++++++-- awesome_owl/static/src/utils.js | 9 +++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 awesome_owl/static/src/utils.js diff --git a/awesome_owl/static/src/todo_list/todo_item.xml b/awesome_owl/static/src/todo_list/todo_item.xml index 8488259c404..4ed35b0a292 100644 --- a/awesome_owl/static/src/todo_list/todo_item.xml +++ b/awesome_owl/static/src/todo_list/todo_item.xml @@ -2,7 +2,7 @@ -
+

.

diff --git a/awesome_owl/static/src/todo_list/todo_list.js b/awesome_owl/static/src/todo_list/todo_list.js index b8d705ccc3a..52fc0d8eb49 100644 --- a/awesome_owl/static/src/todo_list/todo_list.js +++ b/awesome_owl/static/src/todo_list/todo_list.js @@ -1,11 +1,25 @@ -import { Component, useState } from "@odoo/owl"; +import { Component, useState, useRef, onMounted } from "@odoo/owl"; import { TodoItem } from "./todo_item"; +import { useAutoFocus } from "../utils"; export class TodoList extends Component { static template = "awesome_owl.todo_list" static components = { TodoItem } setup() { - this.todos = useState([{ id: 3, description: "buy milk", isCompleted: false }]); + useAutoFocus("todo-input") + this.state = useState({todos: [ + { id: 2, description: "penser à acheter du lait", isCompleted: false }, + { id: 3, description: "penser à acheter des tomates cerises", isCompleted: true } + ], + lastId: 3 + }); + } + + addTodo(ev) { + if (ev.keyCode === 13 && ev.target.value != "") { + this.state.todos.push({id: ++this.state.lastId, description: ev.target.value, isCompleted: false}); + ev.target.value = "" + } } } diff --git a/awesome_owl/static/src/todo_list/todo_list.xml b/awesome_owl/static/src/todo_list/todo_list.xml index b6fd8566805..50c03855232 100644 --- a/awesome_owl/static/src/todo_list/todo_list.xml +++ b/awesome_owl/static/src/todo_list/todo_list.xml @@ -3,8 +3,14 @@
-
- +
+ +
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js new file mode 100644 index 00000000000..1964cd7407a --- /dev/null +++ b/awesome_owl/static/src/utils.js @@ -0,0 +1,9 @@ +import { onMounted, useRef } from '@odoo/owl' + +export function useAutoFocus(refName) { + const inputRef = useRef(refName); + + onMounted(() => { + inputRef.el.focus(); + }); +} From 70e3c05c7e1b95b62073d094460bb73e09b8ff44 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 10:13:11 +0200 Subject: [PATCH 06/32] [IMP] awesome_owl: add section 11 --- awesome_owl/static/src/todo_list/todo_item.js | 8 +++++++- awesome_owl/static/src/todo_list/todo_item.xml | 3 ++- awesome_owl/static/src/todo_list/todo_list.js | 14 +++++++++----- awesome_owl/static/src/todo_list/todo_list.xml | 4 ++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/awesome_owl/static/src/todo_list/todo_item.js b/awesome_owl/static/src/todo_list/todo_item.js index 95e0a5dfa7c..303bafd8ec1 100644 --- a/awesome_owl/static/src/todo_list/todo_item.js +++ b/awesome_owl/static/src/todo_list/todo_item.js @@ -2,9 +2,15 @@ import { Component, useState } from "@odoo/owl"; export class TodoItem extends Component { static template = "awesome_owl.todo_item" - static props = { todo: {type: {id: Number, description: String, isCompleted: Boolean}} } + static props = { + id: String, + todo: {type: {description: String, isCompleted: Boolean}}, + toggleState: Function + } setup() { + this.id = this.props.id this.todo = useState(this.props.todo) + this.toggleState = this.props.toggleState } } diff --git a/awesome_owl/static/src/todo_list/todo_item.xml b/awesome_owl/static/src/todo_list/todo_item.xml index 4ed35b0a292..d68fa9ff14f 100644 --- a/awesome_owl/static/src/todo_list/todo_item.xml +++ b/awesome_owl/static/src/todo_list/todo_item.xml @@ -4,7 +4,8 @@

- . + + .

diff --git a/awesome_owl/static/src/todo_list/todo_list.js b/awesome_owl/static/src/todo_list/todo_list.js index 52fc0d8eb49..293d3abbf25 100644 --- a/awesome_owl/static/src/todo_list/todo_list.js +++ b/awesome_owl/static/src/todo_list/todo_list.js @@ -8,17 +8,21 @@ export class TodoList extends Component { setup() { useAutoFocus("todo-input") - this.state = useState({todos: [ - { id: 2, description: "penser à acheter du lait", isCompleted: false }, - { id: 3, description: "penser à acheter des tomates cerises", isCompleted: true } - ], + this.state = useState({todos: { + 2: { description: "penser à acheter du lait", isCompleted: false }, + 3: { description: "penser à acheter des tomates cerises", isCompleted: true } + }, lastId: 3 }); } + toggleState(id) { + this.state.todos[id].isCompleted = !this.state.todos[id].isCompleted + } + addTodo(ev) { if (ev.keyCode === 13 && ev.target.value != "") { - this.state.todos.push({id: ++this.state.lastId, description: ev.target.value, isCompleted: false}); + this.state.todos[++this.state.lastId] = {description: ev.target.value, isCompleted: false}; ev.target.value = "" } } diff --git a/awesome_owl/static/src/todo_list/todo_list.xml b/awesome_owl/static/src/todo_list/todo_list.xml index 50c03855232..b630f965c1a 100644 --- a/awesome_owl/static/src/todo_list/todo_list.xml +++ b/awesome_owl/static/src/todo_list/todo_list.xml @@ -10,8 +10,8 @@ placeholder="Enter something to do..." t-ref="todo-input" /> - - + +
From aa4125a51fed273d254ae18aa4276705e3a66b13 Mon Sep 17 00:00:00 2001 From: trcazier <100358304+trcazier@users.noreply.github.com> Date: Tue, 23 Sep 2025 10:16:50 +0200 Subject: [PATCH 07/32] [IMP] awesome_owl: replace redundant ternary operator with || MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cemal Faruk Güney <63407686+cgun-odoo@users.noreply.github.com> --- awesome_owl/static/src/counter/counter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js index 7c6bd3deb59..fd813d33580 100644 --- a/awesome_owl/static/src/counter/counter.js +++ b/awesome_owl/static/src/counter/counter.js @@ -8,7 +8,7 @@ export class Counter extends Component { } setup() { - this.state = useState({ value: this.props.value? this.props.value : 0 }); + this.state = useState({ value: this.props.value || 0}); } increment() { From bf99024cedb1b19387db19bf3869e94a3c8a0ec0 Mon Sep 17 00:00:00 2001 From: trcazier <100358304+trcazier@users.noreply.github.com> Date: Tue, 23 Sep 2025 10:17:14 +0200 Subject: [PATCH 08/32] [IMP] awesome_owl: replace redundant ternary operator with if MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cemal Faruk Güney <63407686+cgun-odoo@users.noreply.github.com> --- awesome_owl/static/src/counter/counter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js index fd813d33580..a6f1c3bc79b 100644 --- a/awesome_owl/static/src/counter/counter.js +++ b/awesome_owl/static/src/counter/counter.js @@ -12,7 +12,9 @@ export class Counter extends Component { } increment() { - this.props.side_effect ? this.props.side_effect() : true; + if (this.props.side_effect) { + this.props.side_effect(); + } this.state.value++; } } From 03af1dbfb18c5b6f9b1d319b913be45ac53dba51 Mon Sep 17 00:00:00 2001 From: trcazier <100358304+trcazier@users.noreply.github.com> Date: Tue, 23 Sep 2025 10:22:14 +0200 Subject: [PATCH 09/32] [IMP] awesome_owl: add missing ; MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cemal Faruk Güney <63407686+cgun-odoo@users.noreply.github.com> --- awesome_owl/static/src/todo_list/todo_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awesome_owl/static/src/todo_list/todo_list.js b/awesome_owl/static/src/todo_list/todo_list.js index 293d3abbf25..9eed22ead21 100644 --- a/awesome_owl/static/src/todo_list/todo_list.js +++ b/awesome_owl/static/src/todo_list/todo_list.js @@ -7,7 +7,7 @@ export class TodoList extends Component { static components = { TodoItem } setup() { - useAutoFocus("todo-input") + useAutoFocus("todo-input"); this.state = useState({todos: { 2: { description: "penser à acheter du lait", isCompleted: false }, 3: { description: "penser à acheter des tomates cerises", isCompleted: true } From 86806ecd4df887b17ac1f6cdfe8f6dbceb9502ac Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 10:29:25 +0200 Subject: [PATCH 10/32] [IMP] awesome_owl: add section 12 and missing ;s --- awesome_owl/static/src/counter/counter.js | 2 +- awesome_owl/static/src/playground.js | 2 +- awesome_owl/static/src/todo_list/todo_item.js | 10 ++++++---- awesome_owl/static/src/todo_list/todo_item.xml | 2 +- awesome_owl/static/src/todo_list/todo_list.js | 12 ++++++++---- awesome_owl/static/src/todo_list/todo_list.xml | 7 ++++++- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js index a6f1c3bc79b..507311848ed 100644 --- a/awesome_owl/static/src/counter/counter.js +++ b/awesome_owl/static/src/counter/counter.js @@ -5,7 +5,7 @@ export class Counter extends Component { static props = { value: {optional: true}, side_effect: {type: Function, optional: true} - } + }; setup() { this.state = useState({ value: this.props.value || 0}); diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 4dd10ad255c..c2f825cd293 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -14,7 +14,7 @@ export class Playground extends Component { } get sum() { - return this.state.val1 + this.state.val2 + return this.state.val1 + this.state.val2; } } diff --git a/awesome_owl/static/src/todo_list/todo_item.js b/awesome_owl/static/src/todo_list/todo_item.js index 303bafd8ec1..7807fa30af4 100644 --- a/awesome_owl/static/src/todo_list/todo_item.js +++ b/awesome_owl/static/src/todo_list/todo_item.js @@ -5,12 +5,14 @@ export class TodoItem extends Component { static props = { id: String, todo: {type: {description: String, isCompleted: Boolean}}, - toggleState: Function + toggleState: Function, + removeTodo: Function } setup() { - this.id = this.props.id - this.todo = useState(this.props.todo) - this.toggleState = this.props.toggleState + this.id = this.props.id; + this.todo = useState(this.props.todo); + this.toggleState = this.props.toggleState; + this.removeTodo = this.props.removeTodo; } } diff --git a/awesome_owl/static/src/todo_list/todo_item.xml b/awesome_owl/static/src/todo_list/todo_item.xml index d68fa9ff14f..4bc4ab34a37 100644 --- a/awesome_owl/static/src/todo_list/todo_item.xml +++ b/awesome_owl/static/src/todo_list/todo_item.xml @@ -5,7 +5,7 @@

- . + .

diff --git a/awesome_owl/static/src/todo_list/todo_list.js b/awesome_owl/static/src/todo_list/todo_list.js index 9eed22ead21..b1c8e6eed81 100644 --- a/awesome_owl/static/src/todo_list/todo_list.js +++ b/awesome_owl/static/src/todo_list/todo_list.js @@ -3,8 +3,8 @@ import { TodoItem } from "./todo_item"; import { useAutoFocus } from "../utils"; export class TodoList extends Component { - static template = "awesome_owl.todo_list" - static components = { TodoItem } + static template = "awesome_owl.todo_list"; + static components = { TodoItem }; setup() { useAutoFocus("todo-input"); @@ -17,13 +17,17 @@ export class TodoList extends Component { } toggleState(id) { - this.state.todos[id].isCompleted = !this.state.todos[id].isCompleted + this.state.todos[id].isCompleted = !this.state.todos[id].isCompleted; } addTodo(ev) { if (ev.keyCode === 13 && ev.target.value != "") { this.state.todos[++this.state.lastId] = {description: ev.target.value, isCompleted: false}; - ev.target.value = "" + ev.target.value = ""; } } + + removeTodo(id) { + delete this.state.todos[id]; + } } diff --git a/awesome_owl/static/src/todo_list/todo_list.xml b/awesome_owl/static/src/todo_list/todo_list.xml index b630f965c1a..eed4efec8d7 100644 --- a/awesome_owl/static/src/todo_list/todo_list.xml +++ b/awesome_owl/static/src/todo_list/todo_list.xml @@ -11,7 +11,12 @@ t-ref="todo-input" /> - +
From 143eec912b2322ea3065ab3e03e6747c66502453 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 10:54:23 +0200 Subject: [PATCH 11/32] [IMP] awesome_owl: add section 13 --- awesome_owl/static/src/card/card.js | 13 ++++++++++--- awesome_owl/static/src/card/card.xml | 2 +- awesome_owl/static/src/playground.xml | 13 ++++++++++--- awesome_owl/static/src/todo_list/todo_list.js | 4 ++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js index 7269802b664..b25b3c8f494 100644 --- a/awesome_owl/static/src/card/card.js +++ b/awesome_owl/static/src/card/card.js @@ -2,10 +2,17 @@ import { Component, useState } from "@odoo/owl"; export class Card extends Component { static template = "awesome_owl.card"; - static props = { title: {type: String}, content: {type: String}} + static props = { + title: String, + slots: { + type: Object, + shape: { + default: true + }, + } + } setup() { - this.title = this.props.title; - this.content = this.props.content; + this.title = this.props.title; } } diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml index 02a3b647317..7728d9c7bc6 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.xml b/awesome_owl/static/src/playground.xml index 22b858bd2bf..898bf184d2b 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -9,9 +9,16 @@
The sum is:
- - - + + New content for the new card + + + this should work with arbitrary html content + + + Here is a cool counter for you + +
diff --git a/awesome_owl/static/src/todo_list/todo_list.js b/awesome_owl/static/src/todo_list/todo_list.js index b1c8e6eed81..035775bbf2d 100644 --- a/awesome_owl/static/src/todo_list/todo_list.js +++ b/awesome_owl/static/src/todo_list/todo_list.js @@ -9,8 +9,8 @@ export class TodoList extends Component { setup() { useAutoFocus("todo-input"); this.state = useState({todos: { - 2: { description: "penser à acheter du lait", isCompleted: false }, - 3: { description: "penser à acheter des tomates cerises", isCompleted: true } + 2: { description: "buy milk", isCompleted: false }, + 3: { description: "buy tomatoes", isCompleted: true } }, lastId: 3 }); From 3156e294e1a2d93ecff270c0049b3c28af8e367e Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 10:57:03 +0200 Subject: [PATCH 12/32] [IMP] awesome_owl: set the starting todo index as 1 --- awesome_owl/static/src/todo_list/todo_list.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awesome_owl/static/src/todo_list/todo_list.js b/awesome_owl/static/src/todo_list/todo_list.js index 035775bbf2d..9f4b96702e1 100644 --- a/awesome_owl/static/src/todo_list/todo_list.js +++ b/awesome_owl/static/src/todo_list/todo_list.js @@ -9,10 +9,10 @@ export class TodoList extends Component { setup() { useAutoFocus("todo-input"); this.state = useState({todos: { - 2: { description: "buy milk", isCompleted: false }, - 3: { description: "buy tomatoes", isCompleted: true } + 1: { description: "buy milk", isCompleted: false }, + 2: { description: "buy tomatoes", isCompleted: true } }, - lastId: 3 + lastId: 2 }); } From 60483e63d0e4e9ab4ea23b4616ca5b35b90a8a61 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 11:00:33 +0200 Subject: [PATCH 13/32] [IMP] awesome_owl: add section 14 --- awesome_owl/static/src/card/card.js | 1 + awesome_owl/static/src/card/card.xml | 9 ++++++--- 2 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 b25b3c8f494..961faa9f494 100644 --- a/awesome_owl/static/src/card/card.js +++ b/awesome_owl/static/src/card/card.js @@ -13,6 +13,7 @@ export class Card extends Component { } setup() { + this.state = useState({open: true}); this.title = this.props.title; } } diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml index 7728d9c7bc6..6c35e2c2836 100644 --- a/awesome_owl/static/src/card/card.xml +++ b/awesome_owl/static/src/card/card.xml @@ -5,9 +5,12 @@
-

- -

+ + +

+ +

+
From 2209933fb053697b42014096f9ab0c5cc888e78c Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 11:30:38 +0200 Subject: [PATCH 14/32] [IMP] awesome_dashboard: add section 1 --- awesome_dashboard/static/src/dashboard.js | 2 ++ awesome_dashboard/static/src/dashboard.scss | 3 +++ awesome_dashboard/static/src/dashboard.xml | 3 +++ 3 files changed, 8 insertions(+) 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 637fa4bb972..e3ef9b080fc 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -2,9 +2,11 @@ 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..4f794e54032 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard.scss @@ -0,0 +1,3 @@ +.o_dashboard { + background-color: purple +} diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml index 1a2ac9a2fed..d4b16b61ebb 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -3,6 +3,9 @@ hello dashboard + + some content +
From adf412a4dbfdbfde3cb17ba8a7c4834bc87b5dfc Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 13:39:50 +0200 Subject: [PATCH 15/32] [IMP] awesome_dashboard: add section 2 --- awesome_dashboard/static/src/dashboard.js | 21 +++++++++++++++++++++ awesome_dashboard/static/src/dashboard.xml | 7 ++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index e3ef9b080fc..1e5167e46ad 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -3,10 +3,31 @@ import { Component } from "@odoo/owl"; import { registry } from "@web/core/registry"; import { Layout } from "@web/search/layout"; +import { useService } from "@web/core/utils/hooks"; +import { _t } from "@web/core/l10n/translation"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; static components = { Layout } + + setup() { + this.action = useService("action"); + } + openPartners() { + this.action.doAction("base.action_partner_form"); + } + async openLeads() { + this.action.doAction({ + type: 'ir.actions.act_window', + name: _t('All Leads'), + res_model: 'crm.lead', + views: [ + [false, 'list'], + [false, 'form'] + ], + }); + } + } 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 d4b16b61ebb..8b0356cae2f 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -2,7 +2,12 @@ - hello dashboard + + some content From ac47f9bf05c4c751fe60a7b90844537a7928627f Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 15:21:02 +0200 Subject: [PATCH 16/32] [IMP] awesome_dashboard: add sections 3-4 --- awesome_dashboard/static/src/dashboard.js | 11 +++++++++-- awesome_dashboard/static/src/dashboard.xml | 14 +++++++++++++- awesome_dashboard/static/src/dashboard_item.js | 14 ++++++++++++++ awesome_dashboard/static/src/dashboard_item.xml | 15 +++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 awesome_dashboard/static/src/dashboard_item.js create mode 100644 awesome_dashboard/static/src/dashboard_item.xml diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index 1e5167e46ad..9c76029a412 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -1,17 +1,24 @@ /** @odoo-module **/ -import { Component } from "@odoo/owl"; +import { Component, onWillStart } from "@odoo/owl"; import { registry } from "@web/core/registry"; import { Layout } from "@web/search/layout"; import { useService } from "@web/core/utils/hooks"; import { _t } from "@web/core/l10n/translation"; +import { DashboardItem } from "./dashboard_item"; +import { rpc } from "@web/core/network/rpc"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; - static components = { Layout } + static components = { Layout, DashboardItem } setup() { this.action = useService("action"); + onWillStart(async () => { + const stats = await rpc("/awesome_dashboard/statistics"); + this.stats = stats + console.log(stats) + }) } openPartners() { this.action.doAction("base.action_partner_form"); diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml index 8b0356cae2f..5281dc71bb5 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -9,7 +9,19 @@ Leads - some content + + no size + + + size of 2 + + + + + + + + diff --git a/awesome_dashboard/static/src/dashboard_item.js b/awesome_dashboard/static/src/dashboard_item.js new file mode 100644 index 00000000000..6ea6d00f83e --- /dev/null +++ b/awesome_dashboard/static/src/dashboard_item.js @@ -0,0 +1,14 @@ +import { Component } from "@odoo/owl"; + +export class DashboardItem extends Component { + static template = "awesome_dashboard.dashboard_item" + static props = { + size: {type: Number, optional: true}, + slots: {optional: true} + } + + setup() { + this.size = this.props.size || 1 + this.width = `${18 * this.size}rem` + } +} diff --git a/awesome_dashboard/static/src/dashboard_item.xml b/awesome_dashboard/static/src/dashboard_item.xml new file mode 100644 index 00000000000..77820aa39ef --- /dev/null +++ b/awesome_dashboard/static/src/dashboard_item.xml @@ -0,0 +1,15 @@ + + + + +
+
+
+

+ +

+
+
+
+ +
From 71636b1663793c07b98cea5c66f0bb66ec341340 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 16:03:14 +0200 Subject: [PATCH 17/32] [IMP] awesome_dashboard: add section 5 --- awesome_dashboard/static/src/dashboard.js | 7 +------ .../static/src/dashboard_service.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 awesome_dashboard/static/src/dashboard_service.js diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index 9c76029a412..b173f78af72 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -6,7 +6,6 @@ import { Layout } from "@web/search/layout"; import { useService } from "@web/core/utils/hooks"; import { _t } from "@web/core/l10n/translation"; import { DashboardItem } from "./dashboard_item"; -import { rpc } from "@web/core/network/rpc"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; @@ -14,11 +13,7 @@ class AwesomeDashboard extends Component { setup() { this.action = useService("action"); - onWillStart(async () => { - const stats = await rpc("/awesome_dashboard/statistics"); - this.stats = stats - console.log(stats) - }) + this.stats = useService("awesome_dashboard.statistics").getStatistics() } openPartners() { this.action.doAction("base.action_partner_form"); diff --git a/awesome_dashboard/static/src/dashboard_service.js b/awesome_dashboard/static/src/dashboard_service.js new file mode 100644 index 00000000000..2879b84a403 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard_service.js @@ -0,0 +1,18 @@ +import { registry } from "@web/core/registry"; +import { memoize } from "@web/core/utils/functions"; +import { rpc } from "@web/core/network/rpc"; + +const dashboardService = { + start() { + let stats = {} + async function loadData() { + stats = await rpc("/awesome_dashboard/statistics"); + } + loadData(); + + return { getStatistics: memoize(() => stats)} + }, +}; + + +registry.category("services").add("awesome_dashboard.statistics", dashboardService); From 411550602c00a50c2e90f52ad361ec07d76869a2 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Tue, 23 Sep 2025 16:43:07 +0200 Subject: [PATCH 18/32] [IMP] awesome_dashboard: section 6 --- awesome_dashboard/static/src/dashboard.js | 3 +- awesome_dashboard/static/src/dashboard.xml | 3 ++ .../static/src/pie_chart/pie_chart.js | 29 +++++++++++++++++++ .../static/src/pie_chart/pie_chart.xml | 6 ++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 awesome_dashboard/static/src/pie_chart/pie_chart.js create mode 100644 awesome_dashboard/static/src/pie_chart/pie_chart.xml diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index b173f78af72..abe3a100cf3 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -6,10 +6,11 @@ import { Layout } from "@web/search/layout"; import { useService } from "@web/core/utils/hooks"; import { _t } from "@web/core/l10n/translation"; import { DashboardItem } from "./dashboard_item"; +import { PieChart } from "./pie_chart/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 5281dc71bb5..fec009a47cb 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -22,6 +22,9 @@ + + + diff --git a/awesome_dashboard/static/src/pie_chart/pie_chart.js b/awesome_dashboard/static/src/pie_chart/pie_chart.js new file mode 100644 index 00000000000..ffe64392fc0 --- /dev/null +++ b/awesome_dashboard/static/src/pie_chart/pie_chart.js @@ -0,0 +1,29 @@ +import { Component, onMounted, onWillUnmount, onWillStart, useRef } from "@odoo/owl"; +import { loadJS } from "@web/core/assets"; + +export class PieChart extends Component { + static template = "awesome_dashboard.pie_chart"; + static props = { data: {optional: false}} + + setup() { + this.canvasRef = useRef("canvas"); + + onWillStart(() => loadJS("/web/static/lib/Chart/Chart.js")); + + onMounted(() => this.buildChart()); + + onWillUnmount(() => this.pieChart.destroy()); + } + + buildChart() { + this.pieChart = new Chart(this.canvasRef.el, { + type: "pie", + data: { + labels: Object.keys(this.props.data), + datasets: [{ + data: Object.values(this.props.data), + }], + }, + }); + } +}; diff --git a/awesome_dashboard/static/src/pie_chart/pie_chart.xml b/awesome_dashboard/static/src/pie_chart/pie_chart.xml new file mode 100644 index 00000000000..64a51dcc63a --- /dev/null +++ b/awesome_dashboard/static/src/pie_chart/pie_chart.xml @@ -0,0 +1,6 @@ + + + + + + From 82f496d030236c09bce757eb9a551455682ccedd Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Wed, 24 Sep 2025 09:36:50 +0200 Subject: [PATCH 19/32] [IMP] awesome_dashboard: add section 7 --- awesome_dashboard/static/src/dashboard.js | 4 ++-- .../static/src/dashboard_service.js | 18 +++++++++++++++--- .../static/src/pie_chart/pie_chart.js | 16 ++++++++++++---- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index abe3a100cf3..9014bc2bfe1 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -1,6 +1,6 @@ /** @odoo-module **/ -import { Component, onWillStart } from "@odoo/owl"; +import { Component, onWillStart, useState } from "@odoo/owl"; import { registry } from "@web/core/registry"; import { Layout } from "@web/search/layout"; import { useService } from "@web/core/utils/hooks"; @@ -14,7 +14,7 @@ class AwesomeDashboard extends Component { setup() { this.action = useService("action"); - this.stats = useService("awesome_dashboard.statistics").getStatistics() + this.stats = useState(useService("awesome_dashboard.statistics")) } openPartners() { this.action.doAction("base.action_partner_form"); diff --git a/awesome_dashboard/static/src/dashboard_service.js b/awesome_dashboard/static/src/dashboard_service.js index 2879b84a403..a06128a178c 100644 --- a/awesome_dashboard/static/src/dashboard_service.js +++ b/awesome_dashboard/static/src/dashboard_service.js @@ -1,16 +1,28 @@ 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 dashboardService = { start() { - let stats = {} + let stats = reactive({ + average_quantity: 0, + average_time: 0, + nb_cancelled_orders: 0, + nb_new_orders: 0, + orders_by_size: {}, + total_amount: 0 + }); async function loadData() { - stats = await rpc("/awesome_dashboard/statistics"); + console.log("slt") + const newStats = await rpc("/awesome_dashboard/statistics"); + Object.keys(newStats).forEach((k) => stats[k] = newStats[k]) + console.log(newStats) } + setInterval(loadData, 2*1000); loadData(); - return { getStatistics: memoize(() => stats)} + return stats; }, }; diff --git a/awesome_dashboard/static/src/pie_chart/pie_chart.js b/awesome_dashboard/static/src/pie_chart/pie_chart.js index ffe64392fc0..d69ecac8355 100644 --- a/awesome_dashboard/static/src/pie_chart/pie_chart.js +++ b/awesome_dashboard/static/src/pie_chart/pie_chart.js @@ -1,4 +1,4 @@ -import { Component, onMounted, onWillUnmount, onWillStart, useRef } from "@odoo/owl"; +import { Component, onMounted, onWillUnmount, onWillStart, useEffect, useRef } from "@odoo/owl"; import { loadJS } from "@web/core/assets"; export class PieChart extends Component { @@ -10,7 +10,15 @@ export class PieChart extends Component { onWillStart(() => loadJS("/web/static/lib/Chart/Chart.js")); - onMounted(() => this.buildChart()); + useEffect(() => { + if (this.pieChart) { + this.pieChart.destroy() + } + this.data = Object.values(this.props.data.orders_by_size) + this.labels = Object.keys(this.props.data.orders_by_size) + + this.buildChart() + }); onWillUnmount(() => this.pieChart.destroy()); } @@ -19,9 +27,9 @@ export class PieChart extends Component { this.pieChart = new Chart(this.canvasRef.el, { type: "pie", data: { - labels: Object.keys(this.props.data), + labels: this.labels, datasets: [{ - data: Object.values(this.props.data), + data: this.data, }], }, }); From cabcad9a00760a48555734181170425d272f8993 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Wed, 24 Sep 2025 10:37:11 +0200 Subject: [PATCH 20/32] [IMP] awesome_dashboard: add section 8 --- awesome_dashboard/__manifest__.py | 3 +++ .../static/src/{ => dashboard}/dashboard.js | 4 ++-- .../static/src/{ => dashboard}/dashboard.scss | 0 .../static/src/{ => dashboard}/dashboard.xml | 2 +- .../static/src/dashboard/dashboard_action.js | 13 +++++++++++++ .../static/src/{ => dashboard}/dashboard_item.js | 0 .../static/src/{ => dashboard}/dashboard_item.xml | 0 .../static/src/{ => dashboard}/dashboard_service.js | 0 .../src/{ => dashboard}/pie_chart/pie_chart.js | 0 .../src/{ => dashboard}/pie_chart/pie_chart.xml | 0 10 files changed, 19 insertions(+), 3 deletions(-) rename awesome_dashboard/static/src/{ => dashboard}/dashboard.js (86%) rename awesome_dashboard/static/src/{ => dashboard}/dashboard.scss (100%) rename awesome_dashboard/static/src/{ => dashboard}/dashboard.xml (94%) create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_action.js rename awesome_dashboard/static/src/{ => dashboard}/dashboard_item.js (100%) rename awesome_dashboard/static/src/{ => dashboard}/dashboard_item.xml (100%) rename awesome_dashboard/static/src/{ => dashboard}/dashboard_service.js (100%) rename awesome_dashboard/static/src/{ => dashboard}/pie_chart/pie_chart.js (100%) rename awesome_dashboard/static/src/{ => dashboard}/pie_chart/pie_chart.xml (100%) diff --git a/awesome_dashboard/__manifest__.py b/awesome_dashboard/__manifest__.py index 31406e8addb..7105d960c13 100644 --- a/awesome_dashboard/__manifest__.py +++ b/awesome_dashboard/__manifest__.py @@ -25,6 +25,9 @@ 'web.assets_backend': [ 'awesome_dashboard/static/src/**/*', ], + 'awesome_dashboard.dashboard': [ + 'awesome_dashboard/static/src/dashboard/**/*' + ] }, 'license': 'AGPL-3' } diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js similarity index 86% rename from awesome_dashboard/static/src/dashboard.js rename to awesome_dashboard/static/src/dashboard/dashboard.js index 9014bc2bfe1..922b589f434 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -9,7 +9,7 @@ import { DashboardItem } from "./dashboard_item"; import { PieChart } from "./pie_chart/pie_chart"; class AwesomeDashboard extends Component { - static template = "awesome_dashboard.AwesomeDashboard"; + static template = "awesome_dashboard.awesome_dashboard"; static components = { Layout, DashboardItem, PieChart } setup() { @@ -33,4 +33,4 @@ class AwesomeDashboard extends Component { } -registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard); +registry.category("lazy_components").add("awesome_dashboard.dashboard", 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 94% rename from awesome_dashboard/static/src/dashboard.xml rename to awesome_dashboard/static/src/dashboard/dashboard.xml index fec009a47cb..55aea4ec06f 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -1,7 +1,7 @@ - + diff --git a/awesome_dashboard/static/src/dashboard/dashboard_action.js b/awesome_dashboard/static/src/dashboard/dashboard_action.js new file mode 100644 index 00000000000..8b1d088b2ba --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_action.js @@ -0,0 +1,13 @@ +import { LazyComponent } from "@web/core/assets"; +import { Component, xml, onWillStart, useState } from "@odoo/owl"; +import { registry } from "@web/core/registry"; + + +export class AwesomeDashboardLoader extends Component { + static components = { LazyComponent }; + static template = xml` + + `; +} + +registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboardLoader); diff --git a/awesome_dashboard/static/src/dashboard_item.js b/awesome_dashboard/static/src/dashboard/dashboard_item.js similarity index 100% rename from awesome_dashboard/static/src/dashboard_item.js rename to awesome_dashboard/static/src/dashboard/dashboard_item.js diff --git a/awesome_dashboard/static/src/dashboard_item.xml b/awesome_dashboard/static/src/dashboard/dashboard_item.xml similarity index 100% rename from awesome_dashboard/static/src/dashboard_item.xml rename to awesome_dashboard/static/src/dashboard/dashboard_item.xml diff --git a/awesome_dashboard/static/src/dashboard_service.js b/awesome_dashboard/static/src/dashboard/dashboard_service.js similarity index 100% rename from awesome_dashboard/static/src/dashboard_service.js rename to awesome_dashboard/static/src/dashboard/dashboard_service.js diff --git a/awesome_dashboard/static/src/pie_chart/pie_chart.js b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js similarity index 100% rename from awesome_dashboard/static/src/pie_chart/pie_chart.js rename to awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js diff --git a/awesome_dashboard/static/src/pie_chart/pie_chart.xml b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml similarity index 100% rename from awesome_dashboard/static/src/pie_chart/pie_chart.xml rename to awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml From 036b648249289397f5a924de080d515226873a69 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Wed, 24 Sep 2025 11:52:31 +0200 Subject: [PATCH 21/32] [IMP] awesome_dashboard: add section 9 --- .../static/src/dashboard/dashboard.js | 4 ++ .../static/src/dashboard/dashboard.xml | 11 +++- .../static/src/dashboard/dashboard_items.js | 60 +++++++++++++++++++ .../src/dashboard/number_card/number_card.js | 9 +++ .../src/dashboard/number_card/number_card.xml | 12 ++++ .../src/dashboard/pie_chart/pie_chart.js | 6 +- .../pie_chart_card/pie_chart_card.js | 11 ++++ .../pie_chart_card/pie_chart_card.xml | 10 ++++ 8 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_items.js create mode 100644 awesome_dashboard/static/src/dashboard/number_card/number_card.js create mode 100644 awesome_dashboard/static/src/dashboard/number_card/number_card.xml create mode 100644 awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js create mode 100644 awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index 922b589f434..bda345025b8 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -7,6 +7,7 @@ import { useService } from "@web/core/utils/hooks"; import { _t } from "@web/core/l10n/translation"; import { DashboardItem } from "./dashboard_item"; import { PieChart } from "./pie_chart/pie_chart"; +import { items } from "./dashboard_items"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.awesome_dashboard"; @@ -15,10 +16,13 @@ class AwesomeDashboard extends Component { setup() { this.action = useService("action"); this.stats = useState(useService("awesome_dashboard.statistics")) + this.items = items } + openPartners() { this.action.doAction("base.action_partner_form"); } + async openLeads() { this.action.doAction({ type: 'ir.actions.act_window', diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml index 55aea4ec06f..f6ba43caadb 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -9,14 +9,19 @@ Leads - + + + + + + + @@ -24,7 +29,7 @@ - + --> diff --git a/awesome_dashboard/static/src/dashboard/dashboard_items.js b/awesome_dashboard/static/src/dashboard/dashboard_items.js new file mode 100644 index 00000000000..5a18c1dcb9d --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_items.js @@ -0,0 +1,60 @@ +import { NumberCard } from "./number_card/number_card" +import { PieChartCard } from "./pie_chart_card/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, + }) + } +] diff --git a/awesome_dashboard/static/src/dashboard/number_card/number_card.js b/awesome_dashboard/static/src/dashboard/number_card/number_card.js new file mode 100644 index 00000000000..ec945e40266 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/number_card/number_card.js @@ -0,0 +1,9 @@ +import { Component } from "@odoo/owl"; + +export class NumberCard extends Component { + static template = "awesome_dashboard.number_card" + static props = { + title: String, + value: Number, + } +} diff --git a/awesome_dashboard/static/src/dashboard/number_card/number_card.xml b/awesome_dashboard/static/src/dashboard/number_card/number_card.xml new file mode 100644 index 00000000000..41d4985d53c --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/number_card/number_card.xml @@ -0,0 +1,12 @@ + + + + + + +
+ +
+
+ +
diff --git a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js index d69ecac8355..a8713e15c11 100644 --- a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js +++ b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js @@ -14,13 +14,13 @@ export class PieChart extends Component { if (this.pieChart) { this.pieChart.destroy() } - this.data = Object.values(this.props.data.orders_by_size) - this.labels = Object.keys(this.props.data.orders_by_size) + this.data = Object.values(this.props.data) + this.labels = Object.keys(this.props.data) this.buildChart() }); - onWillUnmount(() => this.pieChart.destroy()); + onWillUnmount(() => { if (this.pieChart) {this.pieChart.destroy()} }); } buildChart() { diff --git a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js new file mode 100644 index 00000000000..7c91208cd15 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js @@ -0,0 +1,11 @@ +import { Component } from "@odoo/owl"; +import { PieChart } from "../pie_chart/pie_chart"; + +export class PieChartCard extends Component { + static template = "awesome_dashboard.pie_chart_card" + static components = { PieChart } + static props = { + title: String, + values: {optional: false}, + } +} diff --git a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml new file mode 100644 index 00000000000..642d3c5839e --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml @@ -0,0 +1,10 @@ + + + + + + + + + + From 164bc525ece2b4aa327910c774ca0366e6ea1e90 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Wed, 24 Sep 2025 11:55:17 +0200 Subject: [PATCH 22/32] [IMP] awesome_dashboard: remove console logs --- awesome_dashboard/static/src/dashboard/dashboard_service.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard_service.js b/awesome_dashboard/static/src/dashboard/dashboard_service.js index a06128a178c..fa92be63b73 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_service.js +++ b/awesome_dashboard/static/src/dashboard/dashboard_service.js @@ -14,10 +14,8 @@ const dashboardService = { total_amount: 0 }); async function loadData() { - console.log("slt") const newStats = await rpc("/awesome_dashboard/statistics"); Object.keys(newStats).forEach((k) => stats[k] = newStats[k]) - console.log(newStats) } setInterval(loadData, 2*1000); loadData(); From a502aa5472463c8fa433d2be139736d4707bafc3 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Wed, 24 Sep 2025 13:13:44 +0200 Subject: [PATCH 23/32] [IMP] awesome_dashboard: add section 10 --- awesome_dashboard/static/src/dashboard/dashboard.js | 4 ++-- awesome_dashboard/static/src/dashboard/dashboard_items.js | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index bda345025b8..4d744e500b7 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -14,9 +14,9 @@ class AwesomeDashboard extends Component { static components = { Layout, DashboardItem, PieChart } setup() { - this.action = useService("action"); + this.action = useService("action") this.stats = useState(useService("awesome_dashboard.statistics")) - this.items = items + this.items = registry.category("awesome_dashboard").getAll() } openPartners() { diff --git a/awesome_dashboard/static/src/dashboard/dashboard_items.js b/awesome_dashboard/static/src/dashboard/dashboard_items.js index 5a18c1dcb9d..ca62a3f66e0 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_items.js +++ b/awesome_dashboard/static/src/dashboard/dashboard_items.js @@ -1,7 +1,7 @@ import { NumberCard } from "./number_card/number_card" import { PieChartCard } from "./pie_chart_card/pie_chart_card" -export const items = [ +const items = [ { id: "average_quantity", description: "Average amount of t-shirt", @@ -58,3 +58,7 @@ export const items = [ }) } ] + +items.forEach(i => { + registry.category("awesome_dashboard").add(i.id, i); +}); From 292c7b8d34110aa7d9c7659dd2d04643f5eefd37 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Wed, 24 Sep 2025 13:19:34 +0200 Subject: [PATCH 24/32] [IMP] awesome_dashboard: add section 10 --- awesome_dashboard/static/src/dashboard/dashboard.js | 4 ++-- awesome_dashboard/static/src/dashboard/dashboard_items.js | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index bda345025b8..4d744e500b7 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -14,9 +14,9 @@ class AwesomeDashboard extends Component { static components = { Layout, DashboardItem, PieChart } setup() { - this.action = useService("action"); + this.action = useService("action") this.stats = useState(useService("awesome_dashboard.statistics")) - this.items = items + this.items = registry.category("awesome_dashboard").getAll() } openPartners() { diff --git a/awesome_dashboard/static/src/dashboard/dashboard_items.js b/awesome_dashboard/static/src/dashboard/dashboard_items.js index 5a18c1dcb9d..ba2e6ff723b 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_items.js +++ b/awesome_dashboard/static/src/dashboard/dashboard_items.js @@ -1,7 +1,8 @@ import { NumberCard } from "./number_card/number_card" import { PieChartCard } from "./pie_chart_card/pie_chart_card" +import { registry } from "@web/core/registry"; -export const items = [ +const items = [ { id: "average_quantity", description: "Average amount of t-shirt", @@ -58,3 +59,7 @@ export const items = [ }) } ] + +items.forEach(i => { + registry.category("awesome_dashboard").add(i.id, i); +}); From 82c0d40f2560e9a813dd5982737fea52ccaa8298 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Wed, 24 Sep 2025 13:20:47 +0200 Subject: [PATCH 25/32] [IMP] awesome_dashboard: move buttons into layout button bar --- .../static/src/dashboard/dashboard.xml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml index f6ba43caadb..3a2b95112cf 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -2,13 +2,15 @@ - - + + + + From b62f551546a57641c7494b1fc0c8c4ea7efe5cf7 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Wed, 24 Sep 2025 14:05:10 +0200 Subject: [PATCH 26/32] [IMP] awesome_dashboard: rewrite xml ids using PascalCase --- awesome_dashboard/static/src/dashboard/dashboard.js | 2 +- awesome_dashboard/static/src/dashboard/dashboard.xml | 9 ++++++++- awesome_dashboard/static/src/dashboard/dashboard_item.js | 2 +- .../static/src/dashboard/dashboard_item.xml | 2 +- .../static/src/dashboard/number_card/number_card.js | 2 +- .../static/src/dashboard/number_card/number_card.xml | 2 +- .../static/src/dashboard/pie_chart/pie_chart.js | 2 +- .../static/src/dashboard/pie_chart/pie_chart.xml | 2 +- .../src/dashboard/pie_chart_card/pie_chart_card.js | 2 +- .../src/dashboard/pie_chart_card/pie_chart_card.xml | 2 +- 10 files changed, 17 insertions(+), 10 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index 4d744e500b7..189a275614b 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -10,7 +10,7 @@ import { PieChart } from "./pie_chart/pie_chart"; import { items } from "./dashboard_items"; class AwesomeDashboard extends Component { - static template = "awesome_dashboard.awesome_dashboard"; + static template = "awesome_dashboard.AwesomeDashboard"; static components = { Layout, DashboardItem, PieChart } setup() { diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml index 3a2b95112cf..bb13d66a202 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -1,7 +1,7 @@ - + + + + + + diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item.js b/awesome_dashboard/static/src/dashboard/dashboard_item.js index 6ea6d00f83e..cb070cd65c7 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_item.js +++ b/awesome_dashboard/static/src/dashboard/dashboard_item.js @@ -1,7 +1,7 @@ import { Component } from "@odoo/owl"; export class DashboardItem extends Component { - static template = "awesome_dashboard.dashboard_item" + static template = "awesome_dashboard.DashboardItem" static props = { size: {type: Number, optional: true}, slots: {optional: true} diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item.xml b/awesome_dashboard/static/src/dashboard/dashboard_item.xml index 77820aa39ef..0376c99eae3 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_item.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard_item.xml @@ -1,7 +1,7 @@ - +
diff --git a/awesome_dashboard/static/src/dashboard/number_card/number_card.js b/awesome_dashboard/static/src/dashboard/number_card/number_card.js index ec945e40266..4daa1346724 100644 --- a/awesome_dashboard/static/src/dashboard/number_card/number_card.js +++ b/awesome_dashboard/static/src/dashboard/number_card/number_card.js @@ -1,7 +1,7 @@ import { Component } from "@odoo/owl"; export class NumberCard extends Component { - static template = "awesome_dashboard.number_card" + static template = "awesome_dashboard.NumberCard" static props = { title: String, value: Number, diff --git a/awesome_dashboard/static/src/dashboard/number_card/number_card.xml b/awesome_dashboard/static/src/dashboard/number_card/number_card.xml index 41d4985d53c..d980f216f9d 100644 --- a/awesome_dashboard/static/src/dashboard/number_card/number_card.xml +++ b/awesome_dashboard/static/src/dashboard/number_card/number_card.xml @@ -2,7 +2,7 @@ - +
diff --git a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js index a8713e15c11..d53756c55a6 100644 --- a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js +++ b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js @@ -2,7 +2,7 @@ import { Component, onMounted, onWillUnmount, onWillStart, useEffect, useRef } f import { loadJS } from "@web/core/assets"; export class PieChart extends Component { - static template = "awesome_dashboard.pie_chart"; + static template = "awesome_dashboard.PieChart"; static props = { data: {optional: false}} setup() { diff --git a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml index 64a51dcc63a..6263d4cec7c 100644 --- a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml +++ b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml @@ -1,6 +1,6 @@ - + diff --git a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js index 7c91208cd15..69ad96a4858 100644 --- a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js +++ b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js @@ -2,7 +2,7 @@ import { Component } from "@odoo/owl"; import { PieChart } from "../pie_chart/pie_chart"; export class PieChartCard extends Component { - static template = "awesome_dashboard.pie_chart_card" + static template = "awesome_dashboard.PieChartCard" static components = { PieChart } static props = { title: String, diff --git a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml index 642d3c5839e..9ddf84e8419 100644 --- a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml +++ b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml @@ -2,7 +2,7 @@ - + From 113773ff79db93b2e57022ac6fc130bc830d6c0c Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Wed, 24 Sep 2025 14:40:28 +0200 Subject: [PATCH 27/32] [IMP] awesome_dashboard: apply PR feedback --- .../static/src/dashboard/dashboard.js | 11 +++++------ .../static/src/dashboard/dashboard.xml | 15 --------------- .../static/src/dashboard/dashboard_item.js | 5 ++--- .../static/src/dashboard/dashboard_item.xml | 2 +- .../static/src/dashboard/dashboard_service.js | 4 ++-- .../src/dashboard/number_card/number_card.js | 2 +- .../static/src/dashboard/pie_chart/pie_chart.js | 12 ++++++------ .../dashboard/pie_chart_card/pie_chart_card.js | 6 +++--- 8 files changed, 20 insertions(+), 37 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index 189a275614b..b7550437d18 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -1,22 +1,21 @@ /** @odoo-module **/ -import { Component, onWillStart, useState } from "@odoo/owl"; +import { Component, useState } from "@odoo/owl"; import { registry } from "@web/core/registry"; import { Layout } from "@web/search/layout"; import { useService } from "@web/core/utils/hooks"; import { _t } from "@web/core/l10n/translation"; import { DashboardItem } from "./dashboard_item"; import { PieChart } from "./pie_chart/pie_chart"; -import { items } from "./dashboard_items"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; - static components = { Layout, DashboardItem, PieChart } + static components = { Layout, DashboardItem, PieChart }; setup() { - this.action = useService("action") - this.stats = useState(useService("awesome_dashboard.statistics")) - this.items = registry.category("awesome_dashboard").getAll() + this.action = useService("action"); + this.stats = useState(useService("awesome_dashboard.statistics")); + this.items = registry.category("awesome_dashboard").getAll(); } openPartners() { diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml index bb13d66a202..4eaf823431c 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -24,21 +24,6 @@ - diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item.js b/awesome_dashboard/static/src/dashboard/dashboard_item.js index cb070cd65c7..de456a82ecd 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_item.js +++ b/awesome_dashboard/static/src/dashboard/dashboard_item.js @@ -5,10 +5,9 @@ export class DashboardItem extends Component { static props = { size: {type: Number, optional: true}, slots: {optional: true} - } + }; setup() { - this.size = this.props.size || 1 - this.width = `${18 * this.size}rem` + this.size = this.props.size || 1; } } diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item.xml b/awesome_dashboard/static/src/dashboard/dashboard_item.xml index 0376c99eae3..ad387048260 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_item.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard_item.xml @@ -2,7 +2,7 @@ -
+

diff --git a/awesome_dashboard/static/src/dashboard/dashboard_service.js b/awesome_dashboard/static/src/dashboard/dashboard_service.js index fa92be63b73..76e34130071 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_service.js +++ b/awesome_dashboard/static/src/dashboard/dashboard_service.js @@ -15,9 +15,9 @@ const dashboardService = { }); async function loadData() { const newStats = await rpc("/awesome_dashboard/statistics"); - Object.keys(newStats).forEach((k) => stats[k] = newStats[k]) + Object.keys(newStats).forEach((k) => stats[k] = newStats[k]); } - setInterval(loadData, 2*1000); + setInterval(loadData, 60*10*1000); loadData(); return stats; diff --git a/awesome_dashboard/static/src/dashboard/number_card/number_card.js b/awesome_dashboard/static/src/dashboard/number_card/number_card.js index 4daa1346724..571d15599e6 100644 --- a/awesome_dashboard/static/src/dashboard/number_card/number_card.js +++ b/awesome_dashboard/static/src/dashboard/number_card/number_card.js @@ -5,5 +5,5 @@ export class NumberCard extends Component { static props = { title: String, value: Number, - } + }; } diff --git a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js index d53756c55a6..c88eeaa1f4b 100644 --- a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js +++ b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js @@ -3,7 +3,7 @@ import { loadJS } from "@web/core/assets"; export class PieChart extends Component { static template = "awesome_dashboard.PieChart"; - static props = { data: {optional: false}} + static props = { data: {optional: false}}; setup() { this.canvasRef = useRef("canvas"); @@ -12,15 +12,15 @@ export class PieChart extends Component { useEffect(() => { if (this.pieChart) { - this.pieChart.destroy() + this.pieChart.destroy(); } - this.data = Object.values(this.props.data) - this.labels = Object.keys(this.props.data) + this.data = Object.values(this.props.data); + this.labels = Object.keys(this.props.data); - this.buildChart() + this.buildChart(); }); - onWillUnmount(() => { if (this.pieChart) {this.pieChart.destroy()} }); + onWillUnmount(() => { if (this.pieChart) {this.pieChart.destroy()}; }); } buildChart() { diff --git a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js index 69ad96a4858..ea01d40141e 100644 --- a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js +++ b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js @@ -2,10 +2,10 @@ import { Component } from "@odoo/owl"; import { PieChart } from "../pie_chart/pie_chart"; export class PieChartCard extends Component { - static template = "awesome_dashboard.PieChartCard" - static components = { PieChart } + static template = "awesome_dashboard.PieChartCard"; + static components = { PieChart }; static props = { title: String, values: {optional: false}, - } + }; } From 6f4a29728fd4a8294e925e595e7663e641b90f1a Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Wed, 24 Sep 2025 17:07:28 +0200 Subject: [PATCH 28/32] [IMP] awesome_dashboard: add section 11 --- .../static/src/dashboard/dashboard.js | 35 +++++++++++++++++++ .../static/src/dashboard/dashboard.xml | 15 ++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index b7550437d18..b221813a77b 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -7,6 +7,9 @@ import { useService } from "@web/core/utils/hooks"; import { _t } from "@web/core/l10n/translation"; import { DashboardItem } from "./dashboard_item"; import { PieChart } from "./pie_chart/pie_chart"; +import { browser } from "@web/core/browser/browser"; +import { Dialog } from "@web/core/dialog/dialog"; +import { CheckBox } from "@web/core/checkbox/checkbox"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; @@ -16,6 +19,8 @@ class AwesomeDashboard extends Component { this.action = useService("action"); this.stats = useState(useService("awesome_dashboard.statistics")); this.items = registry.category("awesome_dashboard").getAll(); + this.dialog = useService("dialog"); + this.state = useState({ itemsNotShown: browser.localStorage.getItem("itemsNotShown")?.split(",") || []}); } openPartners() { @@ -34,6 +39,36 @@ class AwesomeDashboard extends Component { }); } + openSettingsDialog() { + this.dialog.add(SettingsDialog, { + items: this.items, + itemsNotShown: this.state.itemsNotShown, + dashboard: this + }); + } } registry.category("lazy_components").add("awesome_dashboard.dashboard", AwesomeDashboard); + +class SettingsDialog extends Component { + static template = "awesome_dashboard.SettingsDialog"; + static components = { Dialog, CheckBox }; + static props = ["dashboard", "items", "itemsNotShown"]; + + setup() { + this.items = useState(this.props.items); + this.items.forEach((item) => { item.shown = !this.props.itemsNotShown.includes(item.id)}); + } + + toggleItem (ev, item) { + item.shown = ev; + + const newItemsNotShown = Object.values(this.items) + .filter((i) => !i.shown) + .map((i) => i.id) + + browser.localStorage.setItem("itemsNotShown", newItemsNotShown); + + this.props.dashboard.state.itemsNotShown = newItemsNotShown; + } +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml index 4eaf823431c..32e5471b37f 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -13,13 +13,13 @@ - - + @@ -27,4 +27,15 @@ + +

+ Choose which items you want to display + + + + + + + + From 0ad1da48ac776120d0a5af9dc5ffd742cecb916b Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Thu, 25 Sep 2025 13:56:43 +0200 Subject: [PATCH 29/32] [IMP] awesome_dashboard: refactor settings dialog props --- awesome_dashboard/static/src/dashboard/dashboard.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index b221813a77b..8c199098a3f 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -42,8 +42,7 @@ class AwesomeDashboard extends Component { openSettingsDialog() { this.dialog.add(SettingsDialog, { items: this.items, - itemsNotShown: this.state.itemsNotShown, - dashboard: this + dashboard: this, }); } } @@ -53,11 +52,11 @@ registry.category("lazy_components").add("awesome_dashboard.dashboard", AwesomeD class SettingsDialog extends Component { static template = "awesome_dashboard.SettingsDialog"; static components = { Dialog, CheckBox }; - static props = ["dashboard", "items", "itemsNotShown"]; + static props = ["dashboard", "items"]; setup() { this.items = useState(this.props.items); - this.items.forEach((item) => { item.shown = !this.props.itemsNotShown.includes(item.id)}); + this.items.forEach((item) => { item.shown = !this.props.dashboard.state.itemsNotShown.includes(item.id)}); } toggleItem (ev, item) { From 6aacfbe0794c14b6c81c0dbabb4f5b74dea46f86 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Thu, 25 Sep 2025 14:23:59 +0200 Subject: [PATCH 30/32] [IMP] awesome_dashboard: change var name for clarity --- awesome_dashboard/static/src/dashboard/dashboard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index 8c199098a3f..846ff22605a 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -59,8 +59,8 @@ class SettingsDialog extends Component { this.items.forEach((item) => { item.shown = !this.props.dashboard.state.itemsNotShown.includes(item.id)}); } - toggleItem (ev, item) { - item.shown = ev; + toggleItem (isChecked, item) { + item.shown = isChecked; const newItemsNotShown = Object.values(this.items) .filter((i) => !i.shown) From 3231834f52e1e69ea9db2e6c3a68411431750708 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Thu, 25 Sep 2025 14:24:32 +0200 Subject: [PATCH 31/32] [IMP] awesome_dashboard: add newline to file end --- awesome_dashboard/static/src/dashboard/dashboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index 846ff22605a..32758802c40 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -70,4 +70,4 @@ class SettingsDialog extends Component { this.props.dashboard.state.itemsNotShown = newItemsNotShown; } -} \ No newline at end of file +} From 44e0d49c40a5239736430b61c8d4da8b3ce62db2 Mon Sep 17 00:00:00 2001 From: Tristan Cazier Date: Thu, 25 Sep 2025 14:29:28 +0200 Subject: [PATCH 32/32] [IMP] awesome_dashboard: apply PR suggestion --- awesome_dashboard/static/src/dashboard/dashboard_service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard/dashboard_service.js b/awesome_dashboard/static/src/dashboard/dashboard_service.js index 76e34130071..658de243915 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_service.js +++ b/awesome_dashboard/static/src/dashboard/dashboard_service.js @@ -15,9 +15,9 @@ const dashboardService = { }); async function loadData() { const newStats = await rpc("/awesome_dashboard/statistics"); - Object.keys(newStats).forEach((k) => stats[k] = newStats[k]); + Object.assign(stats, newStats); } - setInterval(loadData, 60*10*1000); + setInterval(loadData, 2*1000); loadData(); return stats;