Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a138c78
[ADD] estate: create the estate module for Ch2 of the tutorial
dianv-odoo Jan 19, 2026
96111b9
[IMP] estate: add estate_property model
dianv-odoo Jan 19, 2026
64c4787
[IMP] estate: add access rights
dianv-odoo Jan 19, 2026
7d946f0
[IMP] estate: add UI interaction by creating the form and adding menus
dianv-odoo Jan 19, 2026
662b639
[IMP] estate: add basic views to real estate module (Ch 6)
dianv-odoo Jan 20, 2026
46850b4
[IMP] estate: add property types, tags, and offers
dianv-odoo Jan 21, 2026
95d3d2a
[IMP] estate: add computed fields and onchanges
dianv-odoo Jan 21, 2026
a21ad84
[IMP] estate: add buttons to accept and reject offers
dianv-odoo Jan 21, 2026
2b6b91e
[IMP] estate: add constraints
dianv-odoo Jan 21, 2026
2eef592
[IMP] add widgets, colors, and stat buttons
dianv-odoo Jan 22, 2026
a7a6b84
[FIX] applied suggested style fixes
dianv-odoo Jan 22, 2026
17569cc
[IMP] add business logic to property state and inheritance to users
dianv-odoo Jan 22, 2026
8710e71
[FIX] estate: fix style issues from last commit
dianv-odoo Jan 22, 2026
b5e704c
[ADD] estate_account: add link module estate_account
dianv-odoo Jan 22, 2026
5a7fec3
[IMP] estate: added kanban view option
dianv-odoo Jan 23, 2026
5cead40
[FIX] fix order of files in the manifest to load in correct order
dianv-odoo Jan 23, 2026
32eb7a1
[FIX] estate: change the offer price requirement to be higher than al…
dianv-odoo Jan 23, 2026
726bd9e
[ADD] awesome_owl: add counter, card, and todo list components
dianv-odoo Jan 26, 2026
de1ad8b
[ADD] awesome_dashboard: create dashboard for chapter 2
dianv-odoo Jan 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions awesome_dashboard/static/src/dashboard.js

This file was deleted.

8 changes: 0 additions & 8 deletions awesome_dashboard/static/src/dashboard.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Component, useState } from "@odoo/owl";
import { Dialog } from "@web/core/dialog/dialog";
import { registry } from "@web/core/registry";

export class ConfigDialog extends Component {
static template = "awesome_dashboard.ConfigDialog";
static components = { Dialog };

setup() {
this.items = registry.category("awesome_dashboard").get("DashboardItems");
this.state = useState({
hiddenIds: this.props.hiddenIds,
});
}

toggleItem(id) {
console.log(this.state.hiddenIds);
const idIndex = this.state.hiddenIds.indexOf(id);
if (idIndex >= 0) {
this.state.hiddenIds.splice(idIndex, 1);
} else {
this.state.hiddenIds.push(id);
}
}

onApply() {
this.props.onApply(this.state.hiddenIds);
this.props.close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.ConfigDialog">
<Dialog title="'Dashboard Items Configuration'">
<div>Which cards fo you wish to see?</div>
<div class="list-group">
<t t-foreach="items" t-as="item" t-key="item.id">
<label class="list-group-item d-flex align-items-center">
<input type="checkbox"
class="form-check-input me-3"
t-att-checked="!state.hiddenIds.includes(item.id)"
t-on-change="() => this.toggleItem(item.id)"/>
<t t-esc="item.description"/>
</label>
</t>
</div>
<t t-set-slot="footer">
<button class="btn btn-primary" t-on-click="onApply">Apply</button>
<button class="btn btn-secondary" t-on-click="props.close">Cancel</button>
</t>
</Dialog>
</t>
</templates>
59 changes: 59 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Component, useState } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { browser } from "@web/core/browser/browser";
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/dashboard_item";
import { ConfigDialog } from "./config_dialog/config_dialog";

class AwesomeDashboard extends Component {
static template = "awesome_dashboard.AwesomeDashboard";

static components = { Layout, DashboardItem };

setup() {
this.actionService = useService("action");
this.statisticsService = useService("awesome_dashboard.statistics");
this.statistics = useState(this.statisticsService.statistics);
this.items = registry.category("awesome_dashboard").get("DashboardItems");
this.dialog = useService("dialog");
this.state = useState({
hiddenIds: browser.localStorage.getItem("dashboard_hidden_ids")?.split(",") || [],
});
}

get displayedItems() {
return this.items.filter((item) => !this.state.hiddenIds.includes(item.id));
}

openConfiguration() {
this.dialog.add(ConfigDialog, {
items: this.items,
hiddenIds: this.state.hiddenIds,
onApply: (newHiddenIds) => {
this.state.hiddenIds = newHiddenIds;
browser.localStorage.setItem("dashboard_hidden_ids", newHiddenIds);
},
});
}

openCustomers() {
this.actionService.doAction("base.action_partner_form");
}

openLeads() {
this.actionService.doAction({
type: "ir.actions.act_window",
name: _t("Leads"),
target: "current",
res_model: "crm.lead",
views: [
[false, "list"],
[false, "form"],
],
});
}
}

registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard);
3 changes: 3 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.o_dashboard {
background-color: pink;
}
24 changes: 24 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.AwesomeDashboard">
<Layout display="{ controlPanel: {} }" className="'o_dashboard h-100'">
<t t-set-slot="control-panel-create-button">
<button class="btn btn-primary" t-on-click="openCustomers">Customer</button>
<button class="btn btn-primary" t-on-click="openLeads">Leads</button>
</t>
<t t-set-slot="control-panel-additional-actions">
<button t-on-click="openConfiguration" class="btn p-0 ms-1 border-0">
<i class="fa fa-cog"></i>
</button>
</t>
<div class="row g-3">
<t t-foreach="displayedItems" t-as="item" t-key="item.id">
<DashboardItem size="item.size || 1">
<t t-set="itemProp" t-value="item.props ? item.props(statistics) : {'data': statistics}"/>
<t t-component="item.Component" t-props="itemProp" />
</DashboardItem>
</t>
</div>
</Layout>
</t>
</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component } from "@odoo/owl";

