diff --git a/accounting/models.py b/accounting/models.py index ce0e95d..2a18fd8 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -22,6 +22,8 @@ from django.conf import settings from django.db import models from django.urls import reverse +from mia_core.utils import get_multi_language_attr + class Subject(models.Model): """An accounting subject.""" @@ -50,7 +52,19 @@ class Subject(models.Model): def __str__(self): """Returns the string representation of this accounting subject.""" - return self.code.__str__() + " " + self.title_zhtw.__str__() + return self.code.__str__() + " " + self.title + + _title = None + + @property + def title(self): + if self._title is None: + self._title = get_multi_language_attr(self, "title") + return self._title + + @title.setter + def title(self, value): + self._title = value class Meta: db_table = "accounting_subjects" @@ -241,7 +255,7 @@ class Record(models.Model): record.""" return "%s %s %s %s" % ( self.transaction.date, - self.subject.title_zhtw, + self.subject.title, self.summary, self.amount) diff --git a/accounting/templates/accounting/cash.html b/accounting/templates/accounting/cash.html index 2847913..d5a1057 100644 --- a/accounting/templates/accounting/cash.html +++ b/accounting/templates/accounting/cash.html @@ -25,7 +25,7 @@ First written: 2020/7/1 {% load accounting %} {% block settings %} - {% blocktrans asvar title with subject=current_subject.title_zhtw period=period.description context "Accounting|" %}Cash Account for {{ subject }} in {{ period }}{% endblocktrans %} + {% blocktrans asvar title with subject=current_subject.title|title period=period.description context "Accounting|" %}Cash Account for {{ subject }} in {{ period }}{% endblocktrans %} {% setvar "title" title %} {% setvar "use_period_chooser" True %} {% endblock %} @@ -63,17 +63,17 @@ First written: 2020/7/1 {% endwith %}