diff --git a/yuthon_property/models/yuthon_property.py b/yuthon_property/models/yuthon_property.py index 9fb1042b3..056e5db48 100644 --- a/yuthon_property/models/yuthon_property.py +++ b/yuthon_property/models/yuthon_property.py @@ -108,11 +108,12 @@ class YuthonProperty(models.Model): for prop in rentable_properties: contract_lines = self.env['property.lease.contract.line'].search([ ('address_id', '=', prop.id), + ('lease_id.is_contract', '=', False), ]) if contract_lines: sorted_lines = sorted( contract_lines, - key=lambda line: line.lease_id.actual_end_time, + key=lambda line: line.lease_id.actual_end_time or date.max, reverse=True ) lease_id = sorted_lines[0]