Fixed issues with importer and datetime conversion

Fixed issue with models.VatRate.__unicode__() with datetime and decimal fields

Imported VatRates
This commit is contained in:
tec
2014-11-05 16:26:27 +00:00
parent 1bf5cbaf82
commit 3fbb44a5ad
3 changed files with 5 additions and 4 deletions

View File

@@ -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()
main()

View File

@@ -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
return self.comment + " " + str(self.start_at) + " @ " + str(self.rate)

Binary file not shown.