From fa90c92a2a85347eee8f756a943bcafa08816c9e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 3 Jul 2019 21:19:31 +1000 Subject: [PATCH] Redirect to step 3 --- .../part/bom_upload/select_parts.html | 51 +++++++++++++++++++ InvenTree/part/views.py | 12 ++++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 InvenTree/part/templates/part/bom_upload/select_parts.html diff --git a/InvenTree/part/templates/part/bom_upload/select_parts.html b/InvenTree/part/templates/part/bom_upload/select_parts.html new file mode 100644 index 0000000000..956f4c2271 --- /dev/null +++ b/InvenTree/part/templates/part/bom_upload/select_parts.html @@ -0,0 +1,51 @@ +{% extends "part/part_base.html" %} +{% load static %} + +{% block details %} +{% include "part/tabs.html" with tab="bom" %} +

Upload Bill of Materials

+ +

Step 3 - Select Parts

+
+ +
+ + {% csrf_token %} + {% load crispy_forms_tags %} + + + + + + + + + {% for col in bom_columns %} + + {% endfor %} + + + + {% for row in bom_rows %} + + + + {% for item in row.data %} + + {% endfor %} + + {% endfor %} + +
Row + {{ col.name }} +
+ + {{ forloop.counter }} + {{ item }} +
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index eb575986cc..c4f1a0050f 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -796,6 +796,9 @@ class BomUpload(FormView): self.bom_columns = [] + # Track any duplicate column selections + duplicates = False + for col in col_ids: if col not in column_selections: continue @@ -812,6 +815,7 @@ class BomUpload(FormView): n = list(column_selections.values()).count(column_selections[col]) if n > 1: header['duplicate'] = True + duplicates = True self.bom_columns.append(header) @@ -838,8 +842,14 @@ class BomUpload(FormView): self.bom_rows.append({'index': row_idx, 'data': items}) + valid = len(self.missing_columns) == 0 and not duplicates + form = part_forms.BomUploadSelectFields - self.template_name = 'part/bom_upload/select_fields.html' + + if valid: + form = self.template_name = 'part/bom_upload/select_parts.html' + else: + self.template_name = 'part/bom_upload/select_fields.html' return self.render_to_response(self.get_context_data(form=form))