Skip to content

Commit 93c2864

Browse files
committed
[ADD] Chapter 5 sawer
1 parent 66de39d commit 93c2864

File tree

5 files changed

+62
-5
lines changed

5 files changed

+62
-5
lines changed

estate/__manifest__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
'base'
88
],
99
'data': [
10-
'security/ir.model.access.csv'
10+
'views/estate_property_views.xml',
11+
'views/estate_menus.xml',
12+
'security/ir.model.access.csv',
1113
],
1214

1315
'application': True,

estate/models/estate_property.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
from odoo import models, fields
2+
import datetime
3+
from dateutil.relativedelta import relativedelta
24

35
class EstateProperty(models.Model):
46
_name = "estate.property"
57
_description = "Create a new table"
68

7-
name = fields.Char(string='Name', required=True)
9+
# FIELDS DECLARATION #
10+
name = fields.Char(
11+
string='Name',
12+
required=True
13+
)
814
description = fields.Text(string='Description')
915
postcode = fields.Char(string='Post code')
10-
date_availability = fields.Date(string='Availability date')
16+
date_availability = fields.Date(
17+
string='Availability date',
18+
default=datetime.date.today() + relativedelta(months=3),
19+
copy=False
20+
)
1121
expected_price = fields.Float(string='Expected price', required=True)
12-
selling_price = fields.Float(string='Selling price')
13-
bedrooms = fields.Integer(string='Bedrooms')
22+
selling_price = fields.Float(
23+
string='Selling price',
24+
readonly=True,
25+
copy=False
26+
)
27+
bedrooms = fields.Integer(
28+
string='Bedrooms',
29+
default=2
30+
)
1431
living_area = fields.Integer(string='Living area')
1532
facades = fields.Integer(string='Facades')
1633
garage = fields.Boolean(string='Garage')
@@ -20,3 +37,11 @@ class EstateProperty(models.Model):
2037
string='Garden orientation',
2138
selection= [('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')]
2239
)
40+
active = fields.Boolean(
41+
string='Active',
42+
default=True
43+
)
44+
state = fields.Selection(
45+
string='State',
46+
selection= [('new', 'New'), ('offer_received', 'Offer Received'), ('offer_accepted', 'Offer Accepted'), ('sold', 'Sold'), ('cancelled', 'Cancelled')]
47+
)

estate/static/description/icon.jpg

14.5 KB
Loading

estate/views/estate_menus.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
4+
<menuitem
5+
id="estate_menu_root"
6+
name="Real Estate"
7+
web_icon="estate,static/description/icon.jpg">
8+
9+
<menuitem id="test_first_level_menu" name="Advertisements">
10+
<menuitem id="estate_property_menu_action" name="Properties" action="estate_property_action"/>
11+
</menuitem>
12+
13+
</menuitem>
14+
15+
</odoo>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
4+
<record id="estate_property_action" model="ir.actions.act_window">
5+
<field name="name">Properties</field>
6+
<field name="res_model">estate.property</field>
7+
<field name="view_mode">list,form</field>
8+
<field name="help" type="html">
9+
<p class="o_view_nocontent_smiling_face">
10+
Can you see this section ?
11+
</p>
12+
</field>
13+
</record>
14+
15+
</odoo>

0 commit comments

Comments
 (0)