Skip to content

[ADD] real_estate : add real estate property and create invoice #845

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
3 changes: 3 additions & 0 deletions awesome_dashboard/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
'views/views.xml',
],
'assets': {
"awesome_dashboard.dashboard_assets": [
"awesome_dashboard/static/src/dashboard/**/*",
],
'web.assets_backend': [
'awesome_dashboard/static/src/**/*',
],
Expand Down
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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @odoo-module **/

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 @@
.dashboard-item {
margin: 0.5rem;
padding: 1rem;
background: white;
border: 1px solid #ccc;
border-radius: 0.5rem;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="awesome_dashboard.DashboardItem" owl="1">
<div t-attf-style="width: {{18 * props.size}}rem;" class="dashboard-item o_boxed">
<t t-slot="default" />
</div>
</t>
</templates>
11 changes: 11 additions & 0 deletions awesome_dashboard/static/src/dashboard/NumberCard/number_card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @odoo-module **/

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

export class NumberCard extends Component {
static template = "awesome_dashboard.NumberCard"; // Match template name in XML
static props = {
title: { type: String },
value: { type: Number },
};
}
13 changes: 13 additions & 0 deletions awesome_dashboard/static/src/dashboard/NumberCard/number_card.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.NumberCard" owl="1">
<div class="o_card">
<h4>
<t t-esc="props.title"/>
</h4>
<div class="number">
<t t-esc="props.value"/>
</div>
</div>
</t>
</templates>
64 changes: 64 additions & 0 deletions awesome_dashboard/static/src/dashboard/PieChart/pie_chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/** @odoo-module **/

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

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

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

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

onMounted(() => {
if (!this.props.data || Object.keys(this.props.data).length === 0) {
console.warn("PieChart: No data provided for chart.");
console.log(this.props.data);
return;
}

const ctx = this.canvasRef.el.getContext("2d");

const data = {
labels: Object.keys(this.props.data),
datasets: [
{
label: "Shirt Sizes",
data: Object.values(this.props.data),
backgroundColor: [
"#3498db",
"#e67e22",
"#2ecc71",
"#9b59b6",
"#95a5a6",
],
},
],
};

new window.Chart(ctx, {
type: "pie",
data,
options: {
responsive: true,
plugins: {
legend: {
position: "top",
},
title: {
display: true,
text: "Shirt orders by size",
},
},
},
});
});
}
}
6 changes: 6 additions & 0 deletions awesome_dashboard/static/src/dashboard/PieChart/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>
<t t-name="awesome_dashboard.PieChart" owl="1">
<canvas t-ref="canvas" style="width: 100%; height: 100%;"></canvas>
</t>
</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.PieChartCard" owl="1">
<t t-esc="props.title"/>
<PieChart data="props.values" label="''"/>
</t>
</templates>
17 changes: 17 additions & 0 deletions awesome_dashboard/static/src/dashboard/PieChart/piechart_card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @odoo-module */

import { Component } from "@odoo/owl";
import { PieChart } from "./pie_chart.js";

export class PieChartCard extends Component {
static template = "awesome_dashboard.PieChartCard";
static components = { PieChart };
static props = {
title: {
type: String,
},
values: {
type: Object,
},
};
}
92 changes: 92 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/** @odoo-module **/

import { Component, useState } from "@odoo/owl";
import { useService } from "@web/core/utils/hooks";
import { Layout } from "@web/search/layout";
import { registry } from "@web/core/registry";
import { DashboardItem } from "./DashboardItem/dashboard_item.js";
import { Dialog } from "@web/core/dialog/dialog";
import { CheckBox } from "@web/core/checkbox/checkbox";
import { browser } from "@web/core/browser/browser";

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

setup() {
this.items = registry.category("awesome_dashboard").getAll();
this.action = useService("action");
this.display = {
controlPanel: {},
};

const statisticsService = useService("awesome_dashboard.statistics");
this.stats = useState(statisticsService.getStatistics());
this.dialog = useService("dialog");
this.state = useState({
disabledItems:
browser.localStorage.getItem("disabledDashboardItems")?.split(",") ||
[],
});
}

