From 96805322de91dc1b3315dc0cb1e1120f0c1fe0a0 Mon Sep 17 00:00:00 2001 From: tec Date: Wed, 5 Nov 2014 16:26:27 +0000 Subject: [PATCH] Fixed issues with importer and datetime conversion Fixed issue with models.VatRate.__unicode__() with datetime and decimal fields Imported VatRates --- RIGS/importer.py | 7 ++++--- RIGS/models.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/RIGS/importer.py b/RIGS/importer.py index 9d6f86da..6c72c807 100644 --- a/RIGS/importer.py +++ b/RIGS/importer.py @@ -12,7 +12,7 @@ from django.db.utils import ConnectionDoesNotExist from django.db import transaction from RIGS import models import reversion - +from datetime import datetime def setup_cursor(): try: @@ -79,7 +79,8 @@ def import_vat_rates(): sql = """SELECT `id`, `start_date`, `start_time`, `comment`, `rate` FROM `vat_rates`""" cursor.execute(sql) for row in cursor.fetchall(): - object, created = models.VatRate.objects.get_or_create(pk=row[0], start_at=row[1] + " " + row[2], + start_at = datetime.combine(row[1], row[2]) + object, created = models.VatRate.objects.get_or_create(pk=row[0], start_at=start_at, comment=row[3], rate=row[4]) if created: print("Created: " + object.__unicode__()) @@ -96,4 +97,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/RIGS/models.py b/RIGS/models.py index d86c8e07..dca98de2 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -69,4 +69,4 @@ class VatRate(models.Model, RevisionMixin): comment = models.CharField(max_length=255) def __unicode__(self): - return self.comment + " " + self.start_at + " @ " + self.rate \ No newline at end of file + return self.comment + " " + str(self.start_at) + " @ " + str(self.rate)