Skip to content

Commit 8a7b04c

Browse files
committed
[ADD] estate: add UI actions, menus and defaults
Make estate.property accessible from the UI with proper defaults and field constraints.
1 parent a94c3cd commit 8a7b04c

4 files changed

Lines changed: 47 additions & 3 deletions

File tree

estate/__manifest__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@
99
'application': True,
1010
'data': [
1111
'security/ir.model.access.csv',
12+
'views/estate_property_views.xml',
13+
'views/estate_menus.xml',
1214
]
1315
}

estate/models/estate_property.py

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

34

45
class EstateProperty(models.Model):
@@ -8,10 +9,16 @@ class EstateProperty(models.Model):
89
name = fields.Char(required=True)
910
description = fields.Text()
1011
postcode = fields.Char()
11-
date_availability = fields.Date()
12+
date_availability = fields.Date(
13+
copy=False,
14+
default=lambda self: fields.Date.today() + relativedelta(months=3),
15+
)
1216
expected_price = fields.Float(required=True)
13-
selling_price = fields.Float()
14-
bedrooms = fields.Integer()
17+
selling_price = fields.Float(
18+
readonly=True,
19+
copy=False,
20+
)
21+
bedrooms = fields.Integer(default=2)
1522
living_area = fields.Integer()
1623
facades = fields.Integer()
1724
garage = fields.Boolean()
@@ -21,4 +28,19 @@ class EstateProperty(models.Model):
2128
garden_orientation = fields.Selection(
2229
[('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')]
2330
)
31+
32+
state = fields.Selection(
33+
[
34+
('new', 'New'),
35+
('offer_received', 'Offer Received'),
36+
('offer_accepted', 'Offer Accepted'),
37+
('sold', 'Sold'),
38+
('cancelled', 'Cancelled'),
39+
],
40+
required=True,
41+
copy=False,
42+
default='new',
43+
)
44+
45+
active = fields.Boolean()
2446

estate/views/estate_menus.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
<data>
4+
5+
<menuitem id="estate_menu_root" name="Real Estate">
6+
<menuitem id="estate_properties_menu" name="Properties">
7+
<menuitem id="estate_properties_menu_action" action="estate_property_action"/>
8+
</menuitem>
9+
</menuitem>
10+
11+
</data>
12+
</odoo>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<record id="estate_property_action" model="ir.actions.act_window">
4+
<field name="name">Real Estate</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)