-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[ADD] estate: added a new estate module #734
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
base: 18.0
Are you sure you want to change the base?
Changes from 7 commits
29c0511
ede556e
84e5068
ef955ea
7f831ed
4c14c9b
ab16cc9
be5ca2f
4128d63
8826e2b
df29c68
0d101b0
4878ba5
d270336
77d0bd8
9c751ec
b4e70b6
2fdc85d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
assert models | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
'name': 'Estate', | ||
'depends': ['base'], | ||
'application': True, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget to add the |
||
'license': 'LGPL-3', | ||
'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_offers_views.xml', | ||
'views/estate_menus.xml'] | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,7 @@ | ||||||||||||||||||||||
from . import estate_property | ||||||||||||||||||||||
from . import estate_property_type, estate_property_tag, estate_property_offer | ||||||||||||||||||||||
|
||||||||||||||||||||||
assert estate_property | ||||||||||||||||||||||
assert estate_property_type | ||||||||||||||||||||||
assert estate_property_tag | ||||||||||||||||||||||
assert estate_property_offer | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nitpick: this syntax is fine but in odoo code, |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,78 @@ | ||||||
from odoo import api, models, fields | ||||||
from dateutil.relativedelta import relativedelta | ||||||
|
||||||
|
||||||
def _default_date_availability(): | ||||||
return fields.Date.today() + relativedelta(months=3) | ||||||
|
||||||
|
||||||
class EstateProperty(models.Model): | ||||||
_name = "estate.property" | ||||||
_description = "Real Estate Property Information" | ||||||
|
||||||
name = fields.Char(required=True) | ||||||
description = fields.Text() | ||||||
property_tags_ids = fields.Many2many("estate.property.tag") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick:
Suggested change
for x2m the convention is usually to keep the base name in the singular (since |
||||||
property_type_id = fields.Many2one("estate.property.type", string="Property Type") | ||||||
postcode = fields.Char() | ||||||
date_availability = fields.Date( | ||||||
copy=False, | ||||||
default=_default_date_availability() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Here calling the function means it will called only once instead of at every new record creation |
||||||
) | ||||||
state = fields.Selection( | ||||||
string='Status', | ||||||
required=True, | ||||||
copy=False, | ||||||
default='new', | ||||||
selection=[ | ||||||
('new', 'New'), | ||||||
('offer_received', 'Offer Received'), | ||||||
('offer_accepted', 'Offer Accepted'), | ||||||
('sold', 'Sold'), | ||||||
('cancelled', 'Cancelled') | ||||||
], | ||||||
) | ||||||
expected_price = fields.Float(required=True) | ||||||
best_price = fields.Float(string="Best Offer", compute="_compute_best_price") | ||||||
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( | ||||||
string='Garden Orientation', | ||||||
selection=[('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')], | ||||||
help="Orientation of the garden" | ||||||
) | ||||||
total_area = fields.Integer( | ||||||
string="Total Area (sqm)", | ||||||
compute="_compute_total_area", | ||||||
) | ||||||
salesperson_id = fields.Many2one('res.users', string='Salesperson', default=lambda self: self.env.user) | ||||||
buyer_id = fields.Many2one('res.partner', string='Buyer') | ||||||
offers_ids = fields.One2many('estate.property.offer', 'property_id') | ||||||
active = fields.Boolean(default=True) | ||||||
|
||||||
@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('offers_ids.price') | ||||||
def _compute_best_price(self): | ||||||
for record in self: | ||||||
if record.offers_ids: | ||||||
record.best_price = max(record.offers_ids.mapped('price')) | ||||||
else: | ||||||
record.best_price = 0.0 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tip: |
||||||
|
||||||
@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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from odoo import api, models, fields | ||
from dateutil.relativedelta import relativedelta | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing a blank line. We should have 2 blank lines between imports and class definition. Check the other files. Thanks 👍 |
||
class EstatePropertyOffer(models.Model): | ||
_name = "estate.property.offer" | ||
_description = "Real Estate Property Offer" | ||
|
||
price = fields.Float() | ||
status = fields.Selection( | ||
string='Status', | ||
copy=False, | ||
selection=[ | ||
('accepted', 'Accepted'), | ||
('refused', 'Refused'), | ||
], | ||
) | ||
validity = fields.Integer(string="Validity (days)", default=7) | ||
date_deadline = fields.Date(string="Deadline", compute="_compute_date_deadline", inverse="_inverse_date_deadline") | ||
partner_id = fields.Many2one("res.partner", required=True) | ||
property_id = fields.Many2one("estate.property", required=True) | ||
|
||
@api.depends('create_date', 'validity') | ||
def _compute_date_deadline(self): | ||
for record in self: | ||
if record.create_date: | ||
base_date = record.create_date.date() | ||
else: | ||
base_date = fields.Date.today() | ||
record.date_deadline = base_date + relativedelta(days=record.validity) | ||
|
||
def _inverse_date_deadline(self): | ||
for record in self: | ||
if record.create_date: | ||
base_date = record.create_date.date() | ||
else: | ||
base_date = fields.Date.today() | ||
record.validity = (record.date_deadline - base_date).days |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from odoo import models, fields | ||
|
||
|
||
class EstatePropertyTag(models.Model): | ||
_name = "estate.property.tag" | ||
_description = "Real Estate Property Tag" | ||
|
||
name = fields.Char(required=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from odoo import models, fields | ||
|
||
|
||
class EstatePropertyType(models.Model): | ||
_name = "estate.property.type" | ||
_description = "Real Estate Property Type" | ||
|
||
name = fields.Char(required=True) |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<odoo> | ||
<menuitem id="estate_menu_root" name="Real Estate"> | ||
<menuitem id="estate_properties_menu" name="Advertisements"> | ||
<menuitem id="estate_property_menu_action" action="estate_property_action"/> | ||
</menuitem> | ||
|
||
<menuitem id="settings_menu" name="Settings"> | ||
<menuitem id="estate_property_type_menu_action" action="estate_property_type_action"/> | ||
<menuitem id="estate_property_tag_menu_action" action="estate_property_tag_action"/> | ||
</menuitem> | ||
</menuitem> | ||
</odoo> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<data> | ||
<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="Property Offer"> | ||
<field name="price"/> | ||
<field name="partner_id"/> | ||
<field name="validity"/> | ||
<field name="date_deadline"/> | ||
<field name="status"/> | ||
</list> | ||
</field> | ||
</record> | ||
|
||
<record id="estate_property_offer_view_form" model="ir.ui.view"> | ||
<field name="name">estate.property.offer.view.form</field> | ||
<field name="model">estate.property.offer</field> | ||
<field name="arch" type="xml"> | ||
<form string=""> | ||
<sheet> | ||
<group> | ||
<field name="price"/> | ||
<field name="partner_id"/> | ||
<field name="validity"/> | ||
<field name="date_deadline"/> | ||
<field name="status"/> | ||
</group> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
</data> | ||
</odoo> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<data> | ||
<record id="estate_property_tag_action" 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> | ||
<field name="help" type="html"> | ||
<p class="o_view_nocontent_smiling_face"> | ||
Create a new property tag | ||
</p> | ||
</field> | ||
</record> | ||
|
||
<record id="estate_property_tag_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="Property Tag"> | ||
<field name="name"/> | ||
</list> | ||
</field> | ||
</record> | ||
|
||
<record id="estate_property_tag_view_form" model="ir.ui.view"> | ||
<field name="name">estate.property.tag.view.form</field> | ||
<field name="model">estate.property.tag</field> | ||
<field name="arch" type="xml"> | ||
<form string=""> | ||
<sheet> | ||
<h1> | ||
<field name="name" placeholder="New tag"/> | ||
</h1> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
</data> | ||
</odoo> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<data> | ||
<record id="estate_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> | ||
<field name="help" type="html"> | ||
<p class="o_view_nocontent_smiling_face"> | ||
Create a new property type | ||
</p> | ||
</field> | ||
</record> | ||
|
||
<record id="estate_property_type_view_list" model="ir.ui.view"> | ||
<field name="name">estate.property.type.list</field> | ||
<field name="model">estate.property.type</field> | ||
<field name="arch" type="xml"> | ||
<list string="Property Types"> | ||
<field name="name"/> | ||
</list> | ||
</field> | ||
</record> | ||
|
||
<record id="estate_property_type_view_form" model="ir.ui.view"> | ||
<field name="name">estate.property.type.view.form</field> | ||
<field name="model">estate.property.type</field> | ||
<field name="arch" type="xml"> | ||
<form string=""> | ||
<sheet> | ||
<h1> | ||
<field name="name" placeholder="Appartment"/> | ||
</h1> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
</data> | ||
</odoo> |
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.
nitpick: not really needed but ok