Correct the way we get periods for invoices list

This commit is contained in:
PCoder 2019-04-22 11:40:00 +02:00
commit 1ccb4e9790
3 changed files with 10 additions and 8 deletions

View file

@ -500,7 +500,8 @@ class HostingBillLineItem(AssignPermissionsMixin, models.Model):
:return:
"""
item_detail = ""
if self.metadata is not None and len(self.metadata) > 0:
# metadata is a dict; a dict with nothing has two chars at least {}
if self.metadata is not None and len(self.metadata) > 2:
try:
vm_dict = json.loads(self.metadata)
item_detail = "VM ID: {}<br/>".format(vm_dict["VM_ID"])