Fixed the logic in the save() method of the Account data model so that the current_user will not override the created_by and updated_by when the current_user was not supplied in the accounting application.

This commit is contained in:
依瑪貓 2020-08-09 18:21:34 +08:00
parent f26b303205
commit 8d33429fef

View File

@ -71,9 +71,9 @@ class Account(DirtyFieldsMixin, models.Model):
else Account.objects.get(code=self.code[:-1])
if self.pk is None:
self.pk = new_pk(Account)
if getattr(self, "created_by", None) is None:
self.created_by = current_user
if getattr(self, "updated_by", None) is None:
if current_user is not None:
self.created_by = current_user
if current_user is not None:
self.updated_by = current_user
with transaction.atomic():
super(Account, self).save(