Skip to content

Commit c3a4fa3

Browse files
committed
[IMP] estate: implemented form and model fields, code formation.
implemented form in views and added model fields in estate_property model. modified views and menuitem names.
1 parent a5dd647 commit c3a4fa3

File tree

5 files changed

+66
-27
lines changed

5 files changed

+66
-27
lines changed

estate/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
Description text
1111
""",
1212
'data': [
13-
'views/estate_menus.xml',
1413
'views/estate_property_views.xml',
14+
'views/estate_menus.xml',
1515
'security/ir.model.access.csv'
1616
],
1717
}

estate/models/estate_property.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,47 @@
1-
from odoo import models,fields
1+
from odoo import models, fields
2+
from odoo.tools import date_utils
3+
24

35
class EstateProperty(models.Model):
46
_name = "estate.property"
57
_description = "Estate Property"
68

7-
name = fields.Char(required = True)
9+
name = fields.Char(required=True, default="Unknown")
810
description = fields.Text()
911
postcode = fields.Char()
10-
date_avaliability = fields.Date()
11-
expected_price = fields.Float(required = True)
12-
selling_price = fields.Float()
13-
bedrooms = fields.Integer()
12+
date_avaliability = fields.Date(
13+
copy=False,
14+
default=lambda self: fields.Date.context_today(self) + relativedelta(months=3),
15+
)
16+
expected_price = fields.Float(required=True)
17+
selling_price = fields.Float(readonly=True, copy=False)
18+
bedrooms = fields.Integer(default=2)
1419
living_area = fields.Integer()
1520
facades = fields.Integer()
1621
garage = fields.Boolean()
1722
garden = fields.Boolean()
1823
garden_area = fields.Integer()
19-
garden_orientation = fields.Selection(selection = [('north','North'),('south','South'),('east','East'),('west','West')])
24+
last_seen = fields.Datetime("Last Seen", default=fields.Datetime.now)
25+
garden_orientation = fields.Selection(
26+
selection=[
27+
("north", "North"),
28+
("south", "South"),
29+
("east", "East"),
30+
("west", "West"),
31+
],
32+
string="Orientation",
33+
)
34+
active = fields.Boolean(default=True)
35+
state = fields.Selection(
36+
selection=[
37+
("new", "New"),
38+
("offer_received", "Offer Received"),
39+
("offer_accepted", "Offer Accepted"),
40+
("sold", "Sold"),
41+
("cancelled", "Cancelled"),
42+
],
43+
string="Status",
44+
required=True,
45+
copy=False,
46+
default="new",
47+
)
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,0,0,0
2+
estate.access_estate_property,"access_estate_property",estate.model_estate_property,base.group_user,1,1,1,1

estate/views/estate_menus.xml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,28 @@
33
name="Estate Property"
44
action="action_estate"/>
55

6-
<menuitem id="estate_menu_property"
7-
name="Properties"
6+
<menuitem id="estate_menu_advertisements"
7+
name="Advertisements"
88
parent="estate_menu_root"
9-
action="action_estate_property"/>
10-
11-
<menuitem id="property_menu"
12-
name="Configuration"
13-
parent="estate_menu_root"
14-
action="action_estate_configure"/>
9+
action="action_estate_advertisements"
10+
sequence = "1"/>
11+
12+
<menuitem id="estate_menu_configuration"
13+
name="Settings"
14+
parent="estate_menu_root"/>
15+
16+
<menuitem id="configuration_menu_option_1"
17+
name="Option 1"
18+
parent="estate_menu_configuration"
19+
action="action_estate_configure"/>
20+
21+
<menuitem id="configuration_menu_option_2"
22+
name="Option 2"
23+
parent="estate_menu_configuration"
24+
action="action_estate_configure"/>
25+
26+
<menuitem id="configuration_menu_option_3"
27+
name="Option 3"
28+
parent="estate_menu_configuration"
29+
action="action_estate_configure"/>
1530
</odoo>

estate/views/estate_property_views.xml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
<odoo>
22
<record id="action_estate" model="ir.actions.act_window">
3-
<field name="name">Estate Property</field>
3+
<field name="name">Properties</field>
44
<field name="res_model">estate.property</field>
55
<field name="view_mode">list,form</field>
66
<field name="help" type="html">
77
<p class="o_view_nocontent_smiling_face">
8-
Estate Property Home!
8+
Create your first Property!
99
</p>
1010
</field>
1111
</record>
1212

13-
<record id="action_estate_property" model="ir.actions.act_window">
14-
<field name="name">Estate Property</field>
15-
<field name="res_model">estate.property</field>
16-
<field name="view_mode">list,form</field>
13+
<record id="action_estate_advertisements" model="ir.actions.act_window">
14+
<field name="name">Advertisements</field>
1715
<field name="help" type="html">
1816
<p class="o_view_nocontent_smiling_face">
19-
Create New Property!
17+
advertisements!
2018
</p>
2119
</field>
2220
</record>
2321

2422
<record id="action_estate_configure" model="ir.actions.act_window">
25-
<field name="name">Estate Property</field>
26-
<field name="res_model">estate.property</field>
27-
<field name="view_mode">list,form</field>
23+
<field name="name">Settings</field>
2824
<field name="help" type="html">
2925
<p class="o_view_nocontent_smiling_face">
3026
Empty!

0 commit comments

Comments
 (0)