Skip to content

Commit f7cddde

Browse files
committed
[IMP] estate: added Inline Views, widgets, list order, Attributes, & Options.
-Implemented inline views and widgets to enhance the user interface within the Real Estate module. -Introduced list-ordering functionality to improve the organization and sorting of listings. -Added attribute and option configurations to increase customization capabilities and overall flexibility for users.
1 parent 83b1935 commit f7cddde

10 files changed

+112
-47
lines changed

estate/models/estate_property.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ class EstateProperty(models.Model):
1717
)
1818
expected_price = fields.Float("Expected Price", required=True)
1919
selling_price = fields.Float("Selling Price", readonly=True)
20-
bedrooms = fields.Integer(default=2)
21-
living_area = fields.Integer("Living Area (sqm)")
20+
bedrooms = fields.Integer(default=3)
21+
living_area = fields.Integer("Living Area (sqft)")
2222
facades = fields.Integer()
2323
garage = fields.Boolean()
2424
garden = fields.Boolean()
25-
garden_area = fields.Integer("Garden Area (sqm)")
25+
garden_area = fields.Integer("Garden Area (sqft)")
2626
garden_orientation = fields.Selection(
2727
selection=[
2828
("north", "North"),
29-
("south", "South"),
3029
("east", "East"),
3130
("west", "West"),
31+
("South", "South"),
3232
],
3333
string="Garden Orientation",
3434
)
@@ -51,7 +51,7 @@ class EstateProperty(models.Model):
5151
salesperson_id = fields.Many2one("res.users", string="Salesperson")
5252
tag_ids = fields.Many2many("estate.property.tag", string="Tags")
5353
offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers")
54-
total_area = fields.Integer("Total Area (sqm)", compute="_compute_total_area")
54+
total_area = fields.Integer("Total Area (sqft)", compute="_compute_total_area")
5555
best_price = fields.Float("Best Offer", compute="_compute_best_price")
5656

5757
@api.depends("living_area", "garden_area")
@@ -71,11 +71,11 @@ def _onchange_garden(self):
7171
if record.garden_area == 10:
7272
record.garden_orientation = "north"
7373
elif record.garden_area == 20:
74-
record.garden_orientation = "south"
75-
elif record.garden_area == 30:
7674
record.garden_orientation = "east"
77-
elif record.garden_area == 40:
75+
elif record.garden_area == 30:
7876
record.garden_orientation = "west"
77+
elif record.garden_area == 40:
78+
record.garden_orientation = "south"
7979
else:
8080
record.garden_area = 0
8181
record.garden_orientation = False
@@ -97,12 +97,12 @@ def action_sold(self):
9797

9898
_check_expected_price = models.Constraint(
9999
'CHECK(expected_price > 0)',
100-
'The expected price of a property must be strictly positive.'
100+
'The expected price must be strictly positive.'
101101
)
102102

103103
_check_selling_price = models.Constraint(
104104
'CHECK(selling_price > 0)',
105-
'The selling price of a property must be positive.'
105+
'The selling price must be positive.'
106106
)
107107

108108
@api.constrains("selling_price", "expected_price")
@@ -118,5 +118,6 @@ def _check_selling_price_ratio(self):
118118
< 0
119119
):
120120
raise ValidationError(
121-
"The selling price cannot be lower than 90% of the expected price."
121+
"The selling price cannot be lower then 90% of the expected price."
122122
)
123+

estate/models/estate_property_offer.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,23 @@
77
class EstatePropertyOffer(models.Model):
88
_name = "estate.property.offer"
99
_description = "Real Estate Property Offer"
10+
_order = "price desc"
1011

1112
price = fields.Float()
1213
status = fields.Selection(
13-
[("accepted", "Accepted"), ("refused", "Refused")],
14+
[("accept", "Accept"), ("refuse", "Refuse")],
1415
copy=False,
1516
)
1617
partner_id = fields.Many2one("res.partner", string="Partner", required=True)
1718
property_id = fields.Many2one("estate.property", string="Property", required=True)
18-
validity = fields.Integer(string="Validity(days)", default=7)
19+
validity = fields.Integer(string="Validity(days)", default=15)
1920
date_deadline = fields.Date(string="Deadline Date", compute="_compute_date_deadline", inverse="_inverse_date_deadline")
2021

2122
@api.depends('validity')
2223
def _compute_date_deadline(self):
2324
for record in self:
2425
creation_date = record.create_date or fields.Date.today()
25-
record.date_deadline = relativedelta(days=record.validity) + creation_date
26+
record.date_deadline = relativedelta(days=record.validity) + creation_date
2627

2728
def _inverse_date_deadline(self):
2829
for record in self:
@@ -37,7 +38,7 @@ def action_accept(self):
3738
record.status = 'accepted'
3839
record.property_id.selling_price = record.price
3940
record.property_id.state = 'offer_accepted'
40-
record.property_id.buyer_id= record.partner_id
41+
record.property_id.buyer_id = record.partner_id
4142

