From d6c61e137f36ad5aa466519bffb7bd2f064948f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BF=D0=B0=D0=BD=20=D0=A1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=B5=D0=B2?= Date: Mon, 3 Aug 2020 16:24:44 +0500 Subject: [PATCH] [FIX] No bill name in annex_name field --- models/res_partner_contract_annex.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/res_partner_contract_annex.py b/models/res_partner_contract_annex.py index a269968..2f58012 100755 --- a/models/res_partner_contract_annex.py +++ b/models/res_partner_contract_annex.py @@ -123,10 +123,10 @@ class ContractOrderAnnex(models.Model, IDocument, Extension): } def get_name_by_document_template(self, document_template_id): - bill_name = None - for invoice in self.order_id.invoice_ids: - bill_name = invoice.number - break + active_invoices = self.order_id.invoice_ids.filtered( + lambda r: r.state not in ("draft", "cancel") + ) + bill_name = active_invoices and active_invoices[-1].number return ( {