Changed the use of the sn field with pk.

This commit is contained in:
依瑪貓 2020-07-23 23:20:10 +08:00
parent 1dcbd37fbd
commit aefb5cc091
3 changed files with 6 additions and 6 deletions

View File

@ -193,7 +193,7 @@ class TransactionConverter:
Transaction: The account. Transaction: The account.
""" """
try: try:
return Transaction.objects.get(sn=value) return Transaction.objects.get(pk=value)
except Transaction.DoesNotExist: except Transaction.DoesNotExist:
raise ValueError raise ValueError

View File

@ -50,7 +50,7 @@ class Command(BaseCommand):
if input().lower() not in ("y", "yes"): if input().lower() not in ("y", "yes"):
return return
user = User(sn=923153018, login_id="imacat", user = User(pk=923153018, login_id="imacat",
password="5486b64881adaf7bc1485cc26e57e51e", name="依瑪貓", password="5486b64881adaf7bc1485cc26e57e51e", name="依瑪貓",
is_disabled=False, is_deleted=False) is_disabled=False, is_deleted=False)
user.created_by = user user.created_by = user

View File

@ -134,7 +134,7 @@ class Populator:
code = str(code) code = str(code)
parent = None if len(code) == 1\ parent = None if len(code) == 1\
else Account.objects.get(code=code[:-1]) else Account.objects.get(code=code[:-1])
Account(sn=new_id(Account), parent=parent, code=code, Account(pk=new_id(Account), parent=parent, code=code,
title_zh_hant=data[1], title_en=data[2], title_zh_hant=data[1], title_en=data[2],
title_zh_hans=data[3], title_zh_hans=data[3],
created_by=self.user, updated_by=self.user).save() created_by=self.user, updated_by=self.user).save()
@ -153,7 +153,7 @@ class Populator:
if isinstance(date, int): if isinstance(date, int):
date = timezone.localdate() + timezone.timedelta(days=date) date = timezone.localdate() + timezone.timedelta(days=date)
order = Transaction.objects.filter(date=date).count() + 1 order = Transaction.objects.filter(date=date).count() + 1
transaction = Transaction(sn=new_id(Transaction), date=date, ord=order, transaction = Transaction(pk=new_id(Transaction), date=date, ord=order,
created_by=self.user, updated_by=self.user) created_by=self.user, updated_by=self.user)
transaction.save() transaction.save()
order = 1 order = 1
@ -163,7 +163,7 @@ class Populator:
account = Account.objects.get(code=account) account = Account.objects.get(code=account)
elif isinstance(account, int): elif isinstance(account, int):
account = Account.objects.get(code=str(account)) account = Account.objects.get(code=str(account))
transaction.record_set.create(sn=new_id(Record), is_credit=False, transaction.record_set.create(pk=new_id(Record), is_credit=False,
ord=order, account=account, ord=order, account=account,
summary=data[1], amount=data[2], summary=data[1], amount=data[2],
created_by=self.user, created_by=self.user,
@ -176,7 +176,7 @@ class Populator:
account = Account.objects.get(code=account) account = Account.objects.get(code=account)
elif isinstance(account, int): elif isinstance(account, int):
account = Account.objects.get(code=str(account)) account = Account.objects.get(code=str(account))
transaction.record_set.create(sn=new_id(Record), is_credit=True, transaction.record_set.create(pk=new_id(Record), is_credit=True,
ord=order, account=account, ord=order, account=account,
summary=data[1], amount=data[2], summary=data[1], amount=data[2],
created_by=self.user, created_by=self.user,