4243
def action_refuse(self):
4344
for record in self:
@@ -46,5 +47,5 @@ def action_refuse(self):
4647

4748
_check_offer_price = models.Constraint(
4849
'CHECK(price > 0)',
49-
'The price of an offer must be strictly positive.'
50-
)
50+
'The price must be strictly positive.'
51+
)

estate/models/estate_property_tag.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
class EstatePropertyTag(models.Model):
55
_name = "estate.property.tag"
66
_description = "Real Estate Property Tag"
7+
_order = "name"
78

89
name = fields.Char(required=True)
10+
color = fields.Integer()
911

1012
_check_tag_name_unique = models.Constraint(
11-
'UNIQUE(name)',
12-
'The name of the property tag must be unique.'
13+
'UNIQUE(name)',
14+
'The name of the property tag must be unique.'
1315
)

estate/models/estate_property_type.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
class EstatePropertyType(models.Model):
55
_name = "estate.property.type"
66
_description = "Real Estate Property Type"
7+
_order = "sequence, name"
78

89
name = fields.Char(required=True)
10+
property_ids = fields.One2many("estate.property", "property_type_id", string="Properties")
11+
sequence = fields.Integer('Sequence', default=1)
912

1013
_check_type_name_unique = models.Constraint(
11-
'UNIQUE(name)',
12-
'The name of the property type must be unique.'
13-
)
14+
'UNIQUE(name)',
15+
'The name of the property type must be unique.'
16+
)

estate/security/ir.model.access.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
22
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
33
estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1
44
access_estate_property_tag,estate.property.tag.access,model_estate_property_tag,base.group_user,1,1,1,1
5-
access_estate_property_offer,estate.property.offer.access,model_estate_property_offer,base.group_user,1,1,1,1
5+
access_estate_property_offer,estate.property.offer.access,model_estate_property_offer,base.group_user,1,1,1,1

estate/views/estate_menus.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
<odoo>
22
<menuitem id="estate_menu_root" name="Real Estate" />
3-
43
<menuitem id="menu_estate_advertisements"
54
name="Advertisements"
65
parent="estate_menu_root" />
7-
86
<menuitem id="menu_estate_property_action"
97
name="Properties"
108
parent="menu_estate_advertisements"
119
action="action_estate_property" />
12-
1310
<menuitem id="menu_estate_settings"
1411
name="Settings"
1512
parent="estate_menu_root" />
16-
1713
<menuitem id="menu_estate_property_type_action_settings"
1814
name="Property Types"
1915
parent="menu_estate_settings"
2016
action="estate_property_type_action" />
21-
2217
<menuitem id="menu_estate_property_tag_action_settings"
2318
name="Property Tags"
2419
parent="menu_estate_settings"

estate/views/estate_property_offer_views.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
<field name="name">estate.property.offer.list</field>
44
<field name="model">estate.property.offer</field>
55
<field name="arch" type="xml">
6-
<list>
6+
<list decoration-danger="status == 'refused'"
7+
decoration-success="status == 'accepted'" editable="bottom">
78
<field name="price" />
89
<field name="partner_id" />
9-
<field name="status" />
10+
<field name="status" invisible="1" />
1011
<field name="validity" />
1112
<field name="date_deadline" />
12-
<button name="action_accept" type="object" string="Accept" icon="fa-check"/>
13-
<button name="action_refuse" type="object" string="Refuse" icon="fa-times"/>
13+
<button name="action_accept" type="object" string="Accept" icon="fa-check"
14+
invisible="status in ['accepted', 'refused']" />
15+
<button name="action_refuse" type="object" string="Refuse" icon="fa-times"
16+
invisible="status in ['accepted', 'refused']" />
1417
</list>
1518
</field>
1619
</record>
@@ -33,4 +36,3 @@
3336
</field>
3437
</record>
3538
</odoo>
36-

estate/views/estate_property_tag_views.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,14 @@
44
<field name="res_model">estate.property.tag</field>
55
<field name="view_mode">list,form</field>
66
</record>
7-
</odoo>
7+
8+
<record id="estate_property_tag_tree" model="ir.ui.view">
9+
<field name="name">estate.property.tag.list</field>
10+
<field name="model">estate.property.tag</field>
11+
<field name="arch" type="xml">
12+
<list string="Property Tags" editable="top">
13+
<field name="name"/>
14+
</list>
15+
</field>
16+
</record>
17+
</odoo>

