Skip to content

Commit 2e143d9

Browse files
author
SurryaT10
committed
[ADD] Chapter 6: Build Views
Added estate_property_views.xml which contains list and form views Added a separate estate_property_search_view.xml for search with filters for active and availability as well as group by based on postcode. Also addressed code review comments.
1 parent 6591727 commit 2e143d9

File tree

5 files changed

+100
-28
lines changed

5 files changed

+100
-28
lines changed

estate/__manifest__.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
{
22
'name': "Estate",
33

4-
'summary': """
5-
Starting module for "Estate"
6-
""",
7-
8-
'description': """
9-
Starting module for "Estate"
10-
""",
11-
124
'author': "Odoo",
135
'website': "https://www.odoo.com",
146

15-
# Categories can be used to filter modules in modules listing
16-
# Check https://github.com/odoo/odoo/blob/15.0/odoo/addons/base/data/ir_module_category_data.xml
17-
# for the full list
187
'category': 'Tutorials',
198
'version': '0.1',
209

21-
# any module necessary for this one to work correctly
2210
'depends': ['base', 'web'],
2311
'data': [
12+
'views/estate_property_search_view.xml',
2413
'views/estate_property_views.xml',
2514
'views/estate_menus.xml',
2615
'security/ir.model.access.csv',

estate/models/estate.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,25 @@ class Estate(models.Model):
44
_name = 'estate.property'
55
_description = 'Estate Property'
66

7-
name = fields.Char('Property Name', required=True)
8-
description = fields.Text('Description')
9-
postcode = fields.Char('Postcode')
10-
date_availability = fields.Date('Availability')
11-
expected_price = fields.Float('Expected Price', required=True)
12-
selling_price = fields.Float('Selling Price')
13-
bedrooms = fields.Integer('# Bedrooms')
14-
living_area = fields.Integer('Living Area')
15-
facades = fields.Integer('Facades')
16-
garage = fields.Boolean('Garage', default=True)
17-
garden = fields.Boolean('Garden', default=True)
18-
garden_area = fields.Integer('Garden Area')
7+
name = fields.Char("Property Name", required=True)
8+
description = fields.Text("Description")
9+
postcode = fields.Char("Postcode")
10+
date_availability = fields.Date("Available From", default=fields.Date.add(fields.Date.today(), months=3))
11+
expected_price = fields.Float("Expected Price", required=True)
12+
selling_price = fields.Float("Selling Price", readonly=True, copy=False)
13+
bedrooms = fields.Integer("Bedrooms", default=2)
14+
living_area = fields.Integer("Living Area (sqm)")
15+
facades = fields.Integer("Facades")
16+
garage = fields.Boolean("Garage", default=True)
17+
garden = fields.Boolean("Garden", default=True)
18+
garden_area = fields.Integer("Garden Area (sqm)")
1919
garden_orientation = fields.Selection(
20-
string='Type',
21-
selection=[('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')],
20+
string="Garden Orientation",
21+
selection=[('north', "North"), ('south', "South"), ('east', "East"), ('west', "West")],
2222
required=True)
23+
status = fields.Selection(
24+
string="Status",
25+
selection=[('new', "New"), ('offer_received', "Offer Received"), ('offer_accepted', "Offer Accepted"), ('sold', "Sold"), ('canceled', "Canceled")],
26+
default='new',
27+
required=True)
28+
active = fields.Boolean("Active", default=True)

estate/views/estate_menus.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
<menuitem id="estate_menu_properties" name="Properties" action="estate_property_action"/>
66
</menuitem>
77
</menuitem>
8-
</odoo>
8+
</odoo>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<odoo>
2+
<record id="action_estate_property_search" model="ir.ui.view">
3+
<field name="name">estate.property.search</field>
4+
<field name="model">estate.property</field>
5+
<field name="arch" type="xml">
6+
<search>
7+
<field name="name" string="Title"/>
8+
<field name="postcode"/>
9+
<field name="expected_price"/>
10+
<field name="bedrooms"/>
11+
<field name="living_area"/>
12+
<field name="facades"/>
13+
<filter string="Archived" name="inactive" domain="[('active', '=', False)]"/>
14+
<filter string="Status" name="availability" domain="[('status', 'in', ['new', 'offered'])]"/>
15+
<group>
16+
<filter string="Postcode" name="postcode" context="{'group_by':'postcode'}"/>
17+
</group>
18+
</search>
19+
</field>
20+
</record>
21+
</odoo>

estate/views/estate_property_views.xml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,60 @@
55
<field name="res_model">estate.property</field>
66
<field name="view_mode">list,form</field>
77
</record>
8-
</odoo>
8+
9+
<record id="estate_property_view_tree" model="ir.ui.view">
10+
<field name="name">estate.property.tree</field>
11+
<field name="model">estate.property</field>
12+
<field name="arch" type="xml">
13+
<list>
14+
<field name="name"/>
15+
<field name="postcode"/>
16+
<field name="bedrooms"/>
17+
<field name="living_area"/>
18+
<field name="expected_price"/>
19+
<field name="selling_price"/>
20+
<field name="date_availability"/>
21+
</list>
22+
</field>
23+
</record>
24+
25+
<record id="estate_property_view_form" model="ir.ui.view">
26+
<field name="name">estate.property.form</field>
27+
<field name="model">estate.property</field>
28+
<field name="arch" type="xml">
29+
<form string="My new house">
30+
<sheet>
31+
<group>
32+
<h1>
33+
<field name="name"/>
34+
</h1>
35+
</group>
36+
<group>
37+
<group>
38+
<field name="postcode"/>
39+
<field name="date_availability"/>
40+
</group>
41+
<group>
42+
<field name="expected_price"/>
43+
<field name="selling_price"/>
44+
</group>
45+
</group>
46+
<notebook>
47+
<page string="Description">
48+
<group>
49+
<field name="description"/>
50+
<field name="bedrooms"/>
51+
<field name="living_area"/>
52+
<field name="facades"/>
53+
<field name="garage"/>
54+
<field name="garden"/>
55+
<field name="garden_area"/>
56+
<field name="garden_orientation"/>
57+
</group>
58+
</page>
59+
</notebook>
60+
</sheet>
61+
</form>
62+
</field>
63+
</record>
64+
</odoo>

0 commit comments

Comments
 (0)