Skip to content

Commit b02961b

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 b02961b

18 files changed

+76
-83
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
13
{
24
"name": "Estate Account",
35
"version": "1.0",
46
"depends": ["real_estate", "account"],
5-
"author": "",
67
"category": "Accounts for Estate",
7-
"data": [],
88
"license": "LGPL-3",
99
"installable": True,
1010
"application": True,

estate_account/models/__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 estate_property

estate_account/models/estate_property.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 odoo import Command, models
24

35

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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
13
{
24
"name": "Dream Homes",
35
"version": "1.0",
46
"depends": ["base"],
5-
"author": "Megha Tulsyani",
6-
"category": "Ecommerce For Properties",
7+
"category": "Real Estate/Brokerage",
78
"data": [
89
"security/ir.model.access.csv",
910
"views/estate_property_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: 23 additions & 22 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 odoo import api, fields, models
24
from dateutil.relativedelta import relativedelta
35
from odoo.exceptions import UserError, ValidationError
@@ -9,18 +11,18 @@ class EstateProperty(models.Model):
911
_description = "This is a real estate module"
1012
_order = "id desc"
1113

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)
14+
name = fields.Char(string="Property Name", required=True)
15+
description = fields.Text(string="Description")
16+
postcode = fields.Char(string="Postcode")
17+
expected_price = fields.Float(string="Expected Price", required=True)
18+
selling_price = fields.Float(string="Selling Price", readonly=True, copy=False)
19+
bedrooms = fields.Integer(string="Total Bedrooms", default=2)
1820
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)
21+
facades = fields.Integer(string="Facades")
22+
garage = fields.Boolean(string="Garage")
23+
garden = fields.Boolean(string="Garden")
24+
garden_area = fields.Integer(string="Garden Area (sqm)")
25+
active = fields.Boolean(string="Is Active", default=True)
2426
buyer_id = fields.Many2one(comodel_name="res.partner", string="Buyer", copy=False)
2527
total_area = fields.Float(compute="_compute_total_area", string="Total Area")
2628
best_offer = fields.Float(compute="_compute_best_price", string="Best Offer")
@@ -51,7 +53,8 @@ class EstateProperty(models.Model):
5153
("south", "South"),
5254
("east", "East"),
5355
("west", "West"),
54-
]
56+
],
57+
string="Garden Orientation",
5558
)
5659
state = fields.Selection(
5760
selection=[
@@ -64,7 +67,15 @@ class EstateProperty(models.Model):
6467
copy=False,
6568
required=True,
6669
default="new",
70+
string="State",
6771
)
72+
_sql_constraints = [
73+
(
74+
"check_expected_price_positive",
75+
"CHECK(expected_price > 0)",
76+
"Expected price must be strictly positive.",
77+
),
78+
]
6879

6980
@api.depends("living_area", "garden_area")
7081
def _compute_total_area(self):
@@ -90,7 +101,6 @@ def action_sold(self):
90101
for record in self:
91102
if not record.state == "offer_accepted":
92103
raise UserError("Accept an offer first")
93-
94104
if record.state == "cancelled":
95105
raise UserError("You cannot mark a cancelled property as sold.")
96106
record.state = "sold"
@@ -101,20 +111,11 @@ def action_cancel(self):
101111
raise UserError("You cannot mark a sold property as cancelled.")
102112
record.state = "cancelled"
103113

104-
_sql_constraints = [
105-
(
106-
"check_expected_price_positive",
107-
"CHECK(expected_price > 0)",
108-
"Expected price must be strictly positive.",
109-
),
110-
]
111-
112114
@api.constrains("expected_price", "selling_price")
113115
def _check_selling_price(self):
114116
for record in self:
115117
if float_is_zero(record.selling_price, precision_digits=2):
116118
continue
117-
118119
min_price = record.expected_price * 0.9
119120
if float_compare(record.selling_price, min_price, precision_digits=2) < 0:
120121
raise ValidationError(

real_estate/models/estate_property_offers.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 odoo import api, fields, models
24
from odoo.exceptions import UserError
35

real_estate/models/estate_property_tags.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 odoo import models, fields
24

35

0 commit comments

Comments
 (0)