@@ -16,61 +16,23 @@ class EstateProperty(models.Model):
16
16
# -----------------------------
17
17
# Field Declarations
18
18
# -----------------------------
19
- name = fields .Char (
20
- string = 'Title' ,
21
- required = True ,
22
- help = 'Title or name of the property.'
23
- )
24
- description = fields .Text (
25
- string = 'Description' ,
26
- help = 'Detailed description of the property.'
27
- )
28
- postcode = fields .Char (
29
- string = 'Postcode' ,
30
- help = 'Postal code of the property location.'
31
- )
19
+ name = fields .Char (string = 'Title' , required = True , help = 'Title or name of the property.' )
20
+ description = fields .Text (string = 'Description' , help = 'Detailed description of the property.' )
21
+ postcode = fields .Char (string = 'Postcode' , help = 'Postal code of the property location.' )
32
22
date_availability = fields .Date (
33
23
string = 'Availability From' ,
34
24
copy = False ,
35
25
default = (date .today () + relativedelta (months = 3 )),
36
26
help = 'Date from which the property will be available.'
37
27
)
38
- expected_price = fields .Float (
39
- string = 'Expected Price' ,
40
- required = True ,
41
- help = 'Price expected by the seller for this property.'
42
- )
43
- selling_price = fields .Float (
44
- string = 'Selling Price' ,
45
- readonly = True ,
46
- copy = False ,
47
- help = 'Final selling price once the property is sold.'
48
- )
49
- bedrooms = fields .Integer (
50
- string = 'Bedrooms' ,
51
- default = 2 ,
52
- help = 'Number of bedrooms in the property.'
53
- )
54
- living_area = fields .Integer (
55
- string = 'Living Area (sqm)' ,
56
- help = 'Living area size in square meters.'
57
- )
58
- facades = fields .Integer (
59
- string = 'Facades' ,
60
- help = 'Number of facades of the property.'
61
- )
62
- garage = fields .Integer (
63
- string = 'Garage' ,
64
- help = 'Number of garage spaces.'
65
- )
66
- garden = fields .Boolean (
67
- string = 'Garden' ,
68
- help = 'Whether the property has a garden.'
69
- )
70
- garden_area = fields .Integer (
71
- string = 'Garden Area (sqm)' ,
72
- help = 'Size of the garden area in square meters.'
73
- )
28
+ expected_price = fields .Float (string = 'Expected Price' , required = True , help = 'Price expected by the seller for this property.' )
29
+ selling_price = fields .Float (string = 'Selling Price' , readonly = True , copy = False , help = 'Final selling price once the property is sold.' )
30
+ bedrooms = fields .Integer (string = 'Bedrooms' , default = 2 , help = 'Number of bedrooms in the property.' )
31
+ living_area = fields .Integer (string = 'Living Area (sqm)' , help = 'Living area size in square meters.' )
32
+ facades = fields .Integer (string = 'Facades' , help = 'Number of facades of the property.' )
33
+ garage = fields .Integer (string = 'Garage' , help = 'Number of garage spaces.' )
34
+ garden = fields .Boolean (string = 'Garden' , help = 'Whether the property has a garden.' )
35
+ garden_area = fields .Integer (string = 'Garden Area (sqm)' , help = 'Size of the garden area in square meters.' )
74
36
garden_orientation = fields .Selection (
75
37
string = 'Garden Orientation' ,
76
38
selection = [
@@ -79,9 +41,7 @@ class EstateProperty(models.Model):
79
41
('east' , 'East' ),
80
42
('west' , 'West' ),
81
43
],
82
- default = 'north' ,
83
- help = 'Direction the garden faces.'
84
- )
44
+ default = 'north' , help = 'Direction the garden faces.' )
85
45
state = fields .Selection (
86
46
string = 'Status' ,
87
47
selection = [
@@ -91,51 +51,20 @@ class EstateProperty(models.Model):
91
51
('sold' , 'Sold' ),
92
52
('cancelled' , 'Cancelled' ),
93
53
],
94
- required = True ,
95
- copy = False ,
96
- default = 'new' ,
97
- help = 'Current status of the property.'
98
- )
99
- active = fields .Boolean (
100
- string = 'Active' ,
101
- default = True ,
102
- help = 'Whether the property is active and visible.'
103
- )
104
- property_type_id = fields .Many2one (
105
- 'estate.property.type' ,
106
- string = 'Property Type' ,
107
- help = 'Type or category of the property.'
108
- )
109
- buyer_id = fields .Many2one (
110
- 'res.partner' ,
111
- string = 'Buyer' ,
112
- copy = False ,
113
- help = 'Partner who bought the property.'
114
- )
115
- sales_id = fields .Many2one (
116
- 'res.users' ,
117
- string = 'Salesman' ,
118
- default = lambda self : self .env .user ,
119
- help = 'Salesperson responsible for the property.'
120
- )
121
- tag_ids = fields .Many2many (
122
- 'estate.property.tag' ,
123
- string = 'Tags' ,
124
- help = 'Tags to classify the property.'
125
- )
126
- offer_ids = fields .One2many (
127
- 'estate.property.offer' ,
128
- 'property_id' ,
129
- string = 'Offers' ,
130
- help = 'Offers made on this property.'
131
- )
54
+ required = True , copy = False , default = 'new' , help = 'Current status of the property.'
55
+ )
56
+ active = fields .Boolean (string = 'Active' , default = True , help = 'Whether the property is active and visible.' )
57
+ property_type_id = fields .Many2one ('estate.property.type' , string = 'Property Type' , help = 'Type or category of the property.' )
58
+ buyer_id = fields .Many2one ('res.partner' , string = 'Buyer' , copy = False , help = 'Partner who bought the property.' )
59
+ sales_id = fields .Many2one ('res.users' , string = 'Salesman' , default = lambda self : self .env .user , help = 'Salesperson responsible for the property.' )
60
+ tag_ids = fields .Many2many ('estate.property.tag' , string = 'Tags' , help = 'Tags to classify the property.' )
61
+ offer_ids = fields .One2many ('estate.property.offer' , 'property_id' , string = 'Offers' , help = 'Offers made on this property.' )
132
62
133
63
# -----------------------------
134
64
# SQL Constraints
135
65
# -----------------------------
136
66
_sql_constraints = [
137
- ('check_expected_price' , 'CHECK(expected_price > 0)' , 'Expected price cannot be negative.' ),
138
- ('check_selling_price' , 'CHECK(selling_price > 0)' , 'Selling price cannot be negative.' ),
67
+ ('check_expected_price' , 'CHECK(expected_price > 0)' , 'Expected price cannot be negative.' )
139
68
]
140
69
141
70
# -----------------------------
@@ -191,23 +120,6 @@ def action_cancel(self):
191
120
# -----------------------------
192
121
# Constraints
193
122
# -----------------------------
194
- @api .constrains ('selling_price' , 'expected_price' )
195
- def _check_selling_price (self ):
196
- """
197
- Ensure selling price is at least 90% of expected price.
198
- Raises ValidationError if condition is not met.
199
- """
200
- for record in self :
201
- if record .selling_price and record .selling_price < 0.9 * record .expected_price :
202
- raise ValidationError (
203
- _ ("The selling price must be at least 90%% of the expected price.\n "
204
- "Expected Price: %(expected).2f\n Selling Price: %(selling).2f" )
205
- % {
206
- 'expected' : record .expected_price ,
207
- 'selling' : record .selling_price
208
- }
209
- )
210
-
211
123
@api .constrains ('selling_price' , 'expected_price' )
212
124
def _check_selling_price_above_90_percent (self ):
213
125
"""
@@ -219,14 +131,14 @@ def _check_selling_price_above_90_percent(self):
219
131
continue
220
132
min_acceptable_price = 0.9 * record .expected_price
221
133
if float_compare (record .selling_price , min_acceptable_price , precision_digits = 2 ) < 0 :
222
- raise ValidationError (
223
- _ ( "The selling price must be at least 90%% of the expected price.\n "
224
- "Expected Price: %(expected_price).2f\n Selling Price: %(selling_price).2f" )
225
- % {
134
+ raise ValidationError (_ (
135
+ "The selling price must be at least 90%% of the expected price.\n "
136
+ "Expected Price: %(expected_price).2f\n Selling Price: %(selling_price).2f" ,
137
+ {
226
138
'expected_price' : record .expected_price ,
227
139
'selling_price' : record .selling_price
228
140
}
229
- )
141
+ ))
230
142
231
143
@api .ondelete (at_uninstall = False )
232
144
def _check_can_be_deleted (self ):
@@ -236,4 +148,4 @@ def _check_can_be_deleted(self):
236
148
"""
237
149
for record in self :
238
150
if record .state not in ['new' , 'cancelled' ]:
239
- raise UserError (" You can only delete properties that are New or Cancelled." )
151
+ raise UserError (' You can only delete properties that are New or Cancelled.' )
0 commit comments