export class DashboardItem extends Component {
static template = "awesome_dashboard.DashboardItem";

static props = {
size: {
type: Number,
},
slots: {
type: Object,
optional: true,
},
};

static defaultProps = {
size: 1,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.DashboardItem">
<div class="card shadow-sm m-3 border" t-attf-style="width: {{ 18 * props.size }}rem;">
<div class="card-body">
<t t-slot="default"/>
</div>
</div>
</t>
</templates>
63 changes: 63 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard_items.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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 = [
{
id: "average_quantity",
description: "Average quantity",
Component: NumberCard,
props: (data) => ({
title: "Average amount of t-shirts by order this month",
value: data.average_quantity,
}),
},
{
id: "average_time",
description: "Average time",
Component: NumberCard,
props: (data) => ({
title: "Average time for an order to go from 'new' to 'sent' or 'cancelled'",
value: data.average_time,
}),
},
{
id: "nb_new_orders",
description: "Number of new orders",
Component: NumberCard,
props: (data) => ({
title: "Number of new orders this month",
value: data.nb_new_orders,
}),
},
{
id: "nb_cancelled_orders",
description: "Number of cancelled orders",
Component: NumberCard,
props: (data) => ({
title: "Number of cancelled orders this month",
value: data.nb_cancelled_orders,
}),
},
{
id: "total_amount",
description: "Total orders",
Component: NumberCard,
props: (data) => ({
title: "Total amount of new orders this month",
value: data.total_amount,
}),
},
{
id: "tshirt_sizes",
description: "T-Shirt orders chart",
Component: PieChartCard,
size: 1,
props: (data) => ({
title: "T-Shirt Sizes By Amount Sold",
data: data.orders_by_size,
}),
},
];

registry.category("awesome_dashboard").add("DashboardItems", items);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Component } from "@odoo/owl";

export class NumberCard extends Component {
static template = "awesome_dashboard.NumberCard";
static props = {
title: { String },
value: { Number },
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.NumberCard">
<div class="position-relative h-100">
<h4><t t-esc="props.title"/></h4>
<div class="h3 text-success"><t t-esc="props.value"/></div>
</div>
</t>
</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Component, onWillStart, useRef, onMounted } from "@odoo/owl";
import { loadJS } from "@web/core/assets";

export class PieChartCard extends Component {
static template = "awesome_dashboard.PieChartCard";
static props = {
data: { type: Object },
title: { type: String },
};

setup() {
this.canvasRef = useRef("canvas");

onWillStart(async () => {
await loadJS("/web/static/lib/Chart/Chart.js");
});

onMounted(() => {
this.drawChart();
});
}

drawChart() {
new Chart(this.canvasRef.el, {
type: "pie",
data: {
labels: Object.keys(this.props.data),
datasets: [
{
label: this.props.title,
data: Object.values(this.props.data),
},
],
},
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.PieChartCard">
<div class="position-relative h-100">
<t t-esc="props.title"/>
<canvas t-ref="canvas"/>
</div>
</t>
</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { registry } from "@web/core/registry";
import { rpc } from "@web/core/network/rpc";
import { reactive } from "@odoo/owl";

export const statisticsService = {
start(env) {
const stats = reactive({ data: {} });

async function fetch() {
const result = await rpc("/awesome_dashboard/statistics");
Object.assign(stats.data, result);
}

fetch();

setInterval(fetch, 10000);

return {
statistics: stats.data,
};
},
};

registry.category("services").add("awesome_dashboard.statistics", statisticsService);
15 changes: 15 additions & 0 deletions awesome_dashboard/static/src/dashboard_action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, xml } from "@odoo/owl";
import { LazyComponent } from "@web/core/assets";
import { registry } from "@web/core/registry";

export class DashboardLoader extends Component {
static components = { LazyComponent };
static template = xml`
<LazyComponent
bundle="'awesome_dashboard.dashboard'"
Component="'AwesomeDashboard'"
/>
`;
}

registry.category("actions").add("awesome_dashboard.dashboard", DashboardLoader);
25 changes: 25 additions & 0 deletions awesome_owl/static/src/card/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Component, useState } from "@odoo/owl";


export class Card extends Component {
Comment on lines +2 to +4

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 2 lines before the class definition seems to be a Python only convention, no need to change it as it's not important but now you know

Suggested change
export class Card extends Component {
export class Card extends Component {

static template = "awesome_owl.Card";

static props = {
title: {
type: String,
validate: val => (val.length > 0),
},
slots: {
type: Object,
optional: true,
},
};

setup() {
this.state = useState({ isOpen: true });
};

toggleOpen() {
this.state.isOpen = !this.state.isOpen;
};
}
Loading