Skip to content

[ADD] estate: Real Estate Property Management Module #889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: 18.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
95 changes: 94 additions & 1 deletion awesome_dashboard/static/src/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,103 @@
/** @odoo-module **/

import { Component } from "@odoo/owl";
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { Layout } from "@web/search/layout";
import { useService } from "@web/core/utils/hooks";
import { DashboardItem } from "./dashboard_item/dashboard_item";
import { PieChart } from "./pie_chart/pie_chart";
import { Component, onWillStart, useState } from "@odoo/owl";

class AwesomeDashboard extends Component {
static template = "awesome_dashboard.AwesomeDashboard";
static components = { Layout, DashboardItem, PieChart };

setup() {
this.action = useService("action");
this.statistics = useService("awesome_dashboard.statistics");
this.cards = useState([
{
id: 1,
size: 0,
title: "Number of new orders this month",
value: 0,
},
{
id: 2,
size: 0,
title: "Total amount of new order this month",
value: 0,
},
{
id: 3,
size: 0,
title: "Average amount of t-shirt by order this month",
value: 0,
},
{
id: 4,
size: 0,
title: "Number of cancelled orders this month",
value: 0,
},
{
id: 5,
size: 0,
title: "Average time for an order to go from 'new' to 'sent' or 'cancelled'",
value: 0,
}
]);

onWillStart(async () => {
this.result = await this.statistics.loadStatistics();
this.cards = [
{
id: 1,
size: 2,
title: "Number of new orders this month",
value: this.result.nb_new_orders,
},
{
id: 2,
size: 2,
title: "Total amount of new order this month",
value: this.result.total_amount,
},
{
id: 3,
size: 2,
title: "Average amount of t-shirt by order this month",
value: this.result.average_quantity,
},
{
id: 4,
size: 2,
title: "Number of cancelled orders this month",
value: this.result.nb_cancelled_orders,
},
{
id: 5,
size: 2,
title: "Average time for an order to go from 'new' to 'sent' or 'cancelled'",
value: this.result.average_time,
}
]
});
}

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

openLeads() {
this.action.doAction({
type: 'ir.actions.act_window',
name: _t('Leads'),
target: 'current',
res_model: 'crm.lead',
views: [[false, 'kanban'], [false, 'list'], [false, 'form']], // [view_id, view_type]
});
}
}

registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);
3 changes: 3 additions & 0 deletions awesome_dashboard/static/src/dashboard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.o_dashboard {
background-color: white;
}
24 changes: 23 additions & 1 deletion awesome_dashboard/static/src/dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,29 @@
<templates xml:space="preserve">

<t t-name="awesome_dashboard.AwesomeDashboard">
hello dashboard
<Layout display="{ controlPanel: {} }" className="'o_dashboard h-100'">
<t t-set-slot="layout-buttons">
<button type="button" class="btn btn-primary" t-on-click="openCustomers">Customers</button>
<button type="button" class="btn btn-primary" t-on-click="openLeads">Leads</button>
</t>

<div class="d-flex flex-wrap gap-3 m-3">
<div class="d-flex flex-wrap gap-3">
<t t-foreach="cards" t-as="card" t-key="card.id">
<DashboardItem size="card.size">
<p class="mb-0" style="text-align: left;" t-esc="card.title"/>
<t t-set-slot="value">
<t t-esc="card.value"/>
</t>
</DashboardItem>
</t>
</div>
<DashboardItem size="2">
<p class="mb-0 text-center">T-Shirt orders by size</p>
<PieChart tshirtSales="this.result.orders_by_size"/>
</DashboardItem>
</div>
</Layout>
</t>

</templates>
21 changes: 21 additions & 0 deletions awesome_dashboard/static/src/dashboard_item/dashboard_item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @odoo-module **/

import { Component } from "@odoo/owl";

export class DashboardItem extends Component {
static template = "awesome_dashboard.DashboardItem";
static props = {
size: {
type: Number,
optional: true,
},
slots: {
type: Object,
}
}

setup() {
const size = this.props.size || 1;
this.width = 18*size;
}
}
13 changes: 13 additions & 0 deletions awesome_dashboard/static/src/dashboard_item/dashboard_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.DashboardItem">
<div class="card align-items-center" t-att-style="`width: ${this.width}rem`">
<div class="card-body">
<t t-slot="default"/>
<h1 class="text-center text-sucess" style="color: green;">
<t t-slot="value"/>
</h1>
</div>
</div>
</t>
</templates>
50 changes: 50 additions & 0 deletions awesome_dashboard/static/src/pie_chart/pie_chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/** @odoo-module **/

import { Component, onWillStart, useRef, useEffect } from "@odoo/owl";
import { loadJS } from '@web/core/assets';

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

static props = {
tshirtSales: {
type: Object,
}
}

