-
Notifications
You must be signed in to change notification settings - Fork 3k
luleg - Technical Training - Creation of the Real Estate Module #1176
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
Open
Astremy
wants to merge
15
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-creation-estate-module-luleg
base: 19.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.
Open
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9658532
[ADD] Real Estate: Creation of the module definition
Astremy 64e5ae6
[IMP] Real Estate: Add basic property model
Astremy 95a5568
[IMP] real estate: Set base data and access rights
Astremy 63a9396
[IMP] Real Estate: Add estate application page with list and form view.
Astremy 68e374f
[IMP] Real estate: Improvement of the property model, addition of the…
Astremy adf087f
[IMP] Real Estate: Change of property types from a selection to a man…
Astremy 48de967
[IMP] Real Estate: Added offers and automatic calculations
Astremy 03a702a
[IMP] Real Estate: Setup of validation
Astremy 4d76898
[IMP] Real Estate: Added some constraints to the price
Astremy c731814
[IMP] Real Estate : Addition of a smart buttons and changes in offers…
Astremy af3b60c
[IMP] Added integration to res.user
Astremy 953b021
[IMP] Addition of a new module
Astremy 005e491
[IMP] Real Estate: Setup Kanban View
Astremy 97a128c
[ADD] Awesome Dashboard: Addition of the dashboard and statistics
Astremy 8430da6
[IMP] Upgrade of the Dashboard, with selection of modules
Astremy 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 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 @@ | ||
| import { memoize } from "@web/core/utils/functions"; | ||
| import { registry } from "@web/core/registry"; | ||
| import { rpc } from "@web/core/network/rpc"; | ||
| import { reactive } from "@odoo/owl"; | ||
|
|
||
| export const statistics = { | ||
| async start() { | ||
| const data = reactive({statistics: await rpc("/awesome_dashboard/statistics")}) | ||
|
|
||
| setInterval(async () => { | ||
| const getStatistics = await rpc("/awesome_dashboard/statistics"); | ||
| data.statistics = getStatistics; | ||
| console.log(data) | ||
| }, 1_000*10) | ||
|
|
||
| return { | ||
| data: data | ||
| } | ||
| } | ||
| } | ||
|
|
||
| registry.category("services").add("statistics", statistics) |
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 |
|---|---|---|
| @@ -1,8 +1,48 @@ | ||
| import { Component } from "@odoo/owl"; | ||
| import { Component, onWillStart, useEffect, 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/dashboardItem"; | ||
| import { PieChart } from "./pie_chart/pieChart" | ||
|
|
||
| class AwesomeDashboard extends Component { | ||
| static template = "awesome_dashboard.AwesomeDashboard"; | ||
|
|
||
| static components = { Layout, DashboardItem, PieChart }; | ||
|
|
||
| setup() { | ||
| this.action = useService("action"); | ||
| const statistics = useService("statistics"); | ||
|
|
||
| this.statisticsData = useState(statistics.data); | ||
|
|
||
|
|
||
| const updateData = ((data) => { | ||
| this.result = data | ||
|
|
||
| this.data = Object.entries(data.orders_by_size).map(([key, value]) => ({ | ||
| label: key, | ||
| value: value | ||
| })); | ||
| }).bind(this) | ||
|
|
||
| onWillStart(() => { | ||
| updateData(this.statisticsData.statistics) | ||
| }) | ||
|
|
||
| useEffect(updateData, () => [this.statisticsData.statistics]) | ||
| } | ||
| openCustomers() { | ||
| this.action.doAction("base.action_partner_form"); | ||
| } | ||
|
|
||
| openLeads(){ | ||
| this.action.doAction({ | ||
| type: "ir.actions.act_window", | ||
| views: [[false, "list"], [false, 'form']], | ||
| res_model: "crm.lead", | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| registry.category("actions").add("awesome_dashboard.dashboard", 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: #edfffb; | ||
| } |
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 |
|---|---|---|
| @@ -1,8 +1,43 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="awesome_dashboard.AwesomeDashboard"> | ||
| hello dashboard | ||
| <Layout display="{controlPanel: {} }" className="'o_dashboard h-100'"> | ||
| <t t-set-slot="control-panel-create-button"> | ||
| <button class="btn btn-primary" t-on-click.stop.prevent="() => this.openCustomers()"> | ||
| Customers | ||
| </button> | ||
| <button class="btn btn-primary" t-on-click.stop.prevent="() => this.openLeads()"> | ||
| Leads | ||
| </button> | ||
| </t> | ||
| <div> | ||
| <DashboardItem size="1.2"> | ||
| <span style="text-align: center; display:block;">Average amount of t-shirt by order this month</span> | ||
| <span style="color: green; font-size:30px; text-align: center; display:block;"><t t-esc="result.average_quantity"/></span> | ||
| </DashboardItem> | ||
| <DashboardItem size="2"> | ||
| <span style="text-align: center; display:block;">Average time for an order to go from 'new' to 'sent' or 'cancelled'</span> | ||
| <span style="color: green; font-size:30px; text-align: center; display:block;"><t t-esc="result.average_time"/></span> | ||
| </DashboardItem> | ||
| <DashboardItem> | ||
| <span style="text-align: center; display:block;">Number of new orders this month</span> | ||
| <span style="color: green; font-size:30px; text-align: center; display:block;"><t t-esc="result.nb_new_orders"/></span> | ||
| </DashboardItem> | ||
| <DashboardItem> | ||
| <span style="text-align: center; display:block;">Number of cancelled orders this month</span> | ||
| <span style="color: green; font-size:30px; text-align: center; display:block;"><t t-esc="result.nb_cancelled_orders"/></span> | ||
| </DashboardItem> | ||
| <DashboardItem> | ||
| <span style="text-align: center; display:block;">Total amount of new orders this month</span> | ||
| <span style="color: green; font-size:30px; text-align: center; display:block;"><t t-esc="result.total_amount"/></span> | ||
| </DashboardItem> | ||
| <DashboardItem size="2.5"> | ||
| <span style="text-align: center; display:block;">Shirt orders by size</span> | ||
| <span style="color: green; font-size:30px; margin: auto; display:block; width:50%"> | ||
| <PieChart label="'Shirts ordered'" data="data" /> | ||
| </span> | ||
| </DashboardItem> | ||
| </div> | ||
| </Layout> | ||
| </t> | ||
|
|
||
| </templates> |
14 changes: 14 additions & 0 deletions
14
awesome_dashboard/static/src/dashboard_item/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,14 @@ | ||
| 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, optional: true }, | ||
| }; | ||
|
|
||
| static defaultProps = { | ||
| size: 1, | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
awesome_dashboard/static/src/dashboard_item/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,10 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_dashboard.DashboardItem"> | ||
| <div class="card d-inline-block m-2" t-attf-style="width: {{18*props.size}}rem;"> | ||
| <div class="card-body"> | ||
| <t t-slot="default"/> | ||
| </div> | ||
| </div> | ||
| </t> | ||
| </templates> |
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,52 @@ | ||
| import { Component, onWillUnmount, useEffect, useRef, onWillStart } from "@odoo/owl"; | ||
| import { loadJS } from "@web/core/assets"; | ||
|
|
||
| export class PieChart extends Component { | ||
| static template = "awesome_dashboard.PieChart"; | ||
|
|
||
| static props = { | ||
| label: {type: String, optional: true}, | ||
| data: { type: Array, element:{ | ||
| type: Object, shape: {label: String, value: Number } | ||
| } }, | ||
| }; | ||
|
|
||
| setup() { | ||
| this.canvasRef = useRef("canvas"); | ||
|
|
||
| this.chart = null; | ||
|
|
||
| onWillStart(() => loadJS(["/web/static/lib/Chart/Chart.js"])); | ||
|
|
||
| useEffect(() => this.renderChart()); | ||
| onWillUnmount(this.onWillUnmount); | ||
| } | ||
|
|
||
| onWillUnmount() { | ||
| if (this.chart) { | ||
| this.chart.destroy(); | ||
| } | ||
| } | ||
|
|
||
| getChartConfig() { | ||
| return { | ||
| type: "doughnut", | ||
| data: { | ||
| datasets: [{ | ||
| data: this.props.data.map((element) => element.value), | ||
| label: this.props.label | ||
| }], | ||
| labels: this.props.data.map((element) => element.label), | ||
| } | ||
|
|
||
| } | ||
| } | ||
|
|
||
| renderChart() { | ||
| if (this.chart) { | ||
| this.chart.destroy(); | ||
| } | ||
| const config = this.getChartConfig(); | ||
| this.chart = new Chart(this.canvasRef.el, config); | ||
| } | ||
| } |
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="canvas" /> | ||
| </t> | ||
| </templates> |
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,10 @@ | ||
| import { Component } from "@odoo/owl"; | ||
|
|
||
| export class Card extends Component { | ||
| static template = "awesome_owl.Card"; | ||
|
|
||
| static props = { | ||
| title: String, | ||
| content: String | ||
| }; | ||
| } |
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 @@ | ||
| <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"> | ||
| <h5 class="card-title"><t t-out="props.title"/></h5> | ||
| <p class="card-text"> | ||
| <t t-out="props.content"/> | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </t> | ||
| </templates> |
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,18 @@ | ||
| import { Component, useState } from "@odoo/owl"; | ||
|
|
||
| export class Counter extends Component { | ||
| static template = "awesome_owl.Counter"; | ||
|
|
||
| static props = { | ||
| onChange: { type: Function, optional: true } | ||
| } | ||
|
|
||
| setup() { | ||
| this.state = useState({ value: 0 }); | ||
| } | ||
|
|
||
| increment() { | ||
| this.state.value++; | ||
| if (this.props.onChange) this.props.onChange(); | ||
| } | ||
| } | ||
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,5 @@ | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.Counter"> | ||
| <p>Counter: <t t-esc="state.value"/> <button class="btn btn-primary" t-on-click="increment">Increment</button></p> | ||
| </t> | ||
| </templates> |
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 |
|---|---|---|
| @@ -1,5 +1,21 @@ | ||
| import { Component } from "@odoo/owl"; | ||
| import { Component, markup, useState } from "@odoo/owl"; | ||
| import { Counter } from "./counter/counter"; | ||
| import { Card } from "./card/card"; | ||
| import { TodoList } from "./todoList/todoList"; | ||
|
|
||
| export class Playground extends Component { | ||
| static template = "awesome_owl.playground"; | ||
|
|
||
| value2 = markup("<a href='http://odoo.com'>Test</a>"); | ||
|
|
||
| setup() { | ||
| this.total = useState({ value: 0 }); | ||
|
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. Just a minor comment about naming: maybe here I would have used this.state = useState({ total: 0 }); |
||
| } | ||
|
|
||
| incrementSum() { | ||
| console.log("aaa") | ||
| this.total.value++; | ||
| } | ||
|
|
||
| static components = { Counter, Card, TodoList }; | ||
|
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. It gives the same result, but the |
||
| } | ||
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 |
|---|---|---|
| @@ -1,10 +1,13 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="awesome_owl.playground"> | ||
| <div class="p-3"> | ||
| hello world | ||
| hello world <t t-esc="total.value" /> | ||
| </div> | ||
| <Counter onChange.bind="incrementSum" /> | ||
| <Counter onChange.bind="incrementSum" /> | ||
| <Card title="'Card 1'" content="'content of card 1'"/> | ||
| <Card title="'Card 2'" content="value2"/> | ||
| <TodoList /> | ||
| </t> | ||
|
|
||
| </templates> |
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,11 @@ | ||
| import { Component } from "@odoo/owl"; | ||
|
|
||
| export class TodoItem extends Component { | ||
| static template = "awesome_owl.TodoItem"; | ||
|
|
||
| static props = { | ||
| id: Number, | ||
| description: String, | ||
| isCompleted: Boolean | ||
| }; | ||
| } |
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,7 @@ | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.TodoItem"> | ||
| <div t-att-class="{'text-muted text-decoration-line-through': props.isCompleted}"> | ||
| <t t-esc="props.id" />. <t t-esc="props.description" /> | ||
| </div> | ||
| </t> | ||
| </templates> |
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,20 @@ | ||
| import { Component, useState } from "@odoo/owl"; | ||
| import { TodoItem } from "./todoItem/todoItem"; | ||
|
|
||
| export class TodoList extends Component { | ||
| static template = "awesome_owl.TodoList"; | ||
|
|
||
| setup() { | ||
| this.todos = useState([]); | ||
| this.id = 0; | ||
| } | ||
|
|
||
| addTodo(event){ | ||
| if (event.keyCode == 13){ | ||
| console.log(event) | ||
| this.todos.push({id: this.id++, description: event.target.value, isCompleted:false}) | ||
| } | ||
| } | ||
|
|
||
| static components = { TodoItem }; | ||
| } |
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 @@ | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.TodoList"> | ||
| <div class="card d-inline-block m-2" style="width: 18rem;"> | ||
| <div class="card-body"> | ||
| <input placeholder="New Task" t-on-keyup="addTodo" /> | ||
| <t t-foreach="todos" t-as="todo" t-key="todo.id"> | ||
| <p><TodoItem id="todo.id" description="todo.description" isCompleted="todo.isCompleted" /></p> | ||
| </t> | ||
| </div> | ||
| </div> | ||
| </t> | ||
| </templates> |
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 @@ | ||
| from . import models |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is cursed code, that's some very specific syntax and I feel like it would be better to keep it like that as it is more readable? idk, both solutions seems okay.