openConfiguration() {
this.dialog.add(ConfigurationDialog, {
items: this.items,
disabledItems: this.state.disabledItems,
onUpdateConfiguration: this.updateConfiguration.bind(this),
});
}
updateConfiguration(newDisabledItems) {
this.state.disabledItems = newDisabledItems;
}
openCustomers() {
this.action.doAction("base.action_partner_form");
}

openLeads() {
this.action.doAction({
type: "ir.actions.act_window",
name: "Leads",
res_model: "crm.lead",
views: [
[false, "list"],
[false, "form"],
],
target: "current",
});
}
}
class ConfigurationDialog extends Component {
static template = "awesome_dashboard.ConfigurationDialog";
static components = { Dialog, CheckBox };
static props = ["close", "items", "disabledItems", "onUpdateConfiguration"];

setup() {
this.items = useState(
this.props.items.map((item) => {
return {
...item,
enabled: !this.props.disabledItems.includes(item.id),
};
})
);
}

done() {
this.props.close();
}

onChange(checked, changedItem) {
changedItem.enabled = checked;
const newDisabledItems = Object.values(this.items)
.filter((item) => !item.enabled)
.map((item) => item.id);

browser.localStorage.setItem("disabledDashboardItems", newDisabledItems);

this.props.onUpdateConfiguration(newDisabledItems);
}
}

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: gray;
}
45 changes: 45 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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">
<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>
</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="o_dashboard">
<t t-foreach="items" t-as="item" t-key="item.id">
<DashboardItem t-if="!state.disabledItems.includes(item.id)" size="item.size || 1">
<t t-set="itemProp" t-value="item.props ? item.props(stats) : {'data': stats}"/>
<t t-component="item.Component" t-props="itemProp" />
</DashboardItem>
</t>
</div>
</Layout>
</t>
<t t-name="awesome_dashboard.ConfigurationDialog">
<Dialog title="'Dashboard items configuration'">
Which cards do you whish to see ?
<t t-foreach="items" t-as="item" t-key="item.id">
<CheckBox value="item.enabled" onChange="(ev) => this.onChange(ev, item)">
<t t-esc="item.description"/>
</CheckBox>
</t>
<t t-set-slot="footer">
<button class="btn btn-primary" t-on-click="done">
Done
</button>
</t>
</Dialog>
</t>
</templates>
68 changes: 68 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard_items.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/** @odoo-module */

import { NumberCard } from "./NumberCard/number_card.js";
import { PieChartCard } from "./PieChart/piechart_card.js";
import { registry } from "@web/core/registry";

const items = [
{
id: "average_quantity",
description: "Average amount of t-shirt",
Component: NumberCard,
props: (data) => ({
title: "Average amount of t-shirt by order this month",
value: data.average_quantity,
}),
},
{
id: "average_time",
description: "Average time for an order",
Component: NumberCard,
props: (data) => ({
title:
"Average time for an order to go from 'new' to 'sent' or 'cancelled'",
value: data.average_time,
}),
},
{
id: "number_new_orders",
description: "New orders this month",
Component: NumberCard,
props: (data) => ({
title: "Number of new orders this month",
value: data.nb_new_orders,
}),
},
{
id: "cancelled_orders",
description: "Cancelled orders this month",
Component: NumberCard,
props: (data) => ({
title: "Number of cancelled orders this month",
value: data.nb_cancelled_orders,
}),
},
{
id: "amount_new_orders",
description: "amount orders this month",
Component: NumberCard,
props: (data) => ({
title: "Total amount of new orders this month",
value: data.total_amount,
}),
},
{
id: "pie_chart",
description: "Shirt orders by size",
Component: PieChartCard,
size: 2,
props: (data) => ({
title: "Shirt orders by size",
values: data.orders_by_size,
}),
},
];

items.forEach((item) => {
registry.category("awesome_dashboard").add(item.id, item);
});
Loading