Skip to content

Commit e463e5c

Browse files
committed
[FIX] estate: fixed depreciated sql contraint
-Implemented new sql constraint method.
1 parent d2ac217 commit e463e5c

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

estate/models/estate_property.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,14 @@ def action_sold(self):
9595
raise UserError("A cancelled property cannot be set as sold")
9696
record.state = "sold"
9797

98-
_sql_constraints = [
99-
(
100-
"check_expected_price",
101-
"CHECK(expected_price > 0)",
102-
"The expected price must be strictly positive.",
98+
_constraints = [
99+
models.CheckConstraint(
100+
"expected_price > 0",
101+
message="The expected price must be strictly positive.",
103102
),
104-
(
105-
"check_selling_price_positive",
106-
"CHECK(selling_price >= 0)",
107-
"The selling price must be positive.",
103+
models.CheckConstraint(
104+
"selling_price >= 0",
105+
message="The selling price must be positive.",
108106
),
109107
]
110108

@@ -123,4 +121,3 @@ def _check_selling_price_ratio(self):
123121
raise ValidationError(
124122
"The selling price cannot be lower than 90% of the expected price."
125123
)
126-

0 commit comments

Comments
 (0)