mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Supply part name for auto-fill when creating a new part
This commit is contained in:
parent
85e803f345
commit
dff8d1fb95
@ -35,7 +35,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in bom_rows %}
|
||||
<tr part-description='{{ row.description }}' part-select='#select_part_{{ row.index }}'>
|
||||
<tr part-name='{{ row.part_name }}' part-description='{{ row.description }}' part-select='#select_part_{{ row.index }}'>
|
||||
<td>
|
||||
<button class='btn btn-default btn-remove' id='del_row_{{ forloop.counter }}' style='display: inline; float: right;' title='Remove row'>
|
||||
<span row_id='{{ forloop.counter }}' onClick='removeRowFromBomWizard()' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
|
@ -708,6 +708,7 @@ class BomUpload(FormView):
|
||||
# User-input (passed between client and server)
|
||||
'quantity': row.get('quantity', None),
|
||||
'description': row.get('description', ''),
|
||||
'part_name': row.get('part_name', ''),
|
||||
'part': row.get('part', None),
|
||||
'reference': row.get('reference', ''),
|
||||
'notes': row.get('notes', ''),
|
||||
@ -799,8 +800,9 @@ class BomUpload(FormView):
|
||||
|
||||
|
||||
def preFillSelections(self):
|
||||
""" Once data columns have been selected,
|
||||
attempt to pre-select the proper data from the database.
|
||||
""" Once data columns have been selected, attempt to pre-select the proper data from the database.
|
||||
This function is called once the field selection has been validated.
|
||||
The pre-fill data are then passed through to the part selection form.
|
||||
"""
|
||||
|
||||
q_idx = self.getColumnIndex('Quantity')
|
||||
@ -823,13 +825,15 @@ class BomUpload(FormView):
|
||||
pass
|
||||
|
||||
if p_idx >= 0:
|
||||
p_val = row['data'][p_idx]
|
||||
part_name = row['data'][p_idx]
|
||||
|
||||
row['part_name'] = part_name
|
||||
|
||||
# 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)
|
||||
ratio = fuzz.partial_ratio(part.name + part.description, part_name)
|
||||
matches.append({'part': part, 'match': ratio})
|
||||
|
||||
if len(matches) > 0:
|
||||
|
Loading…
Reference in New Issue
Block a user