Skip to content

[ADD] estate_property: added real estate module #840

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 7 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/


.vscode/
10 changes: 0 additions & 10 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.

37 changes: 37 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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";
import { DashboardItem } from "./dashboard_item/dashboard_item";
import { PieChart } from "./piechart/PieChart";

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

setup() {
this.action = useService("action");
this.display = {
controlPanel: {},
};
this.statistics = useState(useService("awesome_dashboard.statistics"));
}

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

openLead() {
this.action.doAction({
type: "ir.actions.act_window",
name: "Leads",
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: rgb(46, 255, 108);
}
49 changes: 49 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_dashboard.AwesomeDashboard">
<Layout display="display" className="'o_dashboard h-100'">
<t t-set-slot="layout-buttons">
<button class="btn btn-primary" t-on-click="openCustomer">Customers</button>
<button class="btn btn-primary" t-on-click="openLead">Leads</button>
</t>
<div class="d-flex flex-wrap o_dashboard_statistics_container" t-if="statistics.isReady">
<DashboardItem size="2">
Average Quantity of new orders this month
<div class="fs-1 fw-bold text-success text-center">
<t t-esc="statistics.average_quantity"/>
</div>
</DashboardItem>
<DashboardItem size="2">
Average time for an order to go from 'new' to 'sent' or 'cancelled'
<div class="fs-1 fw-bold text-success text-center">
<t t-esc="statistics.average_time"/>
</div>
</DashboardItem>
<DashboardItem size="2">
Number of new orders this month
<div class="fs-1 fw-bold text-success text-center">
<t t-esc="statistics.nb_new_orders"/>
</div>
</DashboardItem>
<DashboardItem size="2">
Number of cancelled orders this month
<div class="fs-1 fw-bold text-success text-center">
<t t-esc="statistics.nb_cancelled_orders"/>
</div>
</DashboardItem>
<DashboardItem size="2">
Total amount of new orders this month
<div class="fs-1 fw-bold text-success text-center">
<t t-esc="statistics.total_amount"/>
</div>
</DashboardItem>
<DashboardItem size="2">
Shirt orders by size
<PieChart data="statistics['orders_by_size']" label="'Shirt orders by size'"/>
</DashboardItem>
</div>
</Layout>
</t>

</templates>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component } from "@odoo/owl";

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

get cardStyle() {
return `width: ${this.props.size * 18}rem;`;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.o_dashboard_card {
background-color: white;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 16px;
margin: 10px;
display: inline-block;
vertical-align: top;
}
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="o_dashboard_card" t-att-style="cardStyle">
<t t-slot="default"/>
</div>
</t>

</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component } from "@odoo/owl";

export class NumberCard extends Component {
static template = "awesome_dashboard.NumberCard";
static props = {
title: {
type: String,
optional: false,
},
value: {
type: Number,
optional: false,
},
}
}
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" owl="1">
<t t-esc="props.title"/>
<div class="fs-1 fw-bold text-success text-center">
<t t-esc="props.value"/>
</div>
</t>
</templates>
41 changes: 41 additions & 0 deletions awesome_dashboard/static/src/dashboard/piechart/PieChart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { loadJS } from "@web/core/assets";
import { getColor } from "@web/core/colors/colors";
import { Component, onWillStart, useRef, onMounted, onWillUnmount } from "@odoo/owl";

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

setup() {
this.canvasRef = useRef("canvas");
onWillStart(() => loadJS(["/web/static/lib/Chart/Chart.js"]));
onMounted(() => {
this.renderChart();
});
onWillUnmount(() => {
this.chart.destroy();
});
}

renderChart() {
const labels = Object.keys(this.props.data);
const data = Object.values(this.props.data);
const color = labels.map((_, index) => getColor(index));
this.chart = new Chart(this.canvasRef.el, {
type: "pie",
data: {
labels: labels,
datasets: [
{
label: this.props.label,
data: data,
backgroundColor: color,
},
],
},
});
}
}
10 changes: 10 additions & 0 deletions awesome_dashboard/static/src/dashboard/piechart/PieChart.xml
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.PieChart">
<div t-att-class="'h-100 ' + props.class" t-ref="root">
<div class="h-100 position-relative" t-ref="container">
<canvas t-ref="canvas" />
</div>
</div>
</t>
</templates>
15 changes: 15 additions & 0 deletions awesome_dashboard/static/src/dashboard_loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @odoo-module */

