Skip to content

Commit 5c94fc5

Browse files
committed
[FIX] real_estate: Apply coding and security guidelines across modules
- Renamed methods and variables to follow naming conventions - Reviewed and aligned code with Odoo coding standards - Studied and applied key security practices: - Avoided unsafe public methods - Prevented direct SQL and ensured ORM usage - Avoided unsafe attribute access patterns
1 parent 7a4879a commit 5c94fc5

12 files changed

+59
-81
lines changed

estate_account/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
13
from . import models

estate_account/__manifest__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
"name": "Estate Account",
33
"version": "1.0",
44
"depends": ["real_estate", "account"],
5-
"author": "",
65
"category": "Accounts for Estate",
7-
"data": [],
86
"license": "LGPL-3",
97
"installable": True,
108
"application": True,

real_estate/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
13
from . import models

real_estate/__manifest__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "Dream Homes",
33
"version": "1.0",
44
"depends": ["base"],
5-
"author": "Megha Tulsyani",
6-
"category": "Ecommerce For Properties",
5+
"category": "Real Estate/Brokerage",
76
"data": [
7+
"security/estate_property_security.xml",
88
"security/ir.model.access.csv",
99
"views/estate_property_views.xml",
1010
"views/estate_property_offer_views.xml",

real_estate/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
13
from . import estate_property
24
from . import estate_property_offers
35
from . import estate_property_tags

real_estate/models/estate_property.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ class EstateProperty(models.Model):
99
_description = "This is a real estate module"
1010
_order = "id desc"
1111

12-
name = fields.Char(required=True)
13-
description = fields.Text()
14-
postcode = fields.Char()
15-
expected_price = fields.Float(required=True)
16-
selling_price = fields.Float(readonly=True, copy=False)
17-
bedrooms = fields.Integer(default=2)
12+
name = fields.Char(string="Property Name", required=True)
13+
description = fields.Text(string="Description")
14+
postcode = fields.Char(string="Postcode")
15+
expected_price = fields.Float(string="Expected Price", required=True)
16+
selling_price = fields.Float(string="Selling Price", readonly=True, copy=False)
17+
bedrooms = fields.Integer(string="Total Bedrooms", default=2)
1818
living_area = fields.Integer(string="Living Area (sqm)")
19-
facades = fields.Integer()
20-
garage = fields.Boolean()
21-
garden = fields.Boolean()
22-
garden_area = fields.Integer()
23-
active = fields.Boolean(default=True)
19+
facades = fields.Integer(string="Facades")
20+
garage = fields.Boolean(string="Garage")
21+
garden = fields.Boolean(string="Garden")
22+
garden_area = fields.Integer(string="Garden Area (sqm)")
23+
active = fields.Boolean(string="Is Active", default=True)
2424
buyer_id = fields.Many2one(comodel_name="res.partner", string="Buyer", copy=False)
2525
total_area = fields.Float(compute="_compute_total_area", string="Total Area")
2626
best_offer = fields.Float(compute="_compute_best_price", string="Best Offer")
@@ -51,7 +51,8 @@ class EstateProperty(models.Model):
5151
("south", "South"),
5252
("east", "East"),
5353
("west", "West"),
54-
]
54+
],
55+
string="Garden Orientation",
5556
)
5657
state = fields.Selection(
5758
selection=[
@@ -64,7 +65,15 @@ class EstateProperty(models.Model):
6465
copy=False,
6566
required=True,
6667
default="new",
68+
string="State",
6769
)
70+
_sql_constraints = [
71+
(
72+
"check_expected_price_positive",
73+
"CHECK(expected_price > 0)",
74+
"Expected price must be strictly positive.",
75+
),
76+
]
6877

6978
@api.depends("living_area", "garden_area")
7079
def _compute_total_area(self):
@@ -90,7 +99,6 @@ def action_sold(self):
9099
for record in self:
91100
if not record.state == "offer_accepted":
92101
raise UserError("Accept an offer first")
93-
94102
if record.state == "cancelled":
95103
raise UserError("You cannot mark a cancelled property as sold.")
96104
record.state = "sold"
@@ -101,20 +109,11 @@ def action_cancel(self):
101109
raise UserError("You cannot mark a sold property as cancelled.")
102110
record.state = "cancelled"
103111

104-
_sql_constraints = [
105-
(
106-
"check_expected_price_positive",
107-
"CHECK(expected_price > 0)",
108-
"Expected price must be strictly positive.",
109-
),
110-
]
111-
112112
@api.constrains("expected_price", "selling_price")
113113
def _check_selling_price(self):
114114
for record in self:
115115
if float_is_zero(record.selling_price, precision_digits=2):
116116
continue
117-
118117
min_price = record.expected_price * 0.9
119118
if float_compare(record.selling_price, min_price, precision_digits=2) < 0:
120119
raise ValidationError(

real_estate/models/estate_property_types.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@ class EstatePropertyTypes(models.Model):
88

99
name = fields.Char(required=True)
1010
sequence = fields.Integer(default=1)
11-
offer_ids = fields.One2many(
12-
comodel_name="estate.property.offers", inverse_name="property_type_id"
13-
)
14-
offer_count = fields.Integer(
15-
string="Number of Offers", compute="_compute_offer_count"
16-
)
17-
property_ids = fields.One2many(
18-
"estate.property", "estate_property_type_id", string="Properties"
19-
)
11+
offer_ids = fields.One2many(comodel_name="estate.property.offers", inverse_name="property_type_id")
12+
offer_count = fields.Integer(string="Number of Offers", compute="_compute_offer_count")
13+
property_ids = fields.One2many("estate.property", "estate_property_type_id", string="Properties")
14+
2015
_sql_constraints = [
2116
(
2217
"unique_type_name",
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<odoo>
3-
<!-- Root menu -->
4-
<menuitem id="estate_menu_root" name="Real Estate" />
3+
<menuitem id="estate_root_menu" name="Real Estate" />
54

6-
<!-- First level submenu under root -->
7-
<menuitem id="estate_menu_advertisements" name="Advertisements" parent="estate_menu_root" />
8-
<menuitem id="estate_menu_settings" name="Settings" parent="estate_menu_root" />
5+
<menuitem id="estate_menu_advertisements" name="Advertisements" parent="estate_root_menu" />
6+
<menuitem id="estate_menu_settings" name="Settings" parent="estate_root_menu" />
97

10-
<!-- Action menu under first level -->
118
<menuitem id="estate_property_menu_action" parent="estate_menu_advertisements"
12-
action="real_estate_main_action" />
9+
action="estate_property_main_view_action" />
10+
1311
<menuitem id="estate_property_type_menu_action" parent="estate_menu_settings"
14-
action="estate_property_type_action" />
12+
action="estate_property_type_view_action" />
1513
<menuitem id="estate_property_tag_menu_action" parent="estate_menu_settings"
16-
action="estate_property_tag_action" />
17-
14+
action="estate_property_tag_view_action" />
1815
</odoo>

real_estate/views/estate_property_offer_views.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<odoo>
3-
<record id="estate_property_offer_action" model="ir.actions.act_window">
3+
<record id="estate_property_offer_view_action" model="ir.actions.act_window">
44
<field name="name">estate.property.offer.action</field>
55
<field name="res_model">estate.property.offers</field>
66
<field name="view_mode">list,form</field>
77
<field name="domain">[('property_type_id', '=', active_id)]</field>
88
</record>
99

10-
<record id="estate_property_offer_view" model="ir.ui.view">
10+
<record id="estate_property_offer_view_list" model="ir.ui.view">
1111
<field name="name">estate.property.offer.list</field>
1212
<field name="model">estate.property.offers</field>
1313
<field name="arch" type="xml">
14-
<list editable="bottom"
15-
decoration-danger="status == 'refused'"
16-
decoration-success="status == 'accepted'">
14+
<list editable="bottom" decoration-danger="status == 'refused'" decoration-success="status == 'accepted'">
1715
<field name="price" />
1816
<field name="partner_id" />
1917
<field name="status" />
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<odoo>
3-
4-
<record id="estate_property_tag_action" model="ir.actions.act_window">
3+
<record id="estate_property_tag_view_action" model="ir.actions.act_window">
54
<field name="name">Property Tags</field>
65
<field name="res_model">estate.property.tags</field>
76
<field name="view_mode">list,form</field>
87
<field name="help" type="html">
9-
<p class="o_view_nocontent_smiling_face">
10-
Define a new Property Tag
11-
</p>
12-
<p>
13-
Create a Propety tag and link it to as many properties as needed.
14-
</p>
8+
<p class="o_view_nocontent_smiling_face">Define a new Property Tag</p>
9+
<p>Create a Propety tag and link it to as many properties as needed.</p>
1510
</field>
1611
</record>
1712

18-
<record id="view_estate_property_tag_list" model="ir.ui.view">
13+
<record id="estate_property_tag_view_list" model="ir.ui.view">
1914
<field name="name">estate.property.tag.list</field>
2015
<field name="model">estate.property.tags</field>
2116
<field name="arch" type="xml">
@@ -24,5 +19,4 @@
2419
</list>
2520
</field>
2621
</record>
27-
2822
</odoo>

0 commit comments

Comments
 (0)