Project

General

Profile

Download (685 Bytes) Statistics
| Branch: | Tag: | Revision:

calebasse / scripts / add_acts_data_to_invoice.py @ 0d4bf0b4

1
import django.core.management
2
import calebasse.settings
3

    
4
django.core.management.setup_environ(calebasse.settings)
5

    
6
from calebasse.facturation.models import Invoice
7

    
8
if __name__ == "__main__":
9
    for invoice in Invoice.objects.all():
10
        if invoice.acts.count() > 0:
11
            acts = invoice.acts.order_by('date')
12
            invoice.first_tag = acts[0].get_hc_tag()
13
            if not invoice.first_tag:
14
                print 'Facture %s avec actes de type indetermine' % invoice.number
15
            invoice.list_dates = '$'.join([act.date.strftime('%d/%m/%Y') for act in acts])
16
            invoice.save()
17
        else:
18
            print 'Facture %s sans actes' % invoice.number
(5-5/47)