Skip to content

Commit 7e244b4

Browse files
[ADD] real_estate: Add property status, dashboard logo, and refactor
- Introduce active and state fields for properties to manage their lifecycle and visibility. - Add a custom logo to the dashboard . - Refactor existing code to adhere to project coding guidelines. - Incorporate feedback from previous reviews . Chapter #5
1 parent fe97ac7 commit 7e244b4

5 files changed

Lines changed: 39 additions & 22 deletions

File tree

estate/models/estate_property.py

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,45 @@
1+
from typing import DefaultDict
2+
from typing_extensions import ReadOnly
13
from odoo import fields, models, api
24
from odoo.exceptions import ValidationError
35

46

5-
class estate_property(models.Model):
7+
class EstateProperty(models.Model):
68

7-
_name = "estate.property"
9+
_name = 'estate.property'
810
_description = "A real estate model with many fields"
9-
name = fields.Char(required=True)
10-
description = fields.Text()
11-
postcode = fields.Integer()
12-
date_availability = fields.Datetime()
13-
expected_price = fields.Float(required=True)
14-
selling_price = fields.Float()
15-
bedrooms = fields.Integer()
16-
living_area = fields.Integer()
17-
facades = fields.Integer()
18-
garage = fields.Boolean()
19-
garden = fields.Boolean()
20-
garden_area = fields.Integer()
11+
active = fields.Boolean(string="Active", default="Active")
12+
bedrooms = fields.Integer(string="Bedrooms", default="2")
13+
date_availability = fields.Datetime(
14+
string="Available From", copy=False, default=lambda self: fields.Date.add(fields.Date.context_today(self), months=3))
15+
description = fields.Text(string="Description")
16+
expected_price = fields.Float(string="Expected Price", required=True)
17+
facades = fields.Integer(string="Facades")
18+
garden = fields.Boolean(string="Garden")
19+
garden_area = fields.Integer(string="Garden Area (sqm)")
2120
garden_orientation = fields.Selection(
22-
string='Type',
23-
selection=[('north', 'North'), ('south', 'South'),
24-
('east', 'East'), ('west', 'West')],
25-
help="Type is used to specify the garden orientation")
21+
string="Direction",
22+
selection=[
23+
('north', "North"),
24+
('south', "South"),
25+
('east', "East"),
26+
('west', "West")
27+
],
28+
help="Type is used to specify the garden orientation"
29+
)
30+
garage = fields.Boolean(string="Garage")
31+
living_area = fields.Integer(string="Living Area (sqm)")
32+
name = fields.Char(string="Title", required=True, default="Unknown")
33+
postcode = fields.Integer(string="Postcode")
34+
selling_price = fields.Float(
35+
string="Selling Price", readonly=True, copy=False)
36+
state = fields.Selection([('new', "New"),
37+
('offer_received', "Offer Received"),
38+
('offer_accepted', "Offer Accepted"),
39+
('sold', "Sold"),
40+
('cancelled', "Cancelled")
41+
],
42+
default='new')
2643

2744
@api.constrains('expected_price')
2845
def _check_price(self):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2-
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
2+
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
180 KB
Loading

estate/views/estate_menus.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0"?>
22
<odoo>
33

4-
<menuitem id="real_estate_root" name="Real Estate"/>
4+
<menuitem id="real_estate_root" name="Real Estate" web_icon="estate,static/description/6888420.jpg" />
55

66
<menuitem id="real_estate_properties_menu" name="Properties" parent="real_estate_root"/>
77

88
<menuitem id="real_estate_menu_action" name="All Properties" parent="real_estate_properties_menu" action="test_property_action"/>
9-
</odoo>
9+
</odoo>

estate/views/estate_property_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
<field name="view_mode">list,form</field>
88
</record>
99

10-
</odoo>
10+
</odoo>

0 commit comments

Comments
 (0)