Skip to content

Commit ea24c8b

Browse files
committed
[ADD] training: add Real Estate root menu with Advertisements submenu
1 parent beaf7d1 commit ea24c8b

File tree

8 files changed

+220
-4
lines changed

8 files changed

+220
-4
lines changed

estate/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

estate/__manifest__.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,26 @@
22
'name': "Real Estate",
33
'version': '1.0',
44
'depends': ['base'],
5-
'author': "Author Name",
5+
'author': "Jay Chauhan",
66
'category': 'Category',
77
'description': """
8-
Description text
9-
"""
10-
}
8+
Real Estate Management Module
9+
10+
This module allows managing real estate properties with detailed information including:
11+
- Property title, description, and postcode
12+
- Availability date with default scheduling
13+
- Pricing details (expected and selling price)
14+
- Property features like bedrooms, living area, facades, garage, and garden
15+
- Garden specifics including area and orientation
16+
- Status tracking through different stages: new, offer received, offer accepted, sold, cancelled
17+
- Active flag to easily archive or activate properties
18+
- User-friendly views and search with filters and group-by options for efficient property management
19+
""",
20+
'data': [
21+
'security/ir.model.access.csv',
22+
'views/estate_menus.xml',
23+
'views/estate_property_views.xml'
24+
],
25+
'installable': True,
26+
'application': True
27+
}

estate/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import estate_property

estate/models/estate_property.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from odoo import models, fields
2+
from datetime import date
3+
from dateutil.relativedelta import relativedelta
4+
5+
class EstateProperty(models.Model):
6+
_name = 'estate.property'
7+
_description = 'Estate Property'
8+
9+
# Title of the property (required)
10+
name = fields.Char(string='Title', required=True)
11+
12+
# Detailed description text
13+
description = fields.Text(string='Description')
14+
15+
# Postcode as a simple Char field
16+
postcode = fields.Char(string='Postcode')
17+
18+
# Availability date with default 3 months from today; copy=False avoids duplication on record duplication
19+
date_availability = fields.Date(
20+
string='Availability From',
21+
copy=False,
22+
default=(date.today() + relativedelta(months=3))
23+
)
24+
25+
# Expected sale price (required)
26+
expected_price = fields.Float(string='Expected Price', required=True)
27+
28+
# Actual selling price, read-only (set by system or workflow), not copied on duplication
29+
selling_price = fields.Float(string='Selling Price', readonly=True, copy=False)
30+
31+
# Number of bedrooms with default value
32+
bedrooms = fields.Integer(string='Bedrooms', default=2)
33+
34+
# Living area in square meters
35+
living_area = fields.Integer(string='Living Area (sqm)')
36+
37+
# Number of facades
38+
facades = fields.Integer(string='Facades')
39+
40+
# Garage capacity count
41+
garage = fields.Integer(string='Garage')
42+
43+
# Boolean indicating if garden exists
44+
garden = fields.Boolean(string='Garden')
45+
46+
# Garden area in square meters
47+
garden_area = fields.Integer(string='Garden Area (sqm)')
48+
49+
# Orientation of the garden with default 'north'
50+
garden_orientation = fields.Selection(
51+
selection=[
52+
('north', 'North'),
53+
('south', 'South'),
54+
('east', 'East'),
55+
('west', 'West')
56+
],
57+
string='Garden Orientation',
58+
default='north'
59+
)
60+
61+
# Status of the property; required, default 'new', not copied on duplication
62+
state = fields.Selection(
63+
selection=[
64+
('new', 'New'),
65+
('offer_received', 'Offer Received'),
66+
('offer_accepted', 'Offer Accepted'),
67+
('sold', 'Sold'),
68+
('cancelled', 'Cancelled'),
69+
],
70+
string='Status',
71+
required=True,
72+
copy=False,
73+
default='new'
74+
)
75+
76+
# Active flag to archive/unarchive records easily
77+
active = fields.Boolean(string='Active', default=True)

estate/security/ir.model.access.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
2+
estate.property,estate.ir.model.access,model_estate_property,base.group_user,1,1,1,1
22 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+
<odoo>
2+
<!-- Root menu for the Real Estate module -->
3+
<menuitem id="real_estate_menu_root" name="Real Estate"
4+
web_icon="estate,static/description/building_icon.png">
5+
6+
<!-- First level submenu under Real Estate for Advertisements -->
7+
<menuitem id="real_estate_first_level_menu" name="Advertisements">
8+
9+
<!-- Menu item to open the Properties action under Advertisements -->
10+
<menuitem id="real_estate_model_menu_action" name="Properties"
11+
action="estate_property_action" />
12+
</menuitem>
13+
</menuitem>
14+
15+
</odoo>
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<odoo>
2+
<!-- List view of estate.property model -->
3+
<record id="estate_property_list" model="ir.ui.view">
4+
<field name="name">estate.property.list</field>
5+
<field name="model">estate.property</field>
6+
<field name="arch" type="xml">
7+
<list string="Channel">
8+
<!-- Display these fields in list view -->
9+
<field name="name" />
10+
<field name="description" />
11+
<field name="postcode" />
12+
<field name="date_availability" />
13+
<field name="expected_price" />
14+
<field name="selling_price" />
15+
<field name="bedrooms" />
16+
<field name="living_area" />
17+
<field name="facades" />
18+
<field name="garage" />
19+
<field name="garden" />
20+
<field name="garden_area" />
21+
<field name="garden_orientation" />
22+
<field name="state" />
23+
<field name="active" />
24+
</list>
25+
</field>
26+
</record>
27+
28+
<!-- Search view of estate.property model -->
29+
<record id="estate_property_search" model="ir.ui.view">
30+
<field name="name">estate.property.search</field>
31+
<field name="model">estate.property</field>
32+
<field name="arch" type="xml">
33+
<search string="Search Properties">
34+
<!-- Searchable fields -->
35+
<field name="name" />
36+
<field name="postcode" />
37+
<field name="expected_price" />
38+
<field name="bedrooms" />
39+
<field name="living_area" />
40+
<field name="facades" />
41+
42+
<!-- Predefined filter to show only available properties -->
43+
<filter string="Available" name="available_properties"
44+
domain="[('state', 'in', ['new', 'offer_received'])]" />
45+
46+
<!-- Group By section -->
47+
<group expand="1" string="Group By">
48+
<filter name="group_by_postcode" string="Post Code" context="{'group_by': 'postcode'}" />
49+
</group>
50+
</search>
51+
</field>
52+
</record>
53+
54+
<!-- Form view of estate.property model -->
55+
<record id="estate_property_form" model="ir.ui.view">
56+
<field name="name">estate.property.form</field>
57+
<field name="model">estate.property</field>
58+
<field name="arch" type="xml">
59+
<form string="Property Form">
60+
<sheet>
61+
<group>
62+
<h1>
63+
<field name="name" />
64+
</h1>
65+
</group>
66+
<group>
67+
<group>
68+
<field name="postcode" />
69+
<field name="date_availability" />
70+
</group>
71+
<group>
72+
<field name="expected_price" />
73+
<field name="selling_price" />
74+
</group>
75+
</group>
76+
<notebook>
77+
<page string="Description">
78+
<group>
79+
<field name="description" />
80+
<field name="bedrooms" />
81+
<field name="living_area" />
82+
<field name="facades" />
83+
<field name="garage" />
84+
<field name="garden" />
85+
<field name="garden_area" />
86+
<field name="garden_orientation" />
87+
<field name="active" />
88+
<field name="state" />
89+
</group>
90+
</page>
91+
</notebook>
92+
</sheet>
93+
</form>
94+
</field>
95+
</record>
96+
97+
<!-- Action to open estate.property records -->
98+
<record id="estate_property_action" model="ir.actions.act_window">
99+
<field name="name">Properties</field>
100+
<field name="res_model">estate.property</field>
101+
<field name="view_mode">list,form</field>
102+
</record>
103+
</odoo>

0 commit comments

Comments
 (0)