@@ -12,7 +12,7 @@ class EstateProperty(models.Model):
1212 description = fields .Text ()
1313 postcode = fields .Char ()
1414 date_availability = fields .Date (
15- copy = False , default = datetime .now () + relativedelta (months = 3 )
15+ copy = False , default = lambda self : datetime .now () + relativedelta (months = 3 )
1616 )
1717 expected_price = fields .Float (required = True )
1818 selling_price = fields .Float (readonly = True , copy = False )
@@ -53,7 +53,7 @@ class EstateProperty(models.Model):
5353 buyer_id = fields .Many2one ("res.partner" , string = "Buyer" , copy = False )
5454 tag_ids = fields .Many2many ("estate_property_tag" )
5555 offer_ids = fields .One2many ("estate_property_offer" , "property_id" , string = "Offers" )
56- total_area = fields .Integer ("Total Area (sqm)" , compute = "_compute_area " )
56+ total_area = fields .Integer ("Total Area (sqm)" , compute = "_compute_total_area " )
5757 best_price = fields .Float ("Best Price" , compute = "_compute_best_price" )
5858
5959 _check_expected_price = models .Constraint (
@@ -64,18 +64,14 @@ class EstateProperty(models.Model):
6464 )
6565
6666 @api .depends ("living_area" , "garden_area" )
67- def _compute_area (self ):
67+ def _compute_total_area (self ):
6868 for record in self :
6969 record .total_area = record .living_area + record .garden_area
7070
7171 @api .depends ("offer_ids.price" )
7272 def _compute_best_price (self ):
7373 for record in self :
74- record .best_price = (
75- 0
76- if len (record .offer_ids ) == 0
77- else max (offer .price for offer in record .offer_ids )
78- )
74+ record .best_price = max (record .offer_ids .mapped ("price" ) or [0 ])
7975
8076 @api .onchange ("garden" )
8177 def _onchange_garden (self ):
0 commit comments