Fixed the CashDefaultView to allow default cash account as 0 in the accounting application.

This commit is contained in:
依瑪貓 2020-08-11 18:36:47 +08:00
parent 9973fc851c
commit 578e934b9f

View File

@ -59,8 +59,11 @@ class CashDefaultView(RedirectView):
pattern_name = "accounting:cash" pattern_name = "accounting:cash"
def get_redirect_url(self, *args, **kwargs): def get_redirect_url(self, *args, **kwargs):
kwargs["account"] = Account.objects.get( code = settings.ACCOUNTING["DEFAULT_CASH_ACCOUNT"]
code=settings.ACCOUNTING["DEFAULT_CASH_ACCOUNT"]) kwargs["account"] = Account(
code="0",
title=_("current assets and liabilities"),
) if code == "0" else Account.objects.get(code=code)
kwargs["period"] = Period.default_spec() kwargs["period"] = Period.default_spec()
return super().get_redirect_url(*args, **kwargs) return super().get_redirect_url(*args, **kwargs)