diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index f9bda6188..8a37c3cdd 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -2524,19 +2524,11 @@ class PropertyLeaseContractLine(models.Model): @api.depends('address_id', 'address_id.manage_information_ids') def _compute_property_area(self): - today = fields.Date.today() for line in self: - rent_area = 0.0 - if line.address_id: - valid_lines = line.address_id.manage_information_ids.filtered( - lambda r: - r.start_time <= today - and (not r.end_date or r.end_date >= today) - ) - if valid_lines: - rent_area = valid_lines[0].rent_area - line.property_area = rent_area - + line.property_area = 0.0 + if line.address_id and line.address_id.manage_information_ids: + latest_line = line.address_id.manage_information_ids.sorted('id', reverse=True)[0] + line.property_area = latest_line.rent_area def open_record(self): self.ensure_one()