[IMP] Bill name in a document

This commit is contained in:
Stepan Savelyev 2020-07-10 12:48:33 +05:00
parent c6cd8015f5
commit 755658a6f9

View File

@ -123,16 +123,25 @@ class ContractOrderAnnex(models.Model, IDocument, Extension):
} }
def get_name_by_document_template(self, document_template_id): 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
return ( return (
{ {
"bill": "{name}", "bill": "{bill_name}",
"specification": "{counter} {name}", "specification": "{counter} {name}",
"approval_list": "{counter}.1 {name}-1", "approval_list": "{counter}.1 {name}-1",
"act_at": "{counter}.2 {name}-2", "act_at": "{counter}.2 {name}-2",
"act_ad": "{counter}.3 {name}-3", "act_ad": "{counter}.3 {name}-3",
} }
.get(document_template_id.document_type_name, "Unknown") .get(document_template_id.document_type_name, "Unknown")
.format(counter=self.counter, name=self.name,) .format(
counter=self.counter,
name=self.name,
bill_name=(bill_name or "Счёт отсутствует"),
)
) )
def get_filename_by_document_template(self, document_template_id): def get_filename_by_document_template(self, document_template_id):