diff --git a/InvenTree/company/apps.py b/InvenTree/company/apps.py index 949ee152c0..0afb18f616 100644 --- a/InvenTree/company/apps.py +++ b/InvenTree/company/apps.py @@ -31,6 +31,11 @@ class CompanyConfig(AppConfig): if not os.path.exists(loc): print("InvenTree: Generating thumbnail for Company '{c}'".format(c=company.name)) - company.image.render_variations(replace=False) + try: + company.image.render_variations(replace=False) + except FileNotFoundError: + print("Image file missing") + company.image = None + company.save() except (OperationalError, ProgrammingError): print("Could not generate Company thumbnails") diff --git a/InvenTree/part/apps.py b/InvenTree/part/apps.py index 95193a9527..2137ec5d89 100644 --- a/InvenTree/part/apps.py +++ b/InvenTree/part/apps.py @@ -30,6 +30,11 @@ class PartConfig(AppConfig): if not os.path.exists(loc): print("InvenTree: Generating thumbnail for Part '{p}'".format(p=part.name)) - part.image.render_variations(replace=False) + try: + part.image.render_variations(replace=False) + except FileNotFoundError: + print("Image file missing") + part.image = None + part.save() except (OperationalError, ProgrammingError): print("Could not generate Part thumbnails") diff --git a/InvenTree/part/migrations/0034_auto_20200404_1238.py b/InvenTree/part/migrations/0034_auto_20200404_1238.py index aba533ff40..b93fb64607 100644 --- a/InvenTree/part/migrations/0034_auto_20200404_1238.py +++ b/InvenTree/part/migrations/0034_auto_20200404_1238.py @@ -16,7 +16,14 @@ def create_thumbnails(apps, schema_editor): for part in Part.objects.all(): # Render thumbnail for each existing Part if part.image: - part.image.render_variations() + try: + part.image.render_variations() + except FileNotFoundError: + print("Missing image:", part.image()) + # The image is missing, so clear the field + part.image = None + part.save() + except (OperationalError, ProgrammingError): # Migrations have not yet been applied - table does not exist print("Could not generate Part thumbnails")