Skip to content

Commit abb9d6b

Browse files
committed
[IMP] Chapter 5: Finally, Some UI to Play With
- The selling price should be read-only (it will be automatically filled in later) - The availability date and the selling price should not be copied when duplicating a record - The default number of bedrooms should be 2 - The default availability date should be in 3 months Added an active field to help filter Added a state field
1 parent e923c22 commit abb9d6b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

estate/models/estate_property.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from calendar import month
2+
13
from odoo import fields, models
24

35
class EstateProperty(models.Model):
@@ -7,10 +9,10 @@ class EstateProperty(models.Model):
79
name = fields.Char(required=True)
810
description = fields.Text(string="Description")
911
postcode = fields.Char(string="Postcode")
10-
date_availability = fields.Date(string="Available From")
12+
date_availability = fields.Date(string="Available From", copy=False, default=fields.Date.add(fields.Date.today(), months=3))
1113
expected_price = fields.Float(string="Expected Price", required=True)
12-
selling_price = fields.Float(string="Selling Price")
13-
bedrooms = fields.Integer(string="Bedrooms")
14+
selling_price = fields.Float(string="Selling Price", readonly=True, copy=False)
15+
bedrooms = fields.Integer(string="Bedrooms", default=2)
1416
living_area = fields.Integer(string="Living Area (sqm)")
1517
facades = fields.Integer(string="Facades")
1618
garage = fields.Boolean(string="Garage")
@@ -21,3 +23,12 @@ class EstateProperty(models.Model):
2123
selection=[('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')],
2224
help="The orientation of the Garden"
2325
)
26+
active = fields.Boolean(default=True)
27+
state = fields.Selection(
28+
string="State",
29+
selection=[('new', 'New'), ('received', 'Offer Received'), ('accepted', 'Offer Accepted'), ('sold', 'Sold'), ('cancelled', 'Cancelled')],
30+
required=True,
31+
copy=False,
32+
default="new",
33+
help="The current state of the property"
34+
)

0 commit comments

Comments
 (0)