-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[ADD] estate: create a new module for Real Estate Advertisement #1127
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
anden-odoo
wants to merge
48
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-technical-training-anden
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 all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
1d9543b
[ADD] estate: create a new module for Real Estate Advertisement
anden-odoo 03dde4d
[IMP] estate: add property model
anden-odoo b6e4d06
[IMP] estate: add informations field
anden-odoo b2ac4fa
[CLN] estate: make code more conventional
anden-odoo bfd650f
[IMP] give access rights to base.group_user
anden-odoo 3490325
[IMP] estate: add a 3 levels architecture and an action (Chapter 5)
anden-odoo b330f0e
[IMP] estate: change attributes of some fields
anden-odoo c7b8c7f
[IMP] estate: add new fields and attributes
anden-odoo e97d000
[CLN] estate: clean some indentations and useless lines
anden-odoo f7fb822
[IMP] estate: custom view for list and form (Chapter 6)
anden-odoo 00761e0
[IMP] estate: add search options (chapter 6)
anden-odoo 2b04b99
[IMP] estate: add new module for property type (Chapter 7)
anden-odoo 476383d
[IMP] estate: add salesperson and buyer as field
anden-odoo af15929
[IMP] estate: add tags to property model (Chapter 7)
anden-odoo 39246b2
[IMP] estate: add offer model (Chapter 7)
anden-odoo 4d9b290
[IMP] estate: add total_area and best_offer fields (chapter 8)
anden-odoo 7e72d0a
[IMP] estate: add fields for validity and deadline (Chapter 8)
anden-odoo 94a7e2e
[CLN] estate: clean fields declaration
anden-odoo 71bbdcd
[IMP] estate: add buttons to property form view (Chapter 9)
anden-odoo c72754d
[FIX] estate: solve the computation of the selling price (Chapter 9)
anden-odoo abd4ecb
[IMP] estate: add constraints in property and offer (Chapter 10)
anden-odoo c90db3e
[IMP] estate: add inline list view in type form (Chapter 11)
anden-odoo 6ce2304
[CLN] estate: clean code to respect robodoo recommendations
anden-odoo b9fc1dc
[IMP] estate: add new views and ordering (Chapter 11)
anden-odoo d9e02b1
[IMP] estate: change the state view depending on the offers (chapter 11)
anden-odoo 87989e0
[IMP] estate: add options and color (chapter 11)
anden-odoo 6fed5bd
[IMP] estate: add invisible fields (Chapter 11)
anden-odoo 02774a3
[IMP] estate: add editable list views and optional field (Chapter 11)
anden-odoo e93b659
[IMP] estate: add decorations in some views (Chapter 11)
anden-odoo 88975fc
[IMP] estate: add custom research (Chapter 11)
anden-odoo 728c4b4
[IMP] estate: add stat button for property type (Chapter 11)
anden-odoo 7a27ef5
[IMP] estate: prevent deletion for some property states (Chapter 12)
anden-odoo da2d02d
[IMP] add properties to users form (Chapter 12)
anden-odoo b606da3
[IMP] estate_account: add automatic invoice (Chapter 13)
anden-odoo a74c840
[CLN] estate: clean a white space
anden-odoo 55edb0e
[IMP] estate: add Kanban view to property view (Chapter 14)
anden-odoo 5c46462
[IMP] awesome_owl: add Counter in a sub component (Chapter 1)
anden-odoo 284a46c
[IMP] awesome_owl: add Card component (Chapter 1)
anden-odoo 1709e79
[IMP] awesome_owl: add markup support to card (Chapter 1)
anden-odoo daee9fb
[IMP] awesome_owl: add props validation for Card (Chapter 1)
anden-odoo 1088fe5
[IMP] awesome_owl: add the sum of two Counter (Chapter 1)
anden-odoo 25fe0a4
[IMP] awesome_owl: add todo list with dynamic attributes (Chapter 1)
anden-odoo bb12a55
[IMP] awesome_owl: add input and toggling to the todo list (Chapter 1)
anden-odoo 3a69330
[IMP] awesome_owl: add deletion of todo and generic card (Chapter 1)
anden-odoo 4323feb
[IMP] awesome_dashboard: add dashboard customizations (Chapter 2)
anden-odoo 98eead3
[IMP] awesome_dashboard: make the dashboard generic (Chapter 2)
anden-odoo 3434ed1
[IMP] awesome_dashboard: add dashboard items configuration (Chapter 2)
anden-odoo 90de9ec
[IMP] estate: add demo date (Define module data chapter)
anden-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 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 |
|---|---|---|
|
|
@@ -127,3 +127,6 @@ dmypy.json | |
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
|
|
||
| # Not functionnal | ||
| estate/security/security.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,19 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="awesome_dashboard.configuration_dialog"> | ||
| <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> |
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,92 @@ | ||
| import { Component } from "@odoo/owl"; | ||
| 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 { Dialog } from "@web/core/dialog/dialog"; | ||
| import { DashboardItem } from "./dashboard_item/dashboard_item" | ||
| import { PieChart } from "./pie_chart/pie_chart" | ||
| import { NumberCard } from "./number_card/number_card"; | ||
| import { PieChartCard } from "./pie_chart_card/pie_chart_card"; | ||
| import { browser } from "@web/core/browser/browser"; | ||
| import { CheckBox } from "@web/core/checkbox/checkbox"; | ||
| // import { rpc } from "@web/core/network/rpc"; | ||
|
|
||
|
|
||
| class AwesomeDashboard extends Component { | ||
| static template = "awesome_dashboard.AwesomeDashboard"; | ||
| static components = { Layout, DashboardItem, PieChart, NumberCard, PieChartCard }; | ||
|
|
||
| setup() { | ||
| this.action = useService("action"); | ||
| this.statsService = useService("awesome_dashboard.statistics"); | ||
| onWillStart(async () => { | ||
| this.stats = await this.statsService.loadStatistics(); | ||
| }) | ||
| this.items = registry.category("awesome_dashboard").getAll(); | ||
| this.dialog = useService("dialog"); | ||
| this.state = useState({ | ||
| disabledItems: browser.localStorage.getItem("disabledDashboardItems")?.split(",") || [] | ||
| }); | ||
| } | ||
|
|
||
| openCustomerView(){ | ||
| this.action.doAction("base.action_partner_form"); | ||
| } | ||
|
|
||
| openLeads(){ | ||
| this.action.doAction({ | ||
| type: 'ir.actions.act_window', | ||
| name: 'Journal Entry', | ||
| res_model: 'account.move', | ||
| views: [[false, 'kanban']], | ||
| }); | ||
| } | ||
|
|
||
| openConfiguration() { | ||
| this.dialog.add(ConfigurationDialog, { | ||
| items: this.items, | ||
| disabledItems: this.state.disabledItems, | ||
| onUpdateConfiguration: this.updateConfiguration.bind(this), | ||
| }) | ||
| } | ||
|
|
||
| updateConfiguration(newDisabledItems) { | ||
| this.state.disabledItems = newDisabledItems; | ||
| } | ||
| } | ||
|
|
||
| class ConfigurationDialog extends Component { | ||
| static template = "awesome_dashboard.configuration_dialog"; | ||
| 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("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: gray; /* You can change 'gray' to any color you like */ | ||
| } |
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
13 changes: 13 additions & 0 deletions
13
awesome_dashboard/static/src/dashboard_item/dashboard_item.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,13 @@ | ||
| import { Component, useState } from "@odoo/owl"; | ||
|
|
||
|
|
||
| export class DashboardItem extends Component { | ||
| static template = "awesome_dashboard.dashboard_item"; | ||
| static props = { | ||
| size: {type: Number, optional: true}, | ||
| }; | ||
|
|
||
| static defaultProps = { | ||
| size: 1, | ||
| }; | ||
| } | ||
13 changes: 13 additions & 0 deletions
13
awesome_dashboard/static/src/dashboard_item/dashboard_item.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,13 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="awesome_dashboard.dashboard_item"> | ||
| <div class="card d-inline-block m-2" t-attf-style="width: {{ 18 * props.size }}rem;"> | ||
| <div class="card-body"> | ||
| <!-- Default slot --> | ||
| <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,65 @@ | ||
| import { NumberCard } from "./number_card/number_card"; | ||
| import { PieChartCard } from "./pie_chart_card/pie_chart_card"; | ||
| 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", | ||
| num: 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'", | ||
| num: data.average_time, | ||
| }) | ||
| }, | ||
| { | ||
| id: "number_new_orders", | ||
| description: "New orders this month", | ||
| Component: NumberCard, | ||
| props: (data) => ({ | ||
| title: "Number of new orders this month", | ||
| num: data.nb_new_orders, | ||
| }) | ||
| }, | ||
| { | ||
| id: "cancelled_orders", | ||
| description: "Cancelled orders this month", | ||
| Component: NumberCard, | ||
| props: (data) => ({ | ||
| title: "Number of cancelled orders this month", | ||
| num: 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", | ||
| num: data.total_amount, | ||
| }) | ||
| }, | ||
| { | ||
| id: "pie_chart", | ||
| description: "Shirt orders by size", | ||
| Component: PieChartCard, | ||
| size: 2, | ||
| props: (data) => ({ | ||
| title: "Shirt orders by size", | ||
| nums: data.orders_by_size, | ||
| }) | ||
| } | ||
| ] | ||
|
|
||
| items.forEach(item => { | ||
| registry.category("awesome_dashboard").add(item.id, item); | ||
| }); |
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 } from "@odoo/owl"; | ||
|
|
||
|
|
||
| export class NumberCard extends Component { | ||
| static template = "awesome_dashboard.number_card"; | ||
|
|
||
| static props = { | ||
| title: {type: String,}, | ||
| num: {type: Number,}, | ||
| }; | ||
|
|
||
| } |
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,13 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="awesome_dashboard.number_card"> | ||
| <div> | ||
| <t t-esc="props.title"/> | ||
| </div> | ||
| <div class="fw-bold text-success display-4 mt-2 text-center"> | ||
| <t t-esc="props.num"/> | ||
| </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,34 @@ | ||
| import { loadJS } from "@web/core/assets"; | ||
| import { Component, onWillStart, useRef, onMounted } from "@odoo/owl"; | ||
|
|
||
|
|
||
| export class PieChart extends Component { | ||
| static template = "awesome_owl.pie_chart"; | ||
|
|
||
| static props = { | ||
| orders_by_size: {type: Object, shape: {m:Number, s:Number, xl:Number}}, | ||
| }; | ||
|
|
||
| setup() { | ||
| onWillStart(() => loadJS("/web/static/lib/Chart/Chart.js")); | ||
|
|
||
| this.canvasRef = useRef("canvas"); | ||
|
|
||
| onMounted(() => { | ||
|
|
||
| const labels = Object.keys(this.props.orders_by_size); | ||
| const values = Object.values(this.props.orders_by_size); | ||
|
|
||
| new Chart(this.canvasRef.el, { | ||
| type: "pie", | ||
| data: { | ||
| labels: labels, | ||
| datasets: [{ | ||
| data: values, | ||
| }], | ||
| }, | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| } |
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 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="awesome_owl.pie_chart"> | ||
| <canvas t-ref="canvas"/> | ||
| </t> | ||
| </templates> |
14 changes: 14 additions & 0 deletions
14
awesome_dashboard/static/src/pie_chart_card/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,14 @@ | ||
| import { Component } from "@odoo/owl"; | ||
| import { PieChart } from "../pie_chart/pie_chart" | ||
|
|
||
|
|
||
| export class PieChartCard extends Component { | ||
| static template = "awesome_dashboard.pie_chart_card"; | ||
| static components = { PieChart }; | ||
|
|
||
| static props = { | ||
| title: {type: String,}, | ||
| nums: {type: Object,}, | ||
| }; | ||
|
|
||
| } |
13 changes: 13 additions & 0 deletions
13
awesome_dashboard/static/src/pie_chart_card/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,13 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="awesome_dashboard.pie_chart_card"> | ||
| <div> | ||
| <t t-esc="props.title"/> | ||
| </div> | ||
| <div class="fw-bold text-success display-4 mt-2 text-center"> | ||
| <PieChart orders_by_size="props.nums"></PieChart> | ||
| </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,16 @@ | ||
|
|
||
| import { memoize } from "@web/core/utils/functions"; | ||
| import { registry } from "@web/core/registry"; | ||
| import { rpc } from "@web/core/network/rpc"; | ||
|
|
||
| const statsService = { | ||
| start(env) { | ||
| const loadStatistics = memoize(async () => { | ||
| return await rpc("/awesome_dashboard/statistics"); | ||
| }); | ||
|
|
||
| return {loadStatistics}; | ||
| }, | ||
| }; | ||
|
|
||
| registry.category("services").add("awesome_dashboard.statistics", statsService); |
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"; | ||
|
|
||
|
|
||
| export class Card extends Component { | ||
| static template = "awesome_owl.card"; | ||
|
|
||
| // static props = { | ||
| // title: {type: String,}, | ||
| // content: {type: String,}, | ||
| // }; | ||
|
|
||
| setup(){ | ||
| this.state = useState({ open: true }); | ||
| } | ||
|
|
||
| toggleButton(){ | ||
| this.state.open = ! this.state.open | ||
| } | ||
|
|
||
| } |
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.
Seems like having 2 newlines before a class definition is only a Python thing