mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
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:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user