estate/views/estate_property_type_views.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,40 @@
44
<field name="res_model">estate.property.type</field>
55
<field name="view_mode">list,form</field>
66
</record>
7+
8+
<record id="estate_property_type_form_view" model="ir.ui.view">
9+
<field name="name">estate.property.type.form</field>
10+
<field name="model">estate.property.type</field>
11+
<field name="arch" type="xml">
12+
<form string="Property Type">
13+
<sheet>
14+
<group>
15+
<field name="name" />
16+
</group>
17+
<notebook>
18+
<page string="Properties">
19+
<field name="property_ids">
20+
<list>
21+
<field name="name" />
22+
<field name="expected_price" />
23+
<field name="state" />
24+
</list>
25+
</field>
26+
</page>
27+
</notebook>
28+
</sheet>
29+
</form>
30+
</field>
31+
</record>
32+
33+
<record id="estate_property_type_list_view" model="ir.ui.view">
34+
<field name="name">estate.property.type.list</field>
35+
<field name="model">estate.property.type</field>
36+
<field name="arch" type="xml">
37+
<list>
38+
<field name="sequence" widget="handle"/>
39+
<field name="name" />
40+
</list>
41+
</field>
42+
</record>
743
</odoo>

estate/views/estate_property_views.xml

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,26 @@
88
Create a new property
99
</p>
1010
</field>
11+
<field name="context">{'search_default_available_properties': 1}</field>
1112
</record>
1213

1314
<record id="estate_property_view_list" model="ir.ui.view">
1415
<field name="name">estate.property.view.list</field>
1516
<field name="model">estate.property</field>
1617
<field name="arch" type="xml">
17-
<list string="lists">
18+
<list string="lists"
19+
decoration-success="state == 'offer_received' or state == 'offer_accepted'"
20+
decoration-bf="state == 'offer_accepted'"
21+
decoration-muted="state == 'sold'">
1822
<field name="name" />
1923
<field name="postcode" />
2024
<field name="bedrooms" />
2125
<field name="living_area" />
2226
<field name="expected_price" />
2327
<field name="selling_price" />
24-
<field name="date_availability" />
28+
<field name="date_availability" optional="hide" />
2529
<field name="property_type_id" />
26-
<field name="tag_ids" widget="many2many_tags" />
30+
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}" />
2731
</list>
2832
</field>
2933
</record>
@@ -34,18 +38,24 @@
3438
<field name="arch" type="xml">
3539
<form string="form">
3640
<header>
37-
<button name="action_sold" type="object" string="Sold" />
38-
<button name="action_cancel" type="object" string="Cancel" />
41+
<button name="action_sold" type="object" string="Sold"
42+
invisible="state in ['sold', 'canceled']" />
43+
<button name="action_cancel" type="object" string="Cancel"
44+
invisible="state in ['sold', 'canceled']" />
45+
<field name="state" widget="statusbar"
46+
statusbar_visible="new,offer_received,offer_accepted,sold,cancelled" />
3947
</header>
4048
<sheet>
4149
<group>
4250
<group>
4351
<field name="name" />
4452
<field name="postcode" />
4553
<field name="date_availability" />
46-
<field name="property_type_id" />
54+
<field name="property_type_id"
55+
options="{'no_create': true, 'no_edit': true}" />
4756
<field name="state" />
48-
<field name="tag_ids" widget="many2many_tags" />
57+
<field name="tag_ids" widget="many2many_tags"
58+
options="{'color_field': 'color'}" />
4959
<field name="best_price" />
5060
</group>
5161
<group>
@@ -56,8 +66,8 @@
5666
<field name="facades" />
5767
<field name="garage" />
5868
<field name="garden" />
59-
<field name="garden_area" />
60-
<field name="garden_orientation" />
69+
<field name="garden_area" invisible="not garden" />
70+
<field name="garden_orientation" invisible="not garden" />
6171
<field name="total_area" />
6272
</group>
6373
</group>
@@ -67,7 +77,8 @@
6777
</page>
6878

6979
<page string="Offers">
70-
<field name="offer_ids">
80+
<field name="offer_ids"
81+
readonly="state in ['offer_accepted', 'sold', 'canceled']">
7182
</field>
7283
</page>
7384

@@ -91,13 +102,17 @@
91102
<field name="name" />
92103
<field name="postcode" />
93104
<field name="expected_price" />
94-
<field name="property_type_id" />
105+
<field
106+
name="property_type_id" />
95107
<filter
96108
string="Available"
97109
name="available_properties"
98-
domain="['|', ('state', '=', 'New'), ('state', '=', 'Offer Received')]" />
99-
<filter string="Postcode" name="group_by_postcode"
110+
domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]" />
111+
<filter
112+
string="Postcode" name="group_by_postcode"
100113
context="{'group_by': 'postcode'}" />
114+
<field name="living_area"
115+
filter_domain="[('living_area', '>=', self)]" />
101116
</search>
102117
</field>
103118
</record>

0 commit comments

Comments
 (0)