import { registry } from "@web/core/registry";
import { LazyComponent } from "@web/core/assets";
import { Component, xml } from "@odoo/owl";

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

}

registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboardLoader);
24 changes: 24 additions & 0 deletions awesome_dashboard/static/src/statistics_service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { registry } from "@web/core/registry";
import { reactive } from "@odoo/owl";
import { rpc } from "@web/core/network/rpc";

const statisticsService = {

start(env) {
const statistics = reactive({ isReady: false });

async function loadData() {
const updates = await rpc("/awesome_dashboard/statistics");
Object.assign(statistics, updates, { isReady: true });
}

setInterval(loadData, 10 * 60 * 1000);
loadData();

return statistics;
},
};

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

export class TodoItem extends Component {
static template = "awesome_owl.todo_item";
static props = {
todo: {
type: Object,
shape: {
id: { type: Number, default: 0 },
description: { type: String },
isCompleted: { type: Boolean },
},
},
removeTodo: { type: Function, optional: true },
toggleState: { type: Function, optional: true },
};

onToggle() {
if (this.props.toggleState) {
this.props.toggleState(this.props.todo.id);
}
}
onRemoveTodo() {
if (this.props.removeTodo) {
this.props.removeTodo(this.props.todo.id);
}
}
}
19 changes: 19 additions & 0 deletions awesome_owl/static/src/Todo/todo_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_owl.todo_item">
<li class="list-group-item d-flex justify-content-between align-items-center" t-att-class="props.todo.isCompleted ? 'text-muted text-decoration-line-through' : ''">
<div class="d-flex align-items-center gap-3">
<input type="checkbox" t-att-checked="props.todo.isCompleted || undefined" t-on-change="onToggle" />
<strong class="text-primary me-2"># <t t-esc="props.todo.id"/>
</strong>
<span>
<t t-esc="props.todo.description"/>
</span>
<span class="fa fa-remove text-danger" t-on-click="onRemoveTodo" style="cursor: pointer;"></span>
</div>
<span class="badge rounded-pill" t-att-class="props.todo.isCompleted ? 'bg-success' : 'bg-warning text-dark'">
<t t-esc="props.todo.isCompleted ? 'Done' : 'Pending'"/>
</span>
</li>
</t>
</templates>
41 changes: 41 additions & 0 deletions awesome_owl/static/src/Todo/todo_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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 };
static props = {};

setup() {
this.todos = useState([]);
}

toggleState = (id) => {
const todo = this.todos.find((t) => t.id === id);
if (todo) {
todo.isCompleted = !todo.isCompleted;
}
};

addTodo(ev) {
if (ev.keyCode !== 13) return;
const description = ev.target.value.trim();

if (!description) return;

this.todos.push({
id: this.todos.length + 1,
description: description,
isCompleted: false,
});

ev.target.value = "";
}

onRemoveTodo = (todoId) => {
const index = this.todos.findIndex((elem) => elem.id === todoId);
if (index >= 0) {
this.todos.splice(index, 1);
}
};
}
18 changes: 18 additions & 0 deletions awesome_owl/static/src/Todo/todo_list.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.todo_list">
<div class="container d-flex justify-content-center mt-5">
<div class="card shadow-sm w-100" style="max-width: 500px;">
<div class="card-body">
<h3 class="card-title text-center mb-4">📝 My Todo List</h3>
<input type="text" class="form-control mb-3" placeholder="Add a new todo..." t-on-keyup="addTodo" t-ref="newTodoInput"/>
<ul class="list-group list-group-flush">
<t t-foreach="todos" t-as="todo" t-key="todo.id">
<TodoItem todo="todo" toggleState="toggleState" removeTodo="onRemoveTodo" />
</t>
</ul>
</div>
</div>
</div>
</t>
</templates>
Loading