Revised the save() method so that it works both with the current user from the its parameter or from the parameter from the constructor.
This commit is contained in:
parent
bbd3d0e470
commit
88e3637663
@ -71,8 +71,10 @@ class Account(DirtyFieldsMixin, models.Model):
|
|||||||
else Account.objects.get(code=self.code[:-1])
|
else Account.objects.get(code=self.code[:-1])
|
||||||
if self.pk is None:
|
if self.pk is None:
|
||||||
self.pk = new_pk(Account)
|
self.pk = new_pk(Account)
|
||||||
|
if getattr(self, "created_by", None) is None:
|
||||||
self.created_by = current_user
|
self.created_by = current_user
|
||||||
self.updated_by = current_user
|
if getattr(self, "updated_by", None) is None:
|
||||||
|
self.updated_by = current_user
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
super(Account, self).save(
|
super(Account, self).save(
|
||||||
force_insert=force_insert, force_update=force_update,
|
force_insert=force_insert, force_update=force_update,
|
||||||
|
Loading…
Reference in New Issue
Block a user