From 322710d6032d4942d4570c15f6ec24919ae4b120 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 10 Jul 2019 13:04:47 +1000 Subject: [PATCH] Handle dimension error in tablib --- InvenTree/part/bom.py | 2 ++ InvenTree/part/views.py | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/InvenTree/part/bom.py b/InvenTree/part/bom.py index 01ee669192..a96c331a4b 100644 --- a/InvenTree/part/bom.py +++ b/InvenTree/part/bom.py @@ -95,6 +95,8 @@ class BomUploadManager: self.data = tablib.Dataset().load(raw_data) except tablib.UnsupportedFormat: raise ValidationError({'bom_file': _('Error reading BOM file (invalid data)')}) + except tablib.core.InvalidDimensions: + raise ValidationError({'bom_file': _('Error reading BOM file (incorrect row size)')}) def guess_header(self, header, threshold=80): """ Try to match a header (from the file) to a list of known headers diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index 6571f28c87..5f9f541a78 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -782,7 +782,6 @@ class BomUpload(FormView): self.extractDataFromFile(manager) else: form = self.form - form.errors['bom_file'] = [_('no errors')] return self.render_to_response(self.get_context_data(form=form))