-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[ADD] module: add new module real estate (Onboarding) #1238
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
yogietama
wants to merge
3
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-onboarding-yomet
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
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,11 @@ | ||
| import { Component, useState } from "@odoo/owl"; | ||
|
|
||
| export class Card extends Component { | ||
| static template = "awesome_owl.card"; | ||
|
|
||
| static props = { | ||
| title: String, | ||
| content : { type: String, optional: true }, | ||
| slots: { type: Object, optional: true }, | ||
| }; | ||
| } |
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 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.card" owl="1"> | ||
| <div class="card d-inline-block m-2" style="width: 18rem;"> | ||
| <div class="card-body"> | ||
| <h5 class="card-title"> | ||
| <t t-esc="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,20 @@ | ||
| 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:1 }) | ||
| } | ||
|
|
||
| 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,11 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.counter" owl="1"> | ||
| <div class="counter-container p-3 border m-2"> | ||
| <p>Counter Value: <t t-esc="state.value"/></p> | ||
| <button class="btn btn-primary" t-on-click="increment"> | ||
| increment | ||
| </button> | ||
| </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,12 @@ | ||
| import { Component } from "@odoo/owl"; | ||
|
|
||
| export class TodoItem extends Component { | ||
| static template = "awesome_owl.TodoItem"; | ||
|
|
||
| static props = { | ||
| todo: { | ||
| type: Object, | ||
| shape: { 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,9 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.TodoItem" owl="1"> | ||
| <div class="todo-item p-2 border-bottom" | ||
| t-att-class="props.todo.isCompleted ? 'text-muted text-decoration-line-through' : ''"> | ||
| <t t-esc="props.todo.id"/>. <t t-esc="props.todo.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,38 @@ | ||
| import { Component, useState, onMounted, useRef} from "@odoo/owl" | ||
| import { TodoItem } from "./todo_item"; | ||
|
|
||
| export class TodoList extends Component { | ||
| static template = "awesome_owl.todo_list" | ||
| static components = { TodoItem }; | ||
|
|
||
| setup() { | ||
| // in TodoList | ||
| this.todos = useState([ | ||
| // { id: 2, description: "write tutorial", isCompleted: true }, | ||
| // { id: 3, description: "buy milk", isCompleted: false }, | ||
| ]); | ||
| this.nextId = 1; | ||
|
|
||
| this.inputRef = useRef("todo-input"); | ||
|
|
||
| onMounted(() => { | ||
| this.inputRef.el.focus(); | ||
| }) | ||
| } | ||
|
|
||
| addTodo(ev) { | ||
| if (ev.keyCode == 13) { | ||
| const description = ev.target.value.trim(); | ||
|
|
||
| if (description !== "") { | ||
| this.todos.push({ | ||
| id:this.nextId++, | ||
| description: description, | ||
| isCompleted: false, | ||
| }); | ||
|
|
||
| ev.target.value = ""; | ||
| } | ||
| } | ||
| } | ||
| } |
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_owl.todo_list" owl="1"> | ||
| <div class="todo-list p-3 shadow-sm bg-white rounded"> | ||
| <h3 class="mb-3">My Tasks</h3> | ||
|
|
||
| <div class="mb-3"> | ||
| <input type="text" | ||
| class="form-control" | ||
| placeholder="Enter a new task" | ||
| t-on-keyup="addTodo" | ||
| t-ref="todo-input"/> | ||
| </div> | ||
|
|
||
| <div class="list-group"> | ||
| <t t-foreach="todos" t-as="todo" t-key="todo.id"> | ||
| <TodoItem todo="todo"/> | ||
| </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 |
|---|---|---|
| @@ -1,5 +1,21 @@ | ||
| import { Component } from "@odoo/owl"; | ||
| import { Component, useState, markup } from "@odoo/owl"; | ||
| import { Counter } from "./components/counter/counter" | ||
| import { Card } from "./components/card/card"; | ||
| import { TodoList } from "./components/todo/todo_list"; | ||
|
|
||
| export class Playground extends Component { | ||
| static template = "awesome_owl.playground"; | ||
|
|
||
| static components = { Counter, Card, TodoList }; | ||
|
|
||
| setup() { | ||
| this.html = markup("<div class='text-primary'>some content</div>"); | ||
|
|
||
| this.state = useState({sum: 2}) | ||
| this.incrementSum = this.incrementSum.bind(this); | ||
| } | ||
|
|
||
| incrementSum(){ | ||
| this.state.sum++; | ||
| } | ||
| } |
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
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 |
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,28 @@ | ||
| # Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
|
||
| { | ||
| 'name': 'Real Estate', | ||
| 'version': '19.0.0.1.0', | ||
| 'category': 'Real Estate/Properties', | ||
| 'sequence': 15, | ||
| 'summary': 'Track leads and close opportunities', | ||
| 'website': 'https://www.odoo.com/app/estate', | ||
| 'depends': [ | ||
| 'base', | ||
| ], | ||
| 'data': [ | ||
| 'security/ir.model.access.csv', | ||
| 'views/estate_property_type_views.xml', | ||
| 'views/estate_property_tags_views.xml', | ||
| 'views/estate_property_users_views.xml', | ||
| 'views/estate_property_offers_views.xml', | ||
| 'views/estate_property_views.xml', | ||
| 'views/estate_property_menu.xml', | ||
| ], | ||
| 'demo': [], | ||
| 'installable': True, | ||
| 'application': True, | ||
| 'assets': {}, | ||
| 'author': 'Odoo S.A.', | ||
| 'license': 'LGPL-3', | ||
| } |
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 @@ | ||
| from . import estate_property | ||
| from . import estate_propery_type | ||
| from . import estate_propery_tag | ||
| from . import estate_propery_offer | ||
| from . import res_users |
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,112 @@ | ||
| from odoo import fields, models, api | ||
| from odoo.exceptions import UserError, ValidationError | ||
| from odoo.tools.float_utils import float_compare, float_is_zero | ||
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = "estate.property" | ||
| _description = "Real Estate Property" | ||
| _order = "id desc" | ||
|
|
||
| name = fields.Char(required=True) | ||
| description = fields.Text() | ||
| postcode = fields.Char() | ||
| date_avaibility = fields.Date(string="Date Avaibility") | ||
| expected_price = fields.Float() | ||
| selling_price = fields.Float() | ||
| bedrooms = fields.Integer() | ||
| living_area = fields.Integer() | ||
| facades = fields.Integer() | ||
| garage = fields.Boolean() | ||
| garden = fields.Boolean() | ||
| garden_area = fields.Integer() | ||
| garden_orientation = fields.Selection( | ||
| selection=[ | ||
| ("north", "North"), | ||
| ("south", "South"), | ||
| ("east", "East"), | ||
| ("west", "West") | ||
| ], | ||
| ) | ||
| active = fields.Boolean(default=True) | ||
| state = fields.Selection( | ||
| selection=[ | ||
| ("new", "New"), | ||
| ("offer received", "Offer Received"), | ||
| ("offer accepted", "Offer Accepted"), | ||
| ("sold", "Sold"), | ||
| ("cancelled", "Cancelled") | ||
| ], | ||
| default="new" | ||
| ) | ||
|
|
||
| partner_id = fields.Many2one("res.partner", string="Partner") | ||
| user_id = fields.Many2one("res.users", string="Users") | ||
| property_type_id = fields.Many2one("estate.property.type", | ||
| string="PropType") | ||
| property_tag_ids = fields.Many2many("estate.property.tag", string="Tags") | ||
| offer_ids = fields.One2many( | ||
| "estate.property.offer", "property_id", string="offers") | ||
| total_area = fields.Float(compute="_compute_total") | ||
| best_price = fields.Float(compute="_compute_best_price") | ||
|
|
||
| # define constrain | ||
| _check_expected_price = models.Constraint( | ||
| 'CHECK(expected_price > 0)', | ||
| 'The expected price must be strictly positive', | ||
| ) | ||
|
|
||
| @api.depends("living_area", "garden_area") | ||
| def _compute_total(self): | ||
| for record in self: | ||
| record.total_area = record.living_area + record.garden_area | ||
|
|
||
| @api.depends("offer_ids.price", "expected_price") | ||
| def _compute_best_price(self): | ||
| for record in self: | ||
| if record.offer_ids: | ||
| record.best_price = max(record.offer_ids.mapped("price")) | ||
| else: | ||
| record.best_price = 0 | ||
|
|
||
| @api.onchange("garden") | ||
| def _onchange_garden(self): | ||
| for record in self: | ||
| if record.garden: | ||
| record.garden_area = 10 | ||
| record.garden_orientation = "north" | ||
| else: | ||
| record.garden_area = 0 | ||
| record.garden_orientation = "" | ||
|
|
||
| @api.constrains("expected_price", "selling_price") | ||
| def _check_price_offer(self): | ||
| for record in self: | ||
| if record.selling_price > 0: | ||
| if float_is_zero(record.selling_price, precision_rounding=2): | ||
| continue | ||
| min_price = 0.9 * record.expected_price | ||
| # if offer percentage lower then 90% | ||
| if float_compare(record.selling_price, min_price, precision_digits=2) == -1: | ||
| raise ValidationError( | ||
| "The selling price cannot be lower than 90% of the expected price\n" | ||
| "You must reduce the expected price if you want to accept this offer" | ||
| ) | ||
|
|
||
| def action_sold(self): | ||
| for record in self: | ||
| if record.state == "cancelled": | ||
| raise UserError("Cancelled properties cannot be sold") | ||
| record.state = "sold" | ||
|
|
||
| def action_cancel(self): | ||
| for record in self: | ||
| if record.state == "sold": | ||
| raise UserError("Sold properties cannot be cancelled") | ||
| record.state = "cancelled" | ||
|
|
||
| @api.ondelete(at_uninstall=False) | ||
| def _unlink_if_new_or_canceled(self): | ||
| for record in self: | ||
| if record.state not in ['new', 'cancelled']: | ||
| raise UserError("You can only delete new or canceled properties.") | ||
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.