-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[ADD] estate: Added Real Estate Module #931
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
stan-odoo
wants to merge
6
commits into
odoo:18.0
Choose a base branch
from
odoo-dev:18.0-training-stan
base: 18.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
6 commits
Select commit
Hold shift + click to select a range
2c03987
[ADD] estate: Added Real Estate Module
stan-odoo fbf7fa3
[IMP] estate: Added access rights in module
stan-odoo d2edb0b
[IMP] estate: Added Views for the module
stan-odoo e587d14
[IMP] estate: Added Form view
stan-odoo c41f21d
[IMP] estate: Improvements, Formatting and added views
stan-odoo 12a0164
[IMP] estate: validation, computed fields and onchanges in fields
stan-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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
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,24 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
{ | ||
'name': 'Real Estate', | ||
'description': 'A Module which covers all workflows related to real estate', | ||
'summary': 'Module to track all things related to real estate of any company', | ||
'version': '1.0', | ||
'category': 'Estate', | ||
'depends': [ | ||
'base' | ||
], | ||
'data': [ | ||
'security/ir.model.access.csv', | ||
'views/estate_property_views.xml', | ||
'views/estate_property_tag_views.xml', | ||
'views/estate_property_type_views.xml', | ||
'views/estate_property_offer_views.xml', | ||
'views/estate_property_menus.xml', | ||
], | ||
'license': 'LGPL-3', | ||
'installable': True, | ||
'application': True, | ||
'auto_install': 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,6 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from . import estate_property | ||
from . import estate_property_type | ||
from . import estate_property_tag | ||
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,88 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from datetime import datetime, timedelta | ||
from odoo import api, models, fields, exceptions | ||
|
||
stan-odoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class EstateProperty(models.Model): | ||
_name = 'estate.property' | ||
_description = 'Estate Property' | ||
|
||
name = fields.Char(string='Estate Property Name', required=True) | ||
description = fields.Text(string='Estate Property Description') | ||
postcode = fields.Char(string='Estate Property Postcode') | ||
date_availability = fields.Date(string='Estate Property Date Availability', copy=False, default=lambda self: datetime.now() + timedelta(days=90)) | ||
expected_price = fields.Float(string='Expected Price Of Property', required=True) | ||
selling_price = fields.Float(string='Selling Price of Property', readonly=True, copy=False) | ||
bedrooms = fields.Integer(string='Number of Bedrooms in Property', default=2) | ||
living_area = fields.Integer(string='Number of Living Room in Property') | ||
facades = fields.Integer(string='Number of Facades in Property') | ||
garage = fields.Boolean(string='Property have garage or not') | ||
garden = fields.Boolean(string='Property have Garden or not') | ||
garden_area = fields.Integer(string='Number of Garden Area') | ||
garden_orientation = fields.Selection( | ||
string='Orientation of Garden', | ||
selection=[ | ||
('north', 'North'), | ||
('south', 'South'), | ||
('east', 'East'), | ||
('west', 'West') | ||
], | ||
help='Different Types of Directions') | ||
active = fields.Boolean(default=True) | ||
state = fields.Selection( | ||
string='State', | ||
default='new', | ||
copy=False, | ||
required=True, | ||
selection=[ | ||
('new', 'New'), | ||
('offer_received', 'Offer Received'), | ||
('offer_accepted', 'Offer Accepted'), | ||
('sold', 'Sold'), | ||
('cancel', 'Cancelled') | ||
], | ||
help='State of the property') | ||
property_type_id = fields.Many2one('estate.property.type', string='Property Type Id') | ||
buyer_id = fields.Many2one('res.partner', string='Buyer', copy=False) | ||
salesman_id = fields.Many2one('res.users', string='Salesman', default=lambda self: self.env.user) | ||
tag_ids = fields.Many2many('estate.property.tag', string='Estate property Tag') | ||
offer_ids = fields.One2many('estate.property.offer', 'property_id', string='offer') | ||
total_area = fields.Float(compute='_compute_total_area') | ||
best_price = fields.Float(compute='_compute_best_price', string='Best Offer Price') | ||
|
||
@api.depends('living_area', 'garden_area') | ||
def _compute_total_area(self): | ||
for record in self: | ||
record.total_area = record.garden_area + record.living_area | ||
|
||
@api.depends('offer_ids.price') | ||
def _compute_best_price(self): | ||
for record in self: | ||
record.best_price = max(record.offer_ids.mapped('price'), default=0.0) | ||
|
||
@api.onchange('garden') | ||
def _on_change_garden(self): | ||
for record in self: | ||
if self.garden: | ||
record.garden_area = 10 | ||
record.garden_orientation = 'north' | ||
else: | ||
record.garden_area = False | ||
record.garden_orientation = False | ||
|
||
def property_sold_action(self): | ||
for record in self: | ||
if record.state == 'cancel': | ||
raise exceptions.UserError('Cancelled property can not be sold') | ||
else: | ||
record.state = 'sold' | ||
return True | ||
|
||
def property_cancel_action(self): | ||
for record in self: | ||
if record.state == 'sold': | ||
raise exceptions.UserError('Sold property can not be cancelled') | ||
else: | ||
record.state = 'cancel' | ||
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,50 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from datetime import timedelta | ||
from odoo import api, fields, models | ||
|
||
|
||
class EstatePropertyOffer(models.Model): | ||
_name = 'estate.property.offer' | ||
_description = 'Estate Property Offer' | ||
|
||
price = fields.Float(string='Offer Price') | ||
status = fields.Selection( | ||
string='Status', | ||
copy=False, | ||
selection=[ | ||
('accepted', 'Accepted'), | ||
('refused', 'Refused') | ||
]) | ||
partner_id = fields.Many2one('res.partner', required=True) | ||
property_id = fields.Many2one('estate.property', required=True) | ||
created_date = fields.Date(default=fields.Date.context_today, string='Created Date') | ||
validity = fields.Integer(default=7, string='Validity (Days)') | ||
date_deadline = fields.Date(compute='_compute_date_deadline', inverse='_inverse_date_deadline', string='Deadline Date', store='True') | ||
|
||
@api.depends('created_date', 'validity') | ||
def _compute_date_deadline(self): | ||
for record in self: | ||
if record.created_date and record.validity: | ||
record.date_deadline = record.created_date + timedelta(days=record.validity) | ||
else: | ||
record.date_deadline = False | ||
|
||
def _inverse_date_deadline(self): | ||
for record in self: | ||
if record.date_deadline and record.created_date: | ||
record.validity = (record.date_deadline - record.created_date).days | ||
else: | ||
record.validity = 0 | ||
|
||
def offer_accepted_action(self): | ||
for record in self: | ||
record.status = 'accepted' | ||
record.property_id.buyer_id = record.partner_id | ||
record.property_id.selling_price = record.price | ||
return True | ||
|
||
def offer_refused_action(self): | ||
for record in self: | ||
record.status = 'refused' | ||
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 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import models, fields | ||
|
||
|
||
class EstatePropertyTag(models.Model): | ||
_name = 'estate.property.tag' | ||
_description = 'Estate Property Tag' | ||
|
||
name = fields.Char(string='Estate Property Tag', required=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 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import models, fields | ||
|
||
|
||
class EstatePropertyType(models.Model): | ||
_name = 'estate.property.type' | ||
_description = 'Estate Property Type' | ||
|
||
name = fields.Char(string='Estate Property Type', required=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,5 @@ | ||
"id","name","model_id/id","group_id/id","perm_read","perm_write","perm_create","perm_unlink" | ||
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1 | ||
access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1 | ||
access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_user,1,1,1,1 | ||
access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1 |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<!-- Root Menu --> | ||
<menuitem id="estate_menu_root" name="Real Estate"> | ||
|
||
<!-- Advertisement Menu --> | ||
<menuitem id="estate_advertisement_menu" name="Advertisement"> | ||
<menuitem id="estate_property_menu_action" action="estate_property_actions" /> | ||
</menuitem> | ||
|
||
<!-- Settings Menu --> | ||
<menuitem id="estate_settings_menu" name="Settings"> | ||
<menuitem id="estate_property_type_menu_action" action="estate_property_type_actions" /> | ||
<menuitem id="estate_property_tag_menu_action" action="estate_property_tag_actions" /> | ||
</menuitem> | ||
</menuitem> | ||
</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,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<!-- List View --> | ||
<record id="estate_property_offer_view" 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> | ||
<field name="price" string="Price" /> | ||
<field name="partner_id" string="Partner" /> | ||
<field name="validity" string="Validity (days)" /> | ||
<field name="date_deadline" string="Deadline" /> | ||
<button name="offer_accepted_action" string="Accept" type="object" icon="fa-check" /> | ||
<button name="offer_refused_action" string="Refuse" type="object" icon="fa-times" /> | ||
<field name="status" /> | ||
</list> | ||
</field> | ||
</record> | ||
|
||
<!-- Form View --> | ||
<record id="estate_property_offer_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="Offer Price Form"> | ||
<sheet> | ||
<group> | ||
<field name="price" string="Price" /> | ||
<field name="partner_id" string="Partner" /> | ||
<field name="validity" string="Validity (days) " /> | ||
<field name="date_deadline" string="Deadline" /> | ||
<field name="status" /> | ||
</group> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
</odoo> | ||
stan-odoo marked this conversation as resolved.
Show resolved
Hide resolved
|
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"?> | ||
<odoo> | ||
|
||
<record id="estate_property_tag_actions" model="ir.actions.act_window"> | ||
<field name="name">Property Tags</field> | ||
<field name="res_model">estate.property.tag</field> | ||
<field name="view_mode">list,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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="estate_property_type_actions" 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> | ||
|
||
</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.
Uh oh!
There was an error while loading. Please reload this page.