From 796b2808c1344258e62c9e13ff6fc06c85988e4a Mon Sep 17 00:00:00 2001 From: Hugo Trentesaux <hugo@le-filament.com> Date: Wed, 23 Apr 2025 12:00:59 +0200 Subject: [PATCH] fix bdf scoring crashing creserfi import --- models/financial_contract_guarantee.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/models/financial_contract_guarantee.py b/models/financial_contract_guarantee.py index 8b0788f..36b522f 100644 --- a/models/financial_contract_guarantee.py +++ b/models/financial_contract_guarantee.py @@ -201,9 +201,10 @@ class FinancialContractGuarantee(models.Model): ) def _compute_guarantee_data(self): for guarantee in self: - last_line = guarantee.line_ids.sorted("line_date", reverse=True) - if last_line: - last_line = last_line[0] + with_date = guarantee.line_ids.filtered(lambda x: not not x.line_date) + ordered = with_date.sorted("line_date", reverse=True) + if ordered: + last_line = ordered[0] guarantee.update({"bdf_scoring": last_line.bdf_scoring}) @api.depends( -- GitLab