mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Added part match auto-selection (if partial_ratio >= 100) to BoM part selection form
This commit is contained in:
parent
685a58b807
commit
303157c586
@ -62,6 +62,11 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<select class='select bomselect' id='select_part_{{ row.index }}' name='part_{{ row.index }}'>
|
<select class='select bomselect' id='select_part_{{ row.index }}' name='part_{{ row.index }}'>
|
||||||
|
{% if row.part_match %}
|
||||||
|
{% with row.part_match as part %}
|
||||||
|
<option value='{{ part.id }}'{% if part.id == row.part.id %} selected='selected'{% endif %}>{{ part.full_name }} - {{ part.description }}</option>
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
<option value=''>---------</option>
|
<option value=''>---------</option>
|
||||||
{% for part in row.part_options %}
|
{% for part in row.part_options %}
|
||||||
<option value='{{ part.id }}'{% if part.id == row.part.id %} selected='selected'{% endif %}>{{ part.full_name }} - {{ part.description }}</option>
|
<option value='{{ part.id }}'{% if part.id == row.part.id %} selected='selected'{% endif %}>{{ part.full_name }} - {{ part.description }}</option>
|
||||||
|
@ -847,6 +847,7 @@ class BomUpload(FormView):
|
|||||||
rows.append({
|
rows.append({
|
||||||
'index': row.get('index', -1),
|
'index': row.get('index', -1),
|
||||||
'data': data,
|
'data': data,
|
||||||
|
'part_match': row.get('part_match', None),
|
||||||
'part_options': row.get('part_options', self.allowed_parts),
|
'part_options': row.get('part_options', self.allowed_parts),
|
||||||
|
|
||||||
# User-input (passed between client and server)
|
# User-input (passed between client and server)
|
||||||
@ -991,7 +992,16 @@ class BomUpload(FormView):
|
|||||||
row['notes'] = row['data'][n_idx]
|
row['notes'] = row['data'][n_idx]
|
||||||
|
|
||||||
row['quantity'] = quantity
|
row['quantity'] = quantity
|
||||||
row['part_options'] = [m['part'] for m in matches]
|
|
||||||
|
# Part selection: separate match from options
|
||||||
|
match_limit = 100
|
||||||
|
part_matches = [m['part'] for m in matches if m['match'] >= match_limit]
|
||||||
|
if len(part_matches) == 1:
|
||||||
|
row['part_match'] = part_matches[0]
|
||||||
|
row['part_options'] = [m['part'] for m in matches if m['match'] < match_limit]
|
||||||
|
else:
|
||||||
|
row['part_match'] = None
|
||||||
|
row['part_options'] = [m['part'] for m in matches]
|
||||||
|
|
||||||
def extractDataFromFile(self, bom):
|
def extractDataFromFile(self, bom):
|
||||||
""" Read data from the BOM file """
|
""" Read data from the BOM file """
|
||||||
|
Loading…
Reference in New Issue
Block a user