@@ -0,0 +1,1158 @@
+# -*- coding: utf-8 -*-%0A# Generated by Django 1.11.14 on 2019-01-09 13:53%0Afrom __future__ import unicode_literals%0A%0Afrom django.db import migrations%0A%0A%0Adef forwards(apps, schema_editor):%0A    BillingLog = apps.get_model(%22crm%22, %22BillingLog%22)%0A%0A    for log in BillingLog.objects.all().exclude(log_type='create_note'):%0A        try:%0A            pk, year = log.invoice.invoice_number.split('-')%0A        except ValueError:%0A            print('Skipping %7B%7D'.format(log.invoice.invoice_number))%0A            continue%0A%0A        if year != log.invoice_year:%0A            if len(year) != 4:%0A                print('Skipping %7B%7D'.format(log.invoice.invoice_number))%0A                continue%0A%0A            print('Updated Log year #%7B%7D from %7B%7D to %7B%7D for Invoice: %7B%7D'.format(log.pk, log.invoice_year, year,%0A                                                                              log.invoice.invoice_number))%0A            log.invoice_year = year%0A            log.save()%0A%0A%0Aclass Migration(migrations.Migration):%0A    dependencies = %5B%0A        ('crm', '0008_set_billing_type_1320'),%0A    %5D%0A%0A    operations = %5B%0A        migrations.RunPython(forwards, hints=%7B'target_db': 'default'%7D),%0A    %5D%0A

Fix invoice years