Ejemplo n.º 1
0
def get_exportable_documents(export):
    documents = []
    if 'QUOTATION' in export.documents_types:
        full_export = Quotation.full_export(export.tenant, export.from_date, export.to_date)
        documents.append(full_export)
        serializer = QuotationCSVSerializer()
        documents.append((
            [serializer.serialize(full_export[0])],
            lambda buf: '{0}/{1}.csv'.format(_('Quotations'), _('Quotations')),
            lambda buf: buf
        ))

    if 'INVOICE' in export.documents_types:
        full_export = Invoice.full_export(export.tenant, export.from_date, export.to_date)
        documents.append(full_export)
        serializer = InvoiceCSVSerializer()
        documents.append((
            [serializer.serialize(full_export[0])],
            lambda buf: '{0}/{1}.csv'.format(_('Invoices'), _('Invoices')),
            lambda buf: buf
        ))

    if 'CREDIT_NOTE' in export.documents_types:
        full_export = CreditNote.full_export(export.tenant, export.from_date, export.to_date)
        documents.append(full_export)
        serializer = CreditNoteCSVSerializer()
        documents.append((
            [serializer.serialize(full_export[0])],
            lambda buf: '{0}/{1}.csv'.format(_('Credit notes'), _('Credit notes')),
            lambda buf: buf
        ))
    return documents