Skip to content

Commit 63f1fb1

Browse files
committed
[IMP] estate: add basic menus
Add basic UI menus for estate_property. Also add some more fields to the model. Python framework 101 tutorial: chapter 5
1 parent be17520 commit 63f1fb1

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

estate/__manifest__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
'application': True,
99
'data': [
1010
'security/ir.model.access.csv',
11+
12+
"views/estate_property_views.xml",
13+
"views/estate_menus.xml",
1114
]
1215
}

estate/models/estate_property.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from dateutil.relativedelta import relativedelta
12
from odoo import fields, models
23

34
class EstateProperty(models.Model):
@@ -7,15 +8,24 @@ class EstateProperty(models.Model):
78
name = fields.Char(required=True)
89
description = fields.Text()
910
postcode = fields.Char()
10-
date_availability = fields.Date()
11+
date_availability = fields.Date(default=fields.Date.today() + relativedelta(months=3), copy=False)
1112
expected_price = fields.Float(required=True)
12-
selling_price = fields.Float()
13-
bedrooms = fields.Integer()
13+
selling_price = fields.Float(readonly=True, copy=False)
14+
bedrooms = fields.Integer(default=2)
1415
living_area = fields.Integer()
1516
facades = fields.Integer()
1617
garage = fields.Boolean()
1718
garden = fields.Boolean()
1819
garden_area = fields.Integer()
1920
garden_orientation = fields.Selection(
2021
selection=[('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')]
22+
)
23+
24+
# Reserved fields
25+
active=fields.Boolean(default=True)
26+
state=fields.Selection(
27+
required=True,
28+
selection=[('new', 'New'), ('offer_received', 'Offer Received'), ('offer_accepted', 'Offer Accepted'), ('sold', 'Sold'), ('cancelled', 'Cancelled')],
29+
default="new",
30+
copy=False
2131
)

estate/views/estate_menus.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
<menuitem id="estate_menu_root" name="Real Estate">
4+
<menuitem id="estate_first_level_menu" name="First Level">
5+
<menuitem id="estate_create_estate_property_menu" action="estate_create_estate_property"/>
6+
</menuitem>
7+
</menuitem>
8+
</odoo>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
<record id="estate_create_estate_property" model="ir.actions.act_window">
4+
<field name="name">Create</field>
5+
<field name="res_model">estate.property</field>
6+
<field name="view_mode">list,form</field>
7+
</record>
8+
</odoo>

0 commit comments

Comments
 (0)