Renamed the new_id() utility to new_pk() in the Mia core application.
This commit is contained in:
parent
aefb5cc091
commit
6e49443b88
@ -27,7 +27,7 @@ from django.utils.translation import pgettext
|
|||||||
|
|
||||||
from accounting.models import Account, Transaction, Record
|
from accounting.models import Account, Transaction, Record
|
||||||
from mia_core.period import Period
|
from mia_core.period import Period
|
||||||
from mia_core.utils import new_id
|
from mia_core.utils import new_pk
|
||||||
|
|
||||||
|
|
||||||
class ReportUrl:
|
class ReportUrl:
|
||||||
@ -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(pk=new_id(Account), parent=parent, code=code,
|
Account(pk=new_pk(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(pk=new_id(Transaction), date=date, ord=order,
|
transaction = Transaction(pk=new_pk(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(pk=new_id(Record), is_credit=False,
|
transaction.record_set.create(pk=new_pk(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(pk=new_id(Record), is_credit=True,
|
transaction.record_set.create(pk=new_pk(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,
|
||||||
|
@ -26,7 +26,7 @@ from django.db.models import Model, Q
|
|||||||
from django.utils.translation import pgettext, get_language
|
from django.utils.translation import pgettext, get_language
|
||||||
|
|
||||||
|
|
||||||
def new_id(cls):
|
def new_pk(cls):
|
||||||
"""Finds a random ID that does not conflict with the existing data records.
|
"""Finds a random ID that does not conflict with the existing data records.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user