Skip to content

Commit 83d1383

Browse files
committed
[ADD] estate: chapter 5 and chapter 6 (list and forms done)
-added default view (list and form) in chapter 5 with some field attributes -added custom view (list and form) in chapter 6
1 parent 8b78ab6 commit 83d1383

File tree

4 files changed

+95
-3
lines changed

4 files changed

+95
-3
lines changed

estate/__manifest__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
'category': 'Real Estate',
1212
'data': [
1313
'security/ir.model.access.csv',
14+
'views/estate_property_views.xml',
15+
'views/estate_menus.xml',
1416
],
1517
'demo': [
1618
'demo/demo.xml',

estate/models/estate_property.py

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

34

@@ -8,10 +9,10 @@ class EstateProperty(models.Model):
89
name = fields.Char(string='Property Name', required=True, help='Enter the name of the property')
910
description = fields.Text(string='Property Description', help='Enter a description of the property')
1011
postcode = fields.Char(string='Postcode', help='Enter the postcode of the property')
11-
date_availability = fields.Date(string='Availability Date', help='Enter the date when the property becomes available')
12+
date_availability = fields.Date(string='Availability Date', help='Enter the date when the property becomes available', copy=False, default=lambda self: fields.Date.today() + relativedelta(months=3))
1213
expected_price = fields.Float(string='Expected Price', required=True, help='Enter the expected price of the property')
13-
selling_price = fields.Float(string='Selling Price', help='Enter the selling price of the property')
14-
bedrooms = fields.Integer(string='Number of Bedrooms', help='Enter the number of bedrooms in the property')
14+
selling_price = fields.Float(string='Selling Price', help='Enter the selling price of the property', readonly=True, copy=False)
15+
bedrooms = fields.Integer(string='Number of Bedrooms', help='Enter the number of bedrooms in the property', default=2)
1516
living_area = fields.Integer(string='Living Area', help='Enter the living area of the property in square meters')
1617
facades = fields.Integer(string='Number of Facades', help='Enter the number of facades of the property')
1718
garage = fields.Boolean(string='Garage', help='Check if the property has a garage')
@@ -27,3 +28,18 @@ class EstateProperty(models.Model):
2728
string='Garden Orientation',
2829
help='Select the orientation of the garden'
2930
)
31+
active = fields.Boolean(string='Active', default=True, help='Set to False to archive the property')
32+
state = fields.Selection(
33+
selection=[
34+
('new', 'New Offer'),
35+
('offer_received', 'Offer Received'),
36+
('offer_accepted', 'Offer Accepted'),
37+
('sold', 'Sold'),
38+
('cancelled', 'Cancelled')
39+
],
40+
string='Status',
41+
required=True,
42+
copy=False,
43+
default='new',
44+
help='Current status of the property'
45+
)

estate/views/estate_menus.xml

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

0 commit comments

Comments
 (0)