Skip to content

[ADD] estate: add real estate module #223

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

Closed
wants to merge 15 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ celerybeat.pid
*.sage.py

# Environments
.vscode/
.env
.venv
env/
Expand Down
39 changes: 19 additions & 20 deletions awesome_dashboard/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
# -*- coding: utf-8 -*-
{
'name': "Awesome Dashboard",

'summary': """
"name": "Awesome Dashboard",
"summary": """
Starting module for "Discover the JS framework, chapter 2: Build a dashboard"
""",

'description': """
"description": """
Starting module for "Discover the JS framework, chapter 2: Build a dashboard"
""",

'author': "Odoo",
'website': "https://www.odoo.com/",
'category': 'Tutorials/AwesomeDashboard',
'version': '0.1',
'application': True,
'installable': True,
'depends': ['base', 'web', 'mail', 'crm'],

'data': [
'views/views.xml',
"author": "Odoo",
"website": "https://www.odoo.com/",
"category": "Tutorials/AwesomeDashboard",
"version": "0.1",
"application": True,
"installable": True,
"depends": ["base", "web", "mail", "crm"],
"data": [
"views/views.xml",
],
'assets': {
'web.assets_backend': [
'awesome_dashboard/static/src/**/*',
"assets": {
"web.assets_backend": [
"awesome_dashboard/static/src/**/*",
],
"awesome_dashboard.dashboard": [
"awesome_dashboard/static/src/dashboard/**/*",
],
},
'license': 'AGPL-3'
"license": "AGPL-3",
}
10 changes: 0 additions & 10 deletions awesome_dashboard/static/src/dashboard.js

This file was deleted.

40 changes: 40 additions & 0 deletions awesome_dashboard/static/src/dashboard/chart/pie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Component, useRef, onWillStart, useEffect } from "@odoo/owl";
import { loadJS } from "@web/core/assets";

export class PieChart extends Component {
static template = "awesome_dashboard.pie_chart";
static props = {
data: { type: Object },
};

setup() {
this.canvasRef = useRef('canvasRef');
this.chart = null;

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

useEffect(()=> this.renderChart())

}

renderChart() {
if (this.chart) {
this.chart.destroy();}
this.chart = new Chart(this.canvasRef.el, this.getChartConfig());
}

getChartConfig() {
return {
type: 'pie',
data: {
labels: this.props.labels,
datasets: [{
data: Object.values(this.props.data)
}],
},
}
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_dashboard.AwesomeDashboard">
hello dashboard
<t t-name="awesome_dashboard.pie_chart">
<canvas t-ref="canvasRef"></canvas>

</t>

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

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 { DashboardItem } from "./dashboarditem/dashboarditem";
import { PieChart } from "./chart/pie";
import { dashboardRegistry } from "./dashboarditem/dashboard_items";
import { SettingsDialog } from "./dialog/dialog";

class AwesomeDashboard extends Component {
static template = "awesome_dashboard.AwesomeDashboard";
static components = { Layout , DashboardItem , PieChart};
setup() {
this.action = useService("action");
this.dialogService = useService("dialog");

this.statisticsService = useService("awesome_dashboard.statistics");
this.state = useState(this.statisticsService.state.dashboardItems);

const savedHiddenItems = JSON.parse(localStorage.getItem("hidden_dashboard_items"));
this.state.hiddenItems = new Set(savedHiddenItems);


}
get display() {
return {controlPanel: {} }
}
async openCustomers() {

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

async opendialog() {
this.dialogService.add(SettingsDialog, {
onApply: (hiddenItems) => {
this.state.hiddenItems = new Set(hiddenItems);
},
});
}
async openCrmlead() {
this.action.doAction({
type: 'ir.actions.act_window',
name:'crm leads',
target: 'current',
res_model: 'crm.lead',
views: [[false, 'list'],[false, 'form']],
});
}
get visibleItems() {
return Object.values(dashboardRegistry.getAll()).filter(item => !this.state.hiddenItems.has(item.id));
}
}

registry.category("lazy_components").add("awesome_dashboard.dashboard", AwesomeDashboard);
Empty file.
36 changes: 36 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_dashboard.AwesomeDashboard">


<Layout className="'o_dashboard h-100 '" display="display">

<t t-set-slot="layout-buttons">
<button type="object" t-on-click="openCustomers" class="btn btn-primary">Customers</button>
<button type="object" t-on-click="openCrmlead" class="btn btn-primary">leads</button>


</t>
<t t-set-slot="control-panel-additional-actions">
<button class="btn" t-on-click="opendialog">
<i class="fa fa-cog" />
</button>
</t>

<div class="d-flex flex-wrap justify-content-center">
<t t-foreach="visibleItems" t-as="item" t-key="item.id">
<div class="p-2 gap-2">
<DashboardItem size="item.size || 1">
<t >
<t t-component="item.Component" t-props="item.props(this.state[item.id])" />
</t>
</DashboardItem>
</div>
</t>
</div>
</Layout>

</t>

</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/** @odoo-module **/
import { NumberCard } from "./number_card";
import { PieChartCard } from "./pie_chart_card";
import { registry } from "@web/core/registry";

export const dashboardRegistry = registry.category("awesome_dashboard.items");

dashboardRegistry.add(
"average_quantity", {
id: "average_quantity",
description: "Average amount of t-shirt by order",
Component: NumberCard,
size: 1,
props: (data) => ({
title: "T-shirt Ordered",
value: data,
}),
})

dashboardRegistry.add(
"average_time", {
id: "average_time",
description: "Average Time",
Component: NumberCard,
size: 2,
props: (data) => ({
title: "Average time for an order to go from 'new' to 'sent' or 'cancelled'",
value: data,
}),
})

dashboardRegistry.add(
"nb_new_orders", {
id: "nb_new_orders",
description: "New orders this month",
Component: NumberCard,
size: 1,
props: (data) => ({
title: "Numbers of new orders this month",
value: data,
}),
})

dashboardRegistry.add(
"nb_cancelled_orders", {
id: "nb_cancelled_orders",
description: "Cancelled orders this month",
Component: NumberCard,
size: 1,
props: (data) => ({
title: "Numbers of cancelled orders this month",
value: data,
})
})

dashboardRegistry.add(
"total_amount", {
id: "total_amount",
description: "Total Orders",
Component: NumberCard,
size: 1,
props: (data) => ({
title: "Total Numbers of new orders this month",
value: data,
}),
})

dashboardRegistry.add(
"orders_by_size", {
id: "orders_by_size",
description: "Orders by size",
Component: PieChartCard,
size: 1.5,
props: (data) => ({
label: "Orders by size",
data: data,
}),
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Component } from "@odoo/owl";

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.dashboarditem">
<div class="card shadow-sm rounded-3 p-3 text-center d-flex flex-column align-items-center justify-content-center" t-att-style="'width: ' + (18 * (props.size || 1)) + 'rem'">
<t t-slot="default" />
</div>
</t>
</templates>
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,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_dashboard.NumberCard">
<t t-out="this.props.title" />
<div style="font-size:60px; color: green; font-weight:bold" class="d-flex justify-content-center align-items-center">
<t t-out="this.props.value" />
</div>
</t>

</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component} from "@odoo/owl";
import { PieChart } from "../chart/pie";
export class PieChartCard extends Component {
static template= 'awesome_dashboard.PieChartCard'

static props = {
label: String,
data: Object,
};

static components = { PieChart };
}
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">
<t t-out="this.props.label" />
<PieChart data="this.props.data" />
</t>

</templates>
Loading