Skip to content

Commit 3aa257c

Browse files
committed
[IMP] awesome_dashboard: add customers and Leads button in layout
add controlpanel layout add customers and leads button in controlpanel layout add delete todo and toggle todo funtion add property id field after customer field in account move form
1 parent b633817 commit 3aa257c

File tree

21 files changed

+249
-49
lines changed

21 files changed

+249
-49
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
11
import { Component } from "@odoo/owl";
22
import { registry } from "@web/core/registry";
3+
import { Layout } from "@web/search/layout";
4+
import { useService } from "@web/core/utils/hooks";
35

46
class AwesomeDashboard extends Component {
57
static template = "awesome_dashboard.AwesomeDashboard";
8+
static components = { Layout }
9+
10+
setup() {
11+
this.action = useService("action");
12+
}
13+
14+
openCustomers() {
15+
this.action.doAction({
16+
type: "ir.actions.act_window",
17+
name: "Customers",
18+
res_model: "res.partner",
19+
views: [
20+
[false, "kanban"],
21+
[false, "form"],
22+
[false, "list"],
23+
],
24+
});
25+
}
26+
27+
openLeads() {
28+
this.action.doAction({
29+
type: "ir.actions.act_window",
30+
name: "Leads",
31+
res_model: "crm.lead",
32+
views: [
33+
[false, "list"],
34+
[false, "form"],
35+
],
36+
});
37+
}
638
}
739

840
registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.o_dashboard {
2+
background-color: gray;
3+
}
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<templates xml:space="preserve">
3-
43
<t t-name="awesome_dashboard.AwesomeDashboard">
5-
hello dashboard
4+
<Layout className="'o_dashboard h-100'" display="{ controlPanel: {} }">
5+
<t t-set-slot="control-panel-always-buttons">
6+
<button class="btn btn-primary me-2" t-on-click="openCustomers">
7+
Customers
8+
</button>
9+
<button class="btn btn-primary me-2" t-on-click="openLeads">
10+
Leads
11+
</button>
12+
</t>
13+
</Layout>
614
</t>
7-
815
</templates>
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
import { Component } from "@odoo/owl";
1+
import { Component, useState } from "@odoo/owl";
22

33

44
export class Card extends Component {
5-
static template = "awesome_owl.Card";
5+
static template = "awesome_owl.card";
66
static props = {
77
title: String,
8-
content: String,
8+
slots: {
9+
type: Object,
10+
shape: {
11+
default: {}
12+
}
13+
}
914
};
15+
16+
setup() {
17+
this.state = useState({visible: true})
18+
}
19+
20+
toggleContent() {
21+
this.state.visible = !this.state.visible;
22+
}
1023
}
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<templates xml:space="preserve">
3-
<t t-name="awesome_owl.Card">
4-
<div class="card d-inline-block m-2" style="border: 3px solid #ccc; margin: 20px; padding: 20px">
5-
<div class="card-body">
6-
<h5 class="card-title" style="font-size: 20px">
7-
<t t-esc="props.title"/>
8-
</h5>
9-
<p class="card-text">
10-
<t t-esc="props.content"/>
11-
</p>
12-
</div>
3+
<t t-name="awesome_owl.card">
4+
<style>
5+
.card-main{
6+
display: block;
7+
border: 1px solid #ccc;
8+
padding: 20px;
9+
}
10+
</style>
11+
<button t-on-click="toggleContent">toggle visibility</button>
12+
<div class="card-main">
13+
<h2 class="card-title" t-esc="props.title"></h2>
14+
<t t-if="this.state.visible">
15+
<div class="card-body">
16+
<t t-slot="default"/>
17+
</div>
18+
</t>
1319
</div>
1420
</t>
1521
</templates>

awesome_owl/static/src/counter/counter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Component, useState } from "@odoo/owl";
33

