diff --git a/InvenTree/part/templates/part/bom_upload/select_parts.html b/InvenTree/part/templates/part/bom_upload/select_parts.html
index 25421d7173..803f9dc496 100644
--- a/InvenTree/part/templates/part/bom_upload/select_parts.html
+++ b/InvenTree/part/templates/part/bom_upload/select_parts.html
@@ -49,12 +49,11 @@
{% if item.column.guess == 'Part' %}
-
- {{ item.cell }}
+ {{ item.cell }}
{% elif item.column.guess == 'Quantity' %}
{% elif item.editable %}
@@ -76,6 +75,9 @@
{% block js_ready %}
{{ block.super }}
-$('.bomselect').select2();
+$('.bomselect').select2({
+ dropdownAutoWidth: true,
+ matcher: partialMatcher,
+});
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py
index 89ba6b2bf9..86931b4e04 100644
--- a/InvenTree/part/views.py
+++ b/InvenTree/part/views.py
@@ -14,6 +14,8 @@ from django.views.generic.edit import FormMixin
from django.forms.models import model_to_dict
from django.forms import HiddenInput, CheckboxInput
+from fuzzywuzzy import fuzz
+
from .models import PartCategory, Part, PartAttachment
from .models import BomItem
from .models import match_part_names
@@ -697,6 +699,7 @@ class BomUpload(FormView):
'index': row.get('index', -1),
'data': data,
'quantity': row.get('quantity', None),
+ 'part_options': row.get('part_options', [])
})
ctx['part'] = self.part
@@ -782,21 +785,40 @@ class BomUpload(FormView):
except ValueError:
q_idx = -1
+ try:
+ p_idx = list(self.column_selections.values()).index('Part')
+ except ValueError:
+ p_idx = -1
+
for row in self.bom_rows:
quantity = 0
+ part = None
if q_idx >= 0:
- print(row)
q_val = row['data'][q_idx]
- print("row:", row['index'], "q:", q_val)
try:
quantity = int(q_val)
except ValueError:
pass
+ if p_idx >= 0:
+ p_val = row['data'][p_idx]
+
+ # Fuzzy match the values and see what happends
+ matches = []
+
+ for part in self.allowed_parts:
+ ratio = fuzz.partial_ratio(part.name + part.description, p_val)
+ matches.append({'part': part, 'match': ratio})
+
+ if len(matches) > 0:
+ matches = sorted(matches, key=lambda item: item['match'], reverse=True)
+
+ row['part'] = part
row['quantity'] = quantity
+ row['part_options'] = [m['part'] for m in matches]
def extractDataFromFile(self, bom):
diff --git a/InvenTree/static/css/inventree.css b/InvenTree/static/css/inventree.css
index 28c304485b..3f64633062 100644
--- a/InvenTree/static/css/inventree.css
+++ b/InvenTree/static/css/inventree.css
@@ -77,6 +77,10 @@
width: 100%;
}
+.bomselect {
+ max-width: 250px;
+}
+
/* Part image icons with full-display on mouse hover */
.hover-img-thumb {