Handle the case of asking for get_state() on an unsaved document

- Legacy-Id: 7779
This commit is contained in:
Ole Laursen 2014-05-26 15:40:07 +00:00
parent 3c88dc127b
commit 47c9ccf0e1

View file

@ -122,6 +122,9 @@ class DocumentInfo(models.Model):
"""Get state of type, or default state for document type if
not specified. Uses a local cache to speed multiple state
reads up."""
if self.pk == None: # states is many-to-many so not in database implies no state
return None
if state_type == None:
state_type = self.type_id