diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 3af605cfc..e0bcf37a2 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -977,7 +977,8 @@ class PropertyLeaseContract(models.Model): bank_accounts = self.env['property.bank.line'].search([ ('tenant_id', '=', self.lessee_id.id) ]).mapped('bank') - bank_accounts = [acc for acc in bank_accounts if acc][0] + filtered_accounts = [acc for acc in bank_accounts if acc] + bank_accounts = filtered_accounts[0] if filtered_accounts else None end_date = self.contract_id.actual_end_time + timedelta(days=1) start_time = f"{end_date} 09:00:00" bank_id = self.env['property.bank.statements'].sudo().create({ diff --git a/yuthon_property_approval/models/property_lease_renewal.py b/yuthon_property_approval/models/property_lease_renewal.py index 464fa35ff..e6fa40c7f 100644 --- a/yuthon_property_approval/models/property_lease_renewal.py +++ b/yuthon_property_approval/models/property_lease_renewal.py @@ -294,7 +294,8 @@ class PropertyLeaseRenewal(models.Model): bank_accounts = self.env['property.bank.line'].search([ ('tenant_id', '=', rec.lessee_id.id) ]).mapped('bank') - bank_accounts = [acc for acc in bank_accounts if acc][0] + filtered_accounts = [acc for acc in bank_accounts if acc] + bank_accounts = filtered_accounts[0] if filtered_accounts else None rec.contract_id.write({ 'actual_end_time': rec.early_quitting_date }) @@ -372,7 +373,8 @@ class PropertyLeaseRenewal(models.Model): bank_accounts = self.env['property.bank.line'].search([ ('tenant_id', '=', rec.lessee_id.id) ]).mapped('bank') - bank_accounts = [acc for acc in bank_accounts if acc][0] + filtered_accounts = [acc for acc in bank_accounts if acc] + bank_accounts = filtered_accounts[0] if filtered_accounts else None rec.contract_id.write({ 'actual_end_time': rec.early_quitting_date })