-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[ADD] estate,*: implement real estate management with accounting integration #842
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
arkp-odoo
wants to merge
15
commits into
odoo:18.0
Choose a base branch
from
odoo-dev:18.0-training-arkp
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
effef7c
[ADD] estate: created real estate module
arkp-odoo 9d2b878
[IMP] estate: add access control and enhance UI views
arkp-odoo 904620d
[IMP] estate: add SQL constraints and computed fields
arkp-odoo 0c5ed59
[IMP] estate: offer states and smart button with UI improvements
arkp-odoo 6624d80
[ADD] estate_account: added the generate invoice functionality
arkp-odoo ea3d44b
[FIX] estate: fix indentation and unnecessary whitespaces
arkp-odoo d97e0d7
[FIX] estate: fixed warnings
arkp-odoo 0e8cb2a
[FIX] estate: align code with Odoo guidelines
arkp-odoo e60dd35
[FIX] estate: remove extra spaces and proper EOF
arkp-odoo 5b87f76
[IMP] estate: Add fields to estate models
arkp-odoo 4e323f1
[IMP] estate: Add Kanban view and PDF reports for property and sales…
arkp-odoo 8770246
[IMP] estate: added unit tests
arkp-odoo 64be323
[ADD] awesome_owl: complete custom OWL component module
arkp-odoo 1b97a76
[ADD] awesome_dashboard: implement custom dashboard module
arkp-odoo d92c3d6
[FIX] awesome_dashboard,*: fixed codebase accourding PR review
arkp-odoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
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 "@awesome_dashboard/dashboard/dashboardItem/dashboarditem"; | ||
import { rpc } from "@web/core/network/rpc"; | ||
import { PieChart } from "@awesome_dashboard/dashboard/pieChart/piechart"; | ||
|
||
class AwesomeDashboard extends Component { | ||
static template = "awesome_dashboard.AwesomeDashboard"; | ||
static components = { Layout, DashboardItem, PieChart }; | ||
|
||
setup(){ | ||
const dashboardItemsRegistry = registry.category("awesome_dashboard"); | ||
this.items = dashboardItemsRegistry.getAll(); | ||
this.action = useService("action"); | ||
this.statisticsService = useService("awesome_dashboard.statistics"); | ||
this.state = useState({ statistics: this.statisticsService.statistics }); | ||
this.displayState = useState({ | ||
disabledItems: [], | ||
isLoading: true, | ||
}); | ||
onWillStart(async () => { | ||
try { | ||
const fetchedDisabledItems = await rpc("/web/dataset/call_kw/res.users/get_dashboard_settings", { | ||
model: 'res.users', | ||
method: 'get_dashboard_settings', | ||
args: [], | ||
kwargs: {}, | ||
}); | ||
this.displayState.disabledItems = fetchedDisabledItems; | ||
} catch (error) { | ||
console.error("Error loading initial dashboard settings from server:", error); | ||
this.displayState.disabledItems = []; | ||
} finally { | ||
this.displayState.isLoading = false; | ||
} | ||
}); | ||
} | ||
|
||
openCustomerView() { | ||
this.action.doAction("base.action_partner_form") | ||
} | ||
|
||
openLeadsView() { | ||
this.action.doAction({ | ||
type: 'ir.actions.act_window', | ||
target: 'current', | ||
res_model: 'crm.lead', | ||
views: [[false, 'list'], [false, 'form']] | ||
}) | ||
} | ||
} | ||
|
||
registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.o_dashboard{ | ||
background-color: gray; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="awesome_dashboard.AwesomeDashboard"> | ||
<Layout className="'o_dashboard h-100'" display="{controlPanel: {} }"> | ||
<t t-set-slot="control-panel-create-button"> | ||
<button type="button" class="btn btn-primary o-kanban-button-new" t-on-click="openCustomerView">Customer</button> | ||
<button type="button" class="btn btn-primary o-kanban-button-new" t-on-click="openLeadsView">Leads</button> | ||
</t> | ||
<div class="dashboard-items"> | ||
<t t-foreach="this.items" t-as="item" t-key="item.id"> | ||
<DashboardItem size="item.size || 1" | ||
t-if="!this.displayState.disabledItems.includes(item.id)"> | ||
arkp-odoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<t t-set="itemProp" t-value="item.props ? item.props(this.state.statistics) : {'data': this.state.statistics}"/> | ||
<t t-component="item.Component" t-props="itemProp" /> | ||
</DashboardItem> | ||
</t> | ||
</div> | ||
</Layout> | ||
</t> | ||
</templates> |
9 changes: 9 additions & 0 deletions
9
awesome_dashboard/static/src/dashboard/dashboardItem/dashboarditem.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }, | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
awesome_dashboard/static/src/dashboard/dashboardItem/dashboarditem.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<t t-name="awesome_dashboard.DashboardItem"> | ||
<t t-set="itemSize" t-value="props.size or 1"/> | ||
<div class="card shadow-sm rounded border-secondary m-2" | ||
t-attf-style="width: #{18 * itemSize}rem;"> | ||
arkp-odoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<div class="card-body"> | ||
<t t-slot="default"/> | ||
</div> | ||
</div> | ||
</t> |
12 changes: 12 additions & 0 deletions
12
awesome_dashboard/static/src/dashboard/dashboard_action.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Component, xml } from "@odoo/owl" | ||
import { LazyComponent } from "@web/core/assets"; | ||
import { registry } from "@web/core/registry"; | ||
|
||
export class DashboardComponentLoader extends Component { | ||
static components = { LazyComponent } | ||
static template = xml` | ||
<LazyComponent bundle="'awesome_dashboard.dashboard'" Component="'AwesomeDashboard'" /> | ||
`; | ||
|
||
} | ||
registry.category("actions").add("awesome_dashboard.dashboard", DashboardComponentLoader); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** @odoo-module **/ | ||
|
||
import { NumberCard } from "@awesome_dashboard/dashboard/numbercard/numbercard"; | ||
import { PieChartCard } from "@awesome_dashboard/dashboard/pieChartCard/pie_chart_card"; | ||
import { registry } from "@web/core/registry"; | ||
import { _t } from "@web/core/l10n/translation"; | ||
|
||
const items = [ | ||
{ | ||
id: "nb_new_orders", | ||
description: _t("The number of new orders, this month"), | ||
Component: NumberCard, | ||
size: 1, | ||
props: (data) => ({ | ||
title: _t("New Orders This Month:"), | ||
value: data.data.nb_new_orders | ||
}), | ||
Comment on lines
+14
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make use of js esLint tool for proper linting the code available in the web/tools |
||
}, | ||
{ | ||
id: "total_amount", | ||
description: _t("The total amount of orders, this month"), | ||
Component: NumberCard, | ||
size: 2, | ||
props: (data) => ({ | ||
title: "Total Amount This Month:", | ||
value: data.data.total_amount | ||
}), | ||
}, | ||
{ | ||
id: "average_quantity", | ||
description: _t("The average number of t-shirts by order"), | ||
Component: NumberCard, | ||
size: 1, | ||
props: (data) => ({ | ||
title: _t("Avg. T-Shirts per Order:"), | ||
value: data.data.average_quantity | ||
}), | ||
}, | ||
{ | ||
id: "nb_cancelled_orders", | ||
description: _t("The number of cancelled orders, this month"), | ||
Component: NumberCard, | ||
size: 1, | ||
props: (data) => ({ | ||
title: _t("Cancelled Orders:"), | ||
value: data.data.nb_cancelled_orders | ||
}), | ||
}, | ||
{ | ||
id: "average_time", | ||
description: _t("The average time (in hours) elapsed between the moment an order is created, and the moment is it sent"), | ||
Component: NumberCard, | ||
size: 1, | ||
props: (data) => ({ | ||
title: _t("Avg. Time New → Sent/Cancelled:"), | ||
value: data.data.average_time | ||
}), | ||
}, | ||
{ | ||
id: "orders_by_size", | ||
description: _t("Number of shirts ordered based on size"), | ||
Component: PieChartCard, | ||
size: 3, | ||
props: (data) => ({ | ||
title: _t("Shirt orders by size:"), | ||
value: data.data.orders_by_size | ||
}), | ||
} | ||
] | ||
items.forEach((item) => { | ||
registry.category("awesome_dashboard").add(item.id, item) | ||
}); |
15 changes: 15 additions & 0 deletions
15
awesome_dashboard/static/src/dashboard/numbercard/numbercard.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component } from "@odoo/owl"; | ||
import { _t } from "@web/core/l10n/translation"; | ||
|
||
export class NumberCard extends Component { | ||
static template = "awesome_dashboard.NumberCard"; | ||
|
||
static props = { | ||
title: { type: String }, | ||
value: { type: [String, Number] } | ||
} | ||
|
||
get translatedTitle() { | ||
return _t(this.props.title); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
awesome_dashboard/static/src/dashboard/numbercard/numbercard.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<t t-name="awesome_dashboard.NumberCard"> | ||
<div class="card shadow-sm rounded border-0 m-2"> | ||
<div class="card-body text-center"> | ||
<span class="card-title d-block mb-1 fw-bold text-muted"> | ||
<t t-out="translatedTitle"/> | ||
</span> | ||
<span class="h2 mb-0 fw-semibold text-primary"> | ||
<t t-esc="props.value"/> | ||
</span> | ||
</div> | ||
</div> | ||
</t> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 t-ref="pie_chart_canvas"/> | ||
</t> | ||
</templates> |
63 changes: 63 additions & 0 deletions
63
awesome_dashboard/static/src/dashboard/pieChart/piechart.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Component, onWillStart, useRef, onMounted, useEffect, onWillUnmount } from "@odoo/owl"; | ||
import { loadJS } from "@web/core/assets" | ||
|
||
export class PieChart extends Component { | ||
static template = "awesome_dashboard.Piechart"; | ||
static props = { | ||
data: { type: Object }, | ||
onSliceClick: { type: Function, optional: true }, | ||
}; | ||
setup() { | ||
this.chart = null; | ||
this.pieChartCanvasRef = useRef("pie_chart_canvas"); | ||
|
||
onWillStart(async () => { | ||
await loadJS("/web/static/lib/Chart/Chart.js"); | ||
}) | ||
|
||
this.chartData = { | ||
labels: Object.keys(this.props.data), | ||
datasets: [{ | ||
data: Object.values(this.props.data) | ||
}] | ||
}; | ||
|
||
onMounted(() => { | ||
this.makePieChart(); | ||
}) | ||
|
||
this.cleanupPieChart = () => { | ||
if (this.chart) { | ||
this.chart.destroy(); | ||
this.chart = null; | ||
} | ||
}; | ||
|
||
onWillUnmount(this.cleanupPieChart); | ||
|
||
useEffect(() => { | ||
this.cleanupPieChart(); | ||
if (this.pieChartCanvasRef.el) { | ||
this.makePieChart(); | ||
} | ||
}, () => [this.props.data]) | ||
} | ||
|
||
makePieChart() { | ||
this.chart = new Chart(this.pieChartCanvasRef.el, { | ||
type: "pie", | ||
data: this.chartData, | ||
options: { | ||
responsive: true, | ||
maintainAspectRatio: false, | ||
onClick: (event, elements) => { | ||
if (elements.length > 0) { | ||
if (this.props.onSliceClick) { | ||
this.props.onSliceClick(this.chartData.labels[elements[0].index]); | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
awesome_dashboard/static/src/dashboard/pieChartCard/pie_chart_card.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Component } from "@odoo/owl"; | ||
import { PieChart } from "@awesome_dashboard/dashboard/pieChart/piechart"; | ||
import { useService } from "@web/core/utils/hooks"; | ||
import { _t } from "@web/core/l10n/translation"; | ||
|
||
export class PieChartCard extends Component { | ||
static template = "awesome_dashboard.PieChartCard"; | ||
static components = { PieChart }; | ||
|
||
static props = { | ||
title: { type: String }, | ||
data: { type: Object } | ||
} | ||
|
||
setup() { | ||
this.action = useService("action"); | ||
} | ||
|
||
get translatedTitle() { | ||
return _t(this.props.title); | ||
} | ||
|
||
get translatedValue() { | ||
return _t(this.props.value); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
awesome_dashboard/static/src/dashboard/pieChartCard/pie_chart_card.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<templates xml:space="preserve"> | ||
<t t-name="awesome_dashboard.PieChartCard"> | ||
<div class="card m-2 border-0 shadow-sm rounded"> | ||
<span class="mb-0 fw-bold text-primary"> | ||
<strong> | ||
<t t-esc="translatedTitle" /> | ||
</strong> | ||
</span> | ||
<span class="align-items-center"> | ||
<t t-if="this.props.value"> | ||
<PieChart data="translatedValue" /> | ||
</t> | ||
<t t-else=""> | ||
<div> | ||
<t t-out="_t('Loading Chart...')" /> | ||
arkp-odoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
</t> | ||
</span> | ||
</div> | ||
</t> | ||
</templates> | ||
arkp-odoo marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { rpc } from "@web/core/network/rpc"; | ||
import { registry } from "@web/core/registry"; | ||
import { reactive } from "@odoo/owl"; | ||
|
||
const statisticsService = { | ||
start() { | ||
const statistics = reactive({ data: null, loading: true, error: null }); | ||
|
||
async function fetchStatistics() { | ||
statistics.loading = true; | ||
statistics.error = null; | ||
try { | ||
const response = await rpc("/awesome_dashboard/statistics"); | ||
statistics.data = response; | ||
} catch (e) { | ||
statistics.error = e; | ||
} finally { | ||
statistics.loading = false; | ||
} | ||
} | ||
|
||
async function fetchStatisticsRecursively() { | ||
await fetchStatistics(); | ||
setTimeout(fetchStatisticsRecursively, 600000); | ||
arkp-odoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
fetchStatisticsRecursively(); | ||
|
||
return { | ||
statistics, | ||
reload: fetchStatistics | ||
}; | ||
}, | ||
}; | ||
registry.category("services").add("awesome_dashboard.statistics", statisticsService); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.