44
export class Counter extends Component {
55
static template = "awesome_owl.Counter";
6-
76
static props = {
87
onChange: {
98
type: Function,
Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<templates xml:space="preserve">
33
<t t-name="awesome_owl.Counter">
4-
<div style="background-color: #FFFFE0; border: 3px solid #ccc; display: inline-block; min-width: 300px; padding: 20px; margin: 20px">
5-
<p>Counter: <t t-esc="state.value"/></p>
6-
<button style="background: purple; color: white; padding: 8px; border-radius: 5px; border: 0;" class="btn btn-primary" t-on-click="increment">
7-
Increment
8-
</button>
9-
<button style="background: purple; color: white; padding: 8px; border-radius: 5px; border: 0; margin:5px" class="btn btn-primary" t-on-click="decrement">
10-
Decrement
11-
</button>
12-
</div>
4+
<style>
5+
.primary-counter{
6+
background-color: #FFFFE0;
7+
border: 3px solid #ccc;
8+
display: inline-block;
9+
min-width: 300px;
10+
padding: 20px;
11+
margin: 20px;
12+
}
13+
.increment-button{
14+
background: purple;
15+
color: white;
16+
padding: 8px;
17+
border-radius: 5px;
18+
}
19+
.decrement-button{
20+
background: purple;
21+
color: white;
22+
padding: 8px;
23+
border-radius: 5px;
24+
margin:5px
25+
}
26+
</style>
27+
<div class="primary-counter">
28+
<p>Counter: <t t-esc="state.value"/></p>
29+
<button class="increment-button" t-on-click="increment">
30+
Increment
31+
</button>
32+
<button class="decrement-button" t-on-click="decrement">
33+
Decrement
34+
</button>
35+
</div>
1336
</t>
1437
</templates>

awesome_owl/static/src/playground.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
import { Component, useState } from "@odoo/owl";
1+
import { Component, useState, markup } from "@odoo/owl";
22
import { Counter } from "./counter/counter";
33
import { Card } from "./card/card";
44
import { TodoList } from "./todo/todo_list";
55

66

77
export class Playground extends Component {
88
static template = "awesome_owl.playground";
9+
static props = {};
910
static components = { Counter, Card, TodoList };
1011

1112
setup() {
1213
this.state = useState({
14+
content: markup('<h1>Welcome to dashboard</h1>'),
1315
sum: 0,
1416
});
17+
1518
}
1619

17-
incrementSum(newVal,Checker){
20+
totalSum(newVal,Checker){
1821
if(Checker)
1922
this.state.sum++;
2023
else
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<templates xml:space="preserve">
33
<t t-name="awesome_owl.playground">
4-
<Counter onChange.bind="incrementSum"/>
5-
<Counter onChange.bind="incrementSum"/>
6-
<Counter onChange.bind="incrementSum"/>
7-
<h3 style="background-color: #90EE90; border: 3px solid #ccc; margin: 20px; padding: 20px">Sum of Counters: <t t-esc="state.sum"/></h3>
4+
<t t-out="this.state.content"/>
5+
<Counter onChange.bind="totalSum"/>
6+
<Counter onChange.bind="totalSum"/>
7+
<Counter onChange.bind="totalSum"/>
8+
<div style="background-color: #90EE90; border: 3px solid #ccc; margin: 20px; padding: 20px">
9+
<h3>Sum of Counters: <t t-esc="state.sum"/></h3>
10+
</div>
811
<TodoList/>
12+
<div>
13+
<Card title="'Card with text'">
14+
<p>This is arbitrary card content!</p>
15+
</Card>
16+
</div>
17+
<div>
18+
<Card title="'Card with a counter'">
19+
<Counter onChange.bind="totalSum"/>
20+
</Card>
21+
</div>
922
</t>
1023
</templates>

awesome_owl/static/src/todo/todo_item.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@ import { Component } from "@odoo/owl";
33

44
export class TodoItem extends Component {
55
static template = "awesome_owl.TodoItem";
6-
76
static props = {
87
todo: Object,
8+
toggleState: Function,
9+
deleteTodo: Function,
910
};
11+
12+
onChangeToggle() {
13+
this.props.toggleState(this.props.todo.id);
14+
}
15+
16+
onChangeDelete() {
17+
this.props.deleteTodo(this.props.todo.id);
18+
}
1019
}

0 commit comments

Comments
 (0)