-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[ADD] real_estate: added real_estate module #1227
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
Arbaaz-Khan-Tech
wants to merge
15
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-tutorials-asurk
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
15 commits
Select commit
Hold shift + click to select a range
8de6abe
[ADD] real_estate: added real_estate module
Arbaaz-Khan-Tech 5775c43
[ADD] real_estate: Add required fields for property details
Arbaaz-Khan-Tech 8dad73a
[ADD] real_estate: add access rights for users
Arbaaz-Khan-Tech fe97ac7
[ADD] real_estate: Add UI views for estate model display
Arbaaz-Khan-Tech 7e244b4
[ADD] real_estate: Add property status, dashboard logo, and refactor
Arbaaz-Khan-Tech 847c363
[FIX] real_estate: Prevent build failures
Arbaaz-Khan-Tech 8890262
[IMP] real_estate: refine property model field data types
Arbaaz-Khan-Tech 192d855
[IMP] real_estate: refine data type for garden_area
Arbaaz-Khan-Tech d5a2a5f
[IMP] real_estate: Add custom form view and list view groupby filter
Arbaaz-Khan-Tech f575f20
[ADD] real_estate: Add property type model and buyer/seller fields
Arbaaz-Khan-Tech 185c842
[ADD] real_estate: Added Property Tags and Property Offer Models
Arbaaz-Khan-Tech ae4963f
[IMP] real_estate: Fix styling issues causing runbot warnings
Arbaaz-Khan-Tech 5080f93
[IMP] real_estate: Add Computed Field and UX Enhancements
Arbaaz-Khan-Tech 388fe31
[IMP] real_estate: Add buttons to manage property and offer status
Arbaaz-Khan-Tech 61a4b99
[IMP] real_estate: Address E712 boolean comparison linting
Arbaaz-Khan-Tech 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,4 @@ dmypy.json | |
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
| .vscode/settings.json | ||
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,23 @@ | ||
| { | ||
| 'name': "Estate", | ||
| 'version': '1.0', | ||
| 'depends': ['base'], | ||
| 'author': "Asurk", | ||
| 'category': 'Real Estate/Brokerage', | ||
| 'description': """ | ||
| A module so that customers can bid on real estates | ||
| """, | ||
| 'data': [ | ||
| 'security/ir.model.access.csv', | ||
| 'views/estate_property_views.xml', | ||
| 'views/estate_property_type_views.xml', | ||
| 'views/estate_property_tags_views.xml', | ||
| 'views/estate_property_offer_views.xml', | ||
| 'views/estate_menus.xml' | ||
| ], | ||
| 'license': 'LGPL-3', # Default License | ||
| 'application': True, | ||
| 'installable': True, | ||
| # data files always loaded at installation | ||
|
|
||
| } | ||
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 estate_property, estate_property_type, estate_property_tag, 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,100 @@ | ||
| from odoo import fields, models, api | ||
| from odoo.exceptions import UserError, ValidationError | ||
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
|
|
||
| _name = 'estate.property' | ||
| _description = "A real estate model with many fields" | ||
| active = fields.Boolean(string="Active", default="Active") | ||
| bedrooms = fields.Integer(string="Bedrooms", default="2") | ||
| best_price = fields.Float( | ||
| string="Best Price", compute='_compute_best_price') | ||
| buyer = fields.Many2one( | ||
| 'res.partner', string="Buyer", ondelete='restrict', | ||
| ) | ||
| date_availability = fields.Datetime( | ||
| string="Available From", copy=False, default=lambda self: fields.Date.add(fields.Date.context_today(self), months=3)) | ||
| description = fields.Text(string="Description") | ||
| expected_price = fields.Float(string="Expected Price", required=True) | ||
| facades = fields.Integer(string="Facades") | ||
| garden = fields.Boolean(string="Garden") | ||
| garden_area = fields.Float(string="Garden Area (sqm)") | ||
| garden_orientation = fields.Selection( | ||
| string="Direction", | ||
| selection=[ | ||
| ('north', "North"), | ||
| ('south', "South"), | ||
| ('east', "East"), | ||
| ('west', "West") | ||
| ], | ||
| help="Type is used to specify the garden orientation" | ||
| ) | ||
| garage = fields.Boolean(string="Garage") | ||
| living_area = fields.Float(string="Living Area (sqm)") | ||
| name = fields.Char(string="Title", required=True) | ||
| offer_ids = fields.One2many( | ||
| 'estate.property.offer', 'property_id', string='Offers') | ||
| postcode = fields.Char(string="Postcode") | ||
| property_type_id = fields.Many2one( | ||
| 'estate.property.type', string="Property Type") | ||
| salesman = fields.Many2one( | ||
| 'res.users', string="Salesman", ondelete='restrict', | ||
| ) | ||
| selling_price = fields.Float( | ||
| string="Selling Price", readonly=True, copy=False) | ||
| state = fields.Selection([('new', "New"), | ||
| ('offer_received', "Offer Received"), | ||
| ('offer_accepted', "Offer Accepted"), | ||
| ('sold', "Sold"), | ||
| ('cancelled', "Cancelled") | ||
| ], | ||
| default='new') | ||
| tag_ids = fields.Many2many( | ||
| 'estate.property.tag', | ||
| string="Tags" | ||
| ) | ||
| total_area = fields.Float( | ||
| string="Total Area", compute='_compute_total_area' | ||
| ) | ||
|
|
||
| @api.depends('living_area', 'garden_area') | ||
| def _compute_total_area(self): | ||
| for rec in self: | ||
| rec.total_area = rec.living_area + rec.garden_area | ||
|
|
||
| @api.depends('offer_ids.price') | ||
| def _compute_best_price(self): | ||
| for rec in self: | ||
| rec.best_price = max(rec.mapped('offer_ids.price') or [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 | ||
|
|
||
| @api.constrains('expected_price') | ||
| def _check_price(self): | ||
| for rec in self: | ||
| if rec.expected_price <= 0: | ||
| raise ValidationError("Price must be positive") # Shown in UI | ||
|
|
||
| def action_property_sold(self): | ||
| for rec in self: | ||
| if rec.state == 'cancelled': | ||
| raise UserError('A cancelled property cannot be sold') | ||
| else: | ||
| rec.state = 'sold' | ||
| return True | ||
|
|
||
| def action_property_cancelled(self): | ||
| for rec in self: | ||
| if rec.state == 'sold': | ||
| raise UserError('A sold property cannot be cancelled') | ||
| else: | ||
| rec.state = 'cancelled' | ||
| return 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,53 @@ | ||
| from odoo import api, fields, models | ||
| from odoo.exceptions import UserError | ||
|
|
||
|
|
||
| class EstatePropertyOffer(models.Model): | ||
|
|
||
| _name = 'estate.property.offer' | ||
| _description = "A model where offer for the properties are stored" | ||
|
|
||
| price = fields.Float(required=True) | ||
| status = fields.Selection(selection=[('accepted', "Accepted"), | ||
| ('refused', "Refused")]) | ||
| partner_id = fields.Many2one('res.partner', required=True) | ||
| property_id = fields.Many2one( | ||
| 'estate.property', required=True) | ||
| validity = fields.Integer(string="Validity", default='7') | ||
| date_deadline = fields.Datetime( | ||
| string="Deadline", compute='_compute_date_deadline', inverse='_inverse_date_deadline') | ||
|
|
||
| @api.depends('validity', 'create_date') | ||
| def _compute_date_deadline(self): | ||
| for rec in self: | ||
| create_date = rec.create_date or fields.Date.context_today(self) | ||
| rec.date_deadline = fields.Date.add(create_date, days=rec.validity) | ||
|
|
||
| def _inverse_date_deadline(self): | ||
| for rec in self: | ||
| create_date = rec.create_date or fields.Date.context_today(self) | ||
| rec.validity = (rec.date_deadline - create_date).days | ||
|
|
||
| def action_status_accepted(self): | ||
| for rec in self: | ||
| if rec.status == 'accepted': | ||
| raise UserError("Offer has already been accepted") | ||
| rec.status = 'accepted' | ||
|
|
||
| rec.property_id.write({ | ||
| 'buyer': rec.partner_id.id, | ||
| 'selling_price': rec.price, | ||
| }) | ||
|
|
||
| return True | ||
|
|
||
| def action_status_refused(self): | ||
| for rec in self: | ||
| if rec.status == 'refused': | ||
| raise UserError("Offer has already been refused") | ||
| rec.status = 'refused' | ||
| rec.property_id.write({ | ||
| 'buyer': False, | ||
| 'selling_price': False, | ||
| }) | ||
| return 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,10 @@ | ||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class EstatePropertyTag(models.Model): | ||
|
|
||
| _name = "estate.property.tag" | ||
| _description = "Tags for properties" | ||
|
|
||
| name = fields.Char(string="Tags") | ||
| color = fields.Integer(string="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,11 @@ | ||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class EstatePropertyType(models.Model): | ||
|
|
||
| _name = 'estate.property.type' | ||
| _description = "A model where property types are defined" | ||
|
|
||
| name = fields.Char(required=True, string="Property Type") | ||
| property_ids = fields.One2many( | ||
| 'estate.property', inverse_name='property_type_id', string="Properties") |
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 @@ | ||
| id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
| estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1 | ||
| estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1 | ||
| estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1 | ||
| estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,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,17 @@ | ||
| <?xml version="1.0"?> | ||
| <odoo> | ||
|
|
||
| <menuitem id="real_estate_root" name="Real Estate" web_icon="estate,static/description/Real_Estate_Logo.jpg"/> | ||
|
|
||
| <menuitem id="real_estate_properties_menu" name="Advertisements" parent="real_estate_root"/> | ||
| <menuitem id="real_estate_properties_settings_menu" name="Settings" parent="real_estate_root"/> | ||
|
|
||
| <menuitem id="real_estate_menu_action" name="All Properties " parent="real_estate_properties_menu" | ||
| action="test_property_action"/> | ||
| <menuitem id="real_estate_property_type_action" name="Property Types" parent="real_estate_properties_settings_menu" | ||
| action="test_property_type_action"/> | ||
| <menuitem id="real_estate_property_tags_action" name="Property Tags" parent="real_estate_properties_settings_menu" | ||
| action="test_property_tags_action"/> | ||
|
|
||
|
|
||
| </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,51 @@ | ||
| <?xml version="1.0"?> | ||
| <odoo> | ||
|
|
||
|
|
||
| <!--_________________________________________ WINDOW ACTION _________________________________________--> | ||
|
|
||
| <record id="test_property_offer_action" model="ir.actions.act_window"> | ||
| <field name="name">Property Offers</field> | ||
| <field name="res_model">estate.property.offer</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
|
|
||
|
|
||
| <!--_________________________________________ LIST VIEW _________________________________________--> | ||
| <record id="estate_property_offer_view_list" model="ir.ui.view"> | ||
| <field name="name">estate.property.offer.list</field> | ||
| <field name="model">estate.property.offer</field> | ||
|
|
||
| <field name="arch" type="xml"> | ||
| <list string=""> | ||
| <field name="price"/> | ||
| <field name="partner_id"/> | ||
| <field name="validity"/> | ||
| <field name="date_deadline" widget="datetime"/> | ||
| <button name="action_status_accepted" string="Accept" type="object" class="btn-primary"/> | ||
| <button name="action_status_refused" string="Refuse" type="object" class="btn-secondary"/> | ||
| <field name="status" /> | ||
| </list> | ||
| </field> | ||
| </record> | ||
| <!--_________________________________________ FORM VIEW _________________________________________--> | ||
|
|
||
| <record id="estate_property_tags_view_form" model="ir.ui.view"> | ||
| <field name="name">estate.property.offer.form</field> | ||
| <field name="model">estate.property.offer</field> | ||
| <field name="arch" type="xml"> | ||
| <form string=""> | ||
| <sheet> | ||
| <group> | ||
| <field name="price" widget=""/> | ||
| <field name="partner_id" widget="many2one_avatar_user"/> | ||
| <field name="validity"/> | ||
| <field name="date_deadline" widget="datetime"/> | ||
| <field name="status" widget="radio"/> | ||
| </group> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </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,60 @@ | ||
| <?xml version="1.0"?> | ||
| <odoo> | ||
|
|
||
|
|
||
| <!--_________________________________________ WINDOW ACTION _________________________________________--> | ||
|
|
||
| <record id="test_property_tags_action" model="ir.actions.act_window"> | ||
| <field name="name">Property Types</field> | ||
| <field name="res_model">estate.property.tag</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
|
|
||
| <!--_________________________________________ LIST ACTION _________________________________________--> | ||
|
|
||
|
|
||
| <record id="estate_property_tags_view_list" model="ir.ui.view"> | ||
| <field name="name">estate.property.tag.list</field> | ||
| <field name="model">estate.property.tag</field> | ||
|
|
||
| <field name="arch" type="xml"> | ||
| <list string=""> | ||
|
|
||
|
|
||
| <field name="name" default_focus="1" class="oe_inline"/> | ||
|
|
||
| <field name="color" widget="color_picker"/> | ||
|
|
||
|
|
||
| </list> | ||
| </field> | ||
|
|
||
| </record> | ||
|
|
||
|
|
||
| <!--_________________________________________ FORM VIEW _________________________________________--> | ||
|
|
||
| <record id="estate_property_tags_view_form" model="ir.ui.view"> | ||
| <field name="name">estate.property.tag.form</field> | ||
| <field name="model">estate.property.tag</field> | ||
|
|
||
| <field name="arch" type="xml"> | ||
| <form string=""> | ||
| <sheet> | ||
| <div class="oe_title "> | ||
| <label for="name"/> | ||
| <h1> | ||
| <field name="name" default_focus="1" class="oe_inline"/> | ||
| </h1> | ||
| <h4> | ||
| <field name="color" widget="color_picker"/> | ||
| </h4> | ||
| </div> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
|
|
||
| </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,28 @@ | ||
| <?xml version="1.0"?> | ||
| <odoo> | ||
|
|
||
| <record id="test_property_type_action" model="ir.actions.act_window"> | ||
| <field name="name">Property Types</field> | ||
| <field name="res_model">estate.property.type</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_type_view_form" model="ir.ui.view"> | ||
| <field name="name">estate.property.type.form</field> | ||
| <field name="model">estate.property.type</field> | ||
|
|
||
| <field name="arch" type="xml"> | ||
| <form> | ||
| <sheet> | ||
| <div class="oe_title oe_inline text-center"> | ||
| <label for="name"/> | ||
| <h1> | ||
| <field name="name" default_focus="1" class="oe_inline"/> | ||
| </h1> | ||
| </div> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| </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's the purpose of using
'installable': True?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.
When installable is set to true , user can install the module from web interface