setup() {
this.canvasRef = useRef("canvas");
onWillStart(async () => {
await loadJS("/web/static/lib/Chart/Chart.js")
});

useEffect(() => {
this.createChart();
return () => this.chart?.destroy();
}, () => []);
}

getChartConfig() {
if (!this.props.tshirtSales) return {};
return {
type: 'pie',
data: {
labels: Object.keys(this.props.tshirtSales),
datasets: [{
data: Object.values(this.props.tshirtSales),
}]
},
options: {
aspectRatio: 2,
}
}
}

createChart() {
if (this.chart) {
this.chart.destroy();
}
const config = this.getChartConfig();
this.chart = new Chart(this.canvasRef.el, config);
}
}
6 changes: 6 additions & 0 deletions awesome_dashboard/static/src/pie_chart/pie_chart.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.PieChart">
<canvas height="500" width="500" t-ref="canvas"/>
</t>
</templates>
20 changes: 20 additions & 0 deletions awesome_dashboard/static/src/statistics_service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** @odoo-module **/

import { registry } from "@web/core/registry";
import { rpc } from "@web/core/network/rpc";
import { memoize } from "@web/core/utils/functions";

const loadStatistics = async() => {
const result = await rpc("/awesome_dashboard/statistics");
return result;
}

export const loadStatService = {
start () {
return {
loadStatistics: memoize(loadStatistics)
}
}
}

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

export class Card extends Component {
static template = "awesome_owl.Card"
static props = {
title: {
type: String,
},
slots: {
type: Object,
},
}

setup() {
this.state = useState({ isCardOpen: false })
}

toggleCard() {
this.state.isCardOpen = !this.state.isCardOpen;
}
}
18 changes: 18 additions & 0 deletions awesome_owl/static/src/card/card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_owl.Card">
<div class="card d-inline-block m-2" style="width: 18rem;">
<div class="card-body">
<div class="d-flex align-items-center" style="justify-content: space-between;">
<h5 class="card-title mb-0">
<t t-esc="props.title"/>
</h5>
<button class="btn btn-primary text-black" style="background: #e7e9ed;" t-on-click="toggleCard">Toggle</button>
</div>
<t t-if="state.isCardOpen">
<t t-slot="default"/>
</t>
</div>
</div>
</t>
</templates>
25 changes: 25 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Component, useState } from "@odoo/owl";

export class Counter extends Component {
static template = "awesome_owl.Counter";
static props = {
title: {
type: String,
},
onChange: {
type: Function,
optional: true,
}
}

setup() {
this.state = useState({ value: 1 });
}

increment() {
this.state.value++;
if (this.props.onChange) {
this.props.onChange();
}
}
}
11 changes: 11 additions & 0 deletions awesome_owl/static/src/counter/counter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_owl.Counter">
<div class="d-flex align-items-center border p-4 gap-4">
<p class="mb-0">
<t t-esc="props.title"/>: <t t-esc="state.value"></t>
</p>
<button class="btn btn-primary text-white" style="background: #714b67" t-on-click="increment">Increment</button>
</div>
</t>
</templates>
16 changes: 15 additions & 1 deletion awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
/** @odoo-module **/

import { Component } from "@odoo/owl";
import { Component, useState, markup } from "@odoo/owl";
import { Counter } from "./counter/counter";
import { Card } from "./card/card";
import { TodoList } from "./todo/todo_list";

export class Playground extends Component {
static template = "awesome_owl.playground";
static components = { Counter, Card, TodoList }
html = ('<h3>hello world</h3>');
markup_html = markup(this.html);

setup() {
this.state = useState({ sum: 2 });
}

incrementSum() {
this.state.sum++;
}
}
33 changes: 31 additions & 2 deletions awesome_owl/static/src/playground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,37 @@
<templates xml:space="preserve">

<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
<div class="d-flex justify-content-center">
<div class="border m-5">
<div class="d-flex gap-4 p-3" style="max-width: fit-content;">
<Counter title="'Counter 1'" onChange.bind="incrementSum"/>
<Counter title="'Counter 2'" onChange.bind="incrementSum"/>
</div>
<p class="ms-3">Sum is: <t t-esc="state.sum"></t></p>
</div>

<!-- Card Component -->
<div class="p-3 border m-5" style="max-width: fit-content;">
<h1>Cards</h1>
<div class="d-flex gap-3">
<Card title="'Gandhinagar'">
<p class="card-text">Using Slot for card 1</p>
</Card>
<Card title="'Ahmedabad'">
<p class="card-text">
<t t-out="markup_html"/>
</p>
</Card>
<Card title="'Counter Card'">
<Counter title="'Counter 3'" onChange.bind="incrementSum"/>
</Card>
</div>
</div>
</div>

<!-- Todo List Component -->
<div class="mt-5">
<TodoList/>
</div>
</t>

Expand Down
Loading