-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[ADD] estate: initialize estate module #1333
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
vrushibh
wants to merge
8
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-tutorials-vrbha
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.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b1adea6
[ADD] estate: initialize estate module
vrushibh 8594029
[ADD] estate: add estate.property model and basic fields
vrushibh 10c70a5
[ADD] estate: add security access rules for estate.property
vrushibh 8fb2322
[ADD] estate: add basic views, action and menus
vrushibh 67d44d9
[IMP] estate: add tag and offer models with relations
vrushibh e65e22a
[FIX] estate: address TL review feedback and add demo data
vrushibh ee21cac
[IMP] estate: automate fields and views
vrushibh 4890895
[FIX] estate: add description in property tag demo data
vrushibh 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 @@ | ||
| 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,18 @@ | ||
| { | ||
| "name": "Real Estate", | ||
| "author": "Odoo S.A.", | ||
| "license": "LGPL-3", | ||
| "depends": ["base"], | ||
| "data": [ | ||
| "security/estate_security.xml", | ||
| "security/ir.model.access.csv", | ||
| "views/estate_property_views.xml", | ||
| "views/estate_property_type_views.xml", | ||
| "views/estate_property_tag_views.xml", | ||
| "views/estate_property_offer_views.xml", | ||
| "views/estate_menus.xml", | ||
| "data/estate_demo.xml", | ||
| ], | ||
| "application": True, | ||
| "installable": 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,72 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
|
|
||
| <record id="estate_property_type_residential" model="estate.property.type"> | ||
| <field name="name">Residential</field> | ||
| </record> | ||
| <record id="estate_property_type_commercial" model="estate.property.type"> | ||
| <field name="name">commercial</field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_tag_cozy" model="estate.property.tag"> | ||
| <field name="name">Cozy</field> | ||
| <field name="description">Cozy property tag</field> | ||
| </record> | ||
| <record id="estate_property_tag_cool" model="estate.property.tag"> | ||
| <field name="name">Cool</field> | ||
| <field name="description">Cool property tag</field> | ||
| </record> | ||
| <record id="estate_property_tag_nice" model="estate.property.tag"> | ||
| <field name="name">Nice</field> | ||
| <field name="description">Nice property tag</field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_demo_1" model="estate.property"> | ||
| <field name="name">vrushibh Apartment</field> | ||
| <field name="expected_price">75000.00</field> | ||
| <field name="bedrooms">4</field> | ||
| <field name="living_area">250</field> | ||
| <field name="postcode">35000</field> | ||
| <field name="date_availability">2026-09-15</field> | ||
| <field name="property_type_id" ref="estate_property_type_residential"/> | ||
| <field name="tag_ids" eval="[(6, 0, [ref('estate_property_tag_cool'), ref('estate_property_tag_nice')])]"/> | ||
| </record> | ||
|
|
||
| <record id="estate_property_demo_2" model="estate.property"> | ||
| <field name="name">Cozy Apartment</field> | ||
| <field name="expected_price">200000.00</field> | ||
| <field name="bedrooms">2</field> | ||
| <field name="living_area">85</field> | ||
| <field name="postcode">380001</field> | ||
| <field name="property_type_id" ref="estate_property_type_commercial"/> | ||
| <field name="tag_ids" eval="[(6, 0, [ref('estate_property_tag_cool'), ref('estate_property_tag_nice')])]"/> | ||
| </record> | ||
|
|
||
| <record id="estate_property_demo_3" model="estate.property"> | ||
| <field name="name">nice Apartment</field> | ||
| <field name="expected_price">206000.00</field> | ||
| <field name="bedrooms">2</field> | ||
| <field name="living_area">85</field> | ||
| <field name="postcode">380001</field> | ||
| <field name="property_type_id" ref="estate_property_type_commercial"/> | ||
| </record> | ||
|
|
||
| <record id="estate_property_demo_4" model="estate.property"> | ||
| <field name="name">cool Apartment</field> | ||
| <field name="expected_price">206000.00</field> | ||
| <field name="bedrooms">2</field> | ||
| <field name="living_area">85</field> | ||
| <field name="postcode">380001</field> | ||
| <field name="property_type_id" ref="estate_property_type_commercial"/> | ||
| </record> | ||
|
|
||
| <record id="estate_property_demo_5" model="estate.property"> | ||
| <field name="name">jumbo Apartment</field> | ||
| <field name="expected_price">206000.00</field> | ||
| <field name="bedrooms">2</field> | ||
| <field name="living_area">85</field> | ||
| <field name="postcode">380001</field> | ||
| <field name="property_type_id" ref="estate_property_type_commercial"/> | ||
| </record> | ||
|
|
||
| </odoo> |
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,4 @@ | ||
| from . import estate_property | ||
| from . import estate_property_tag | ||
| from . import estate_property_type | ||
| from . import estate_property_offer |
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,99 @@ | ||
| from dateutil.relativedelta import relativedelta | ||
|
|
||
| from odoo import api, fields, models | ||
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = "estate.property" | ||
| _description = "Real Estate Property" | ||
|
|
||
| name = fields.Char(required=True, string="Property Name") | ||
| description = fields.Text() | ||
| postcode = fields.Char() | ||
| date_availability = fields.Date( | ||
| default=lambda self: fields.Date.context_today(self) + relativedelta(months=3), | ||
| ) | ||
| expected_price = fields.Float(required=True, copy=False, default=0.0) | ||
| selling_price = fields.Float(readonly=True, copy=False) | ||
| bedrooms = fields.Integer(default=2) | ||
| 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"), | ||
| ], | ||
|
vrushibh marked this conversation as resolved.
|
||
| string="Garden Orientation", | ||
| ) | ||
| active = fields.Boolean(default=True) | ||
| state = fields.Selection( | ||
| selection=[ | ||
| ('new', "New"), | ||
| ('offer_received', "Offer Received"), | ||
| ('offer_accepted', "Offer Accepted"), | ||
| ('sold', "Sold"), | ||
| ('cancelled', "Cancelled"), | ||
| ], | ||
| required=True, | ||
| copy=False, | ||
| default="new", | ||
| string="State", | ||
| ) | ||
| property_type_id = fields.Many2one("estate.property.type", string="Property Type") | ||
| buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False) | ||
| salesperson_id = fields.Many2one( | ||
| "res.users", | ||
| string="Salesperson", | ||
| default=lambda self: self.env.user, | ||
| ) | ||
| tag_ids = fields.Many2many("estate.property.tag", string="Property Tags") | ||
| offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers") | ||
|
|
||
| total_area = fields.Integer( | ||
| string="Total Area (sqm)", | ||
| compute="_compute_total_area", | ||
| help="Total area of the property (living area + garden area)", | ||
| ) | ||
| best_price = fields.Float( | ||
| string="Best Offer", | ||
| compute="_compute_best_price", | ||
| help="The highest offer received for this property", | ||
| store="true", | ||
| ) | ||
| squre_area = fields.Integer( | ||
| string="Squre Area", | ||
| compute="_compute_total_squre", | ||
| ) | ||
|
|
||
| @api.depends("living_area", "garden_area") | ||
| def _compute_total_area(self): | ||
| for record in self: | ||
| record.total_area = record.living_area + record.garden_area | ||
|
|
||
| @api.depends("total_area") | ||
| def _compute_total_squre(self): | ||
| for record in self: | ||
| record.squre_area = record.total_area * record.total_area | ||
|
|
||
| @api.depends("offer_ids.price") | ||
| def _compute_best_price(self): | ||
| for record in self: | ||
| prices = record.offer_ids.mapped("price") | ||
| if prices: | ||
| record.best_price = max(prices) | ||
| else: | ||
| record.best_price = 0.0 | ||
|
|
||
| @api.onchange("garden") | ||
| def _onchange_garden(self): | ||
| if self.garden: | ||
| self.garden_area = 10 | ||
| self.garden_orientation = "north" | ||
| else: | ||
| self.garden_area = 0 | ||
| self.garden_orientation = False | ||
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,48 @@ | ||
| from datetime import timedelta | ||
|
|
||
| from odoo import api, fields, models | ||
|
|
||
|
|
||
| class EstatePropertyOffer(models.Model): | ||
| _name = "estate.property.offer" | ||
| _description = "Real Estate Property Offer" | ||
|
|
||
| price = fields.Float(required=True) | ||
| status = fields.Selection( | ||
| selection=[ | ||
| ('accepted', 'Accepted'), | ||
| ('rejected', 'Rejected'), | ||
| ], | ||
| copy=False, | ||
| string="Status", | ||
| ) | ||
| partner_id = fields.Many2one("res.partner", string="Partner", required=True) | ||
| property_id = fields.Many2one("estate.property", string="Property", required=True) | ||
| validity = fields.Integer(string="Validity", default=7) | ||
| date_deadline = fields.Date( | ||
| string="Deadline", | ||
| compute="_compute_date_deadline", | ||
| inverse="_inverse_date_deadline", | ||
| ) | ||
|
|
||
| @api.depends("create_date", "validity") | ||
| def _compute_date_deadline(self): | ||
| for record in self: | ||
| if record.create_date: | ||
| create_date = record.create_date.date() | ||
| else: | ||
| create_date = fields.Date.today() | ||
| record.date_deadline = create_date + timedelta(days=record.validity) | ||
|
|
||
| def _inverse_date_deadline(self): | ||
| for record in self: | ||
| if record.create_date: | ||
| create_date = record.create_date.date() | ||
| else: | ||
| create_date = fields.Date.today() | ||
| if record.date_deadline: | ||
| record.validity = (record.date_deadline - create_date).days | ||
|
|
||
| @api.onchange("date_deadline") | ||
| def _onchange_date_deadline(self): | ||
| self._inverse_date_deadline() |
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 @@ | ||
| from random import randint | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class EstatePropertyTag(models.Model): | ||
| _name = "estate.property.tag" | ||
| _description = "Real Estate Property Tag" | ||
| _rec_name = 'name' | ||
|
|
||
| def _default_color(self): | ||
| return randint(1, 11) | ||
|
|
||
| name = fields.Char(required=True) | ||
| description = fields.Char(required=True) | ||
| color = fields.Integer( | ||
| string='Color Index', | ||
| default=lambda self: self._default_color(), | ||
| ) |
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,17 @@ | ||
| from odoo import api, fields, models | ||
|
|
||
|
|
||
| class EstatePropertyType(models.Model): | ||
| _name = "estate.property.type" | ||
| _description = "Real Estate Property Type" | ||
| _rec_names_search = ["name", "code"] | ||
|
|
||
| name = fields.Char(required=True, string="Property Type") | ||
| code = fields.Char(string="Code") | ||
|
|
||
| @api.depends("name", "code") | ||
| def _compute_display_name(self): | ||
| for record in self: | ||
| record.display_name = ( | ||
| f"{record.name} [{record.code}]" if record.code else record.name | ||
| ) |
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,27 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
|
|
||
| <record id="module_category_real_estate" model="ir.module.category"> | ||
| <field name="name">Real Estate</field> | ||
| <field name="sequence">10</field> | ||
| </record> | ||
|
|
||
| <record id="res_groups_privilege_estate" model="res.groups.privilege"> | ||
| <field name="name">Access Level</field> | ||
| <field name="category_id" ref="module_category_real_estate"/> | ||
| </record> | ||
|
|
||
| <record id="estate_group_agent" model="res.groups"> | ||
| <field name="name">Agent</field> | ||
| <field name="privilege_id" ref="res_groups_privilege_estate"/> | ||
| <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/> | ||
| </record> | ||
|
|
||
| <record id="estate_group_manager" model="res.groups"> | ||
| <field name="name">Manager</field> | ||
| <field name="privilege_id" ref="res_groups_privilege_estate"/> | ||
| <field name="implied_ids" eval="[(4, ref('estate_group_agent'))]"/> | ||
| <field name="user_ids" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/> | ||
| </record> | ||
|
|
||
| </odoo> |
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 @@ | ||
| id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink | ||
| access_estate_property_agent,access_estate_property_agent,model_estate_property,estate_group_agent,1,1,1,0 | ||
| access_estate_property_manager,access_estate_property_manager,model_estate_property,estate_group_manager,1,1,1,1 | ||
| access_estate_property_type_agent,access_estate_property_type_agent,model_estate_property_type,estate_group_agent,1,1,1,1 | ||
| access_estate_property_type_manager,access_estate_property_type_manager,model_estate_property_type,estate_group_manager,1,1,1,1 | ||
| access_estate_property_tag_agent,access_estate_property_tag_agent,model_estate_property_tag,estate_group_agent,1,1,1,1 | ||
| access_estate_property_tag_manager,access_estate_property_tag_manager,model_estate_property_tag,estate_group_manager,1,1,1,1 | ||
| access_estate_property_offer_agent,access_estate_property_offer_agent,model_estate_property_offer,estate_group_agent,1,1,1,1 | ||
| access_estate_property_offer_manager,access_estate_property_offer_manager,model_estate_property_offer,estate_group_manager,1,1,1,1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,49 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
|
|
||
| <menuitem | ||
| id="estate_menu_root" | ||
| name="Real Estate" | ||
| sequence="10" | ||
| web_icon="estate,static/description/icon.png"/> | ||
|
|
||
| <menuitem | ||
| id="estate_property_menu_advertisements" | ||
| name="Advertisements" | ||
| parent="estate_menu_root" | ||
| sequence="10"/> | ||
|
|
||
| <menuitem | ||
| id="estate_property_menu" | ||
| name="Properties" | ||
| parent="estate_property_menu_advertisements" | ||
| action="estate_property_action" | ||
| sequence="10"/> | ||
|
|
||
| <menuitem | ||
| id="estate_property_menu_settings" | ||
| name="Settings" | ||
| parent="estate_menu_root" | ||
| sequence="20"/> | ||
|
|
||
| <menuitem | ||
| id="estate_property_type_menu" | ||
| name="Property Types" | ||
| parent="estate_property_menu_settings" | ||
| action="estate_property_type_action" | ||
| sequence="10"/> | ||
|
|
||
| <menuitem | ||
| id="estate_property_offers_menu" | ||
| name="Offers Type" | ||
| parent ="estate_property_menu_settings" | ||
| action="estate_property_offers_action" | ||
| /> | ||
| <menuitem | ||
| id="estate_property_tag_menu" | ||
| name="Tag Types" | ||
| parent ="estate_property_menu_settings" | ||
| action="estate_property_tag_action" | ||
| /> | ||
|
|
||
| </odoo> |
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.
What if we don't write
basehere?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.
If we don't write base, Odoo will still load it automatically. However, writing it explicitly is a best practice to make the module dependency clear.