From 4ea506ffab57ca4d1a0d1a5ee3188a28729f542b Mon Sep 17 00:00:00 2001
From: Hugo Trentesaux <hugo@le-filament.com>
Date: Thu, 5 Jun 2025 16:41:50 +0200
Subject: [PATCH] change state to "done" when line with crdu zero found

---
 models/financial_contract_guarantee.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/models/financial_contract_guarantee.py b/models/financial_contract_guarantee.py
index b1e0129..f30e447 100644
--- a/models/financial_contract_guarantee.py
+++ b/models/financial_contract_guarantee.py
@@ -289,6 +289,9 @@ class FinancialContractGuarantee(models.Model):
                         "amount_received": last_line.amount_received,
                     }
                 )
+                if last_line.remaining_capital == 0:
+                    guarantee.state = "done"
+                    guarantee.external_loan_id.state = "done"
 
     @api.depends("line_ids", "line_ids.commission_amount")
     def _compute_commission_amount(self):
-- 
GitLab