diff --git a/models/financial_contract_guarantee.py b/models/financial_contract_guarantee.py index 8b0788f67c8f154b753dad878310ccc1f8045778..36b522f52166c54bbcda4dd1fccc7b459ecabcb9 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(