Merge pull request !7214 from dev
This commit is contained in:
李鹏宇
2025-12-23 10:20:07 +00:00
committed by Gitee
+15 -3
View File
@@ -100,12 +100,24 @@ class YuthonProperty(models.Model):
today = date.today()
current_year = today.year
current_month = today.month
rentable_properties = self.search([('purpose_id.name', '=', '可租')])
rentable_properties = self.env["yuthon.property"].browse(
self._context.get('active_ids', self._context.get('active_id')))
# rentable_properties = self.search([('purpose_id.name', '=', '可租')])
for prop in rentable_properties:
lease_id = self.env['property.lease.contract.line'].search([
contract_lines = self.env['property.lease.contract.line'].search([
('address_id', '=', prop.id),
('lease_id.contact_state', '=', 'ing')
], limit=1)
])
if contract_lines:
sorted_lines = sorted(
contract_lines,
key=lambda line: line.lease_id.actual_end_time,
reverse=True
)
lease_id = sorted_lines[0]
else:
lease_id = self.env['property.lease.contract.line']
if not lease_id:
prop.write({'property_state': 'vacant'})
continue