2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 20:15:44 +00:00

Almost there?

This commit is contained in:
eeintech
2021-05-10 17:31:29 -04:00
parent 6d8f94619b
commit c9e77edf04
5 changed files with 110 additions and 88 deletions

View File

@ -32,8 +32,8 @@
{% block form_content %}
<thead>
<tr>
<th></th>
<th>{% trans "File Fields" %}</th>
<th></th>
{% for col in form %}
<th>
<div>
@ -49,8 +49,8 @@
</thead>
<tbody>
<tr>
<td></td>
<td>{% trans "Match Fields" %}</td>
<td></td>
{% for col in form %}
<td>
{{ col }}
@ -65,18 +65,18 @@
{% endfor %}
</tr>
{% for row in rows %}
{% with forloop.counter as row_index %}
{% with forloop.counter0 as row_index %}
<tr>
<td>
<button class='btn btn-default btn-remove' onClick='removeRowFromBomWizard()' id='del_row_{{ row_index }}' style='display: inline; float: right;' title='{% trans "Remove row" %}'>
<td style='width: 32px;'>
<button class='btn btn-default btn-remove' onClick='removeRowFromBomWizard()' id='del_row_{{ row_index }}' style='display: inline; float: left;' title='{% trans "Remove row" %}'>
<span row_id='{{ row_index }}' class='fas fa-trash-alt icon-red'></span>
</button>
</td>
<td>{{ row_index }}</td>
<td style='text-align: left;'>{{ row_index }}</td>
{% for item in row.data %}
<td>
<input type='hidden' name='row_{{ row_index }}_col_{{ forloop.counter0 }}' value='{{ item }}'/>
{{ item.cell }}
{{ item }}
</td>
{% endfor %}
</tr>

View File

@ -4,6 +4,8 @@
{% load static %}
{% block form_alert %}
{% if form.errors %}
{% endif %}
{% if form_errors %}
<div class='alert alert-danger alert-block' role='alert'>
{% trans "Errors exist in the submitted data" %}
@ -21,11 +23,12 @@
{% block form_content %}
<thead>
<tr>
<th></th>
<th></th>
<th>{% trans "Row" %}</th>
<th>{% trans "Select Supplier Part" %}</th>
<th>{% trans "Quantity" %}</th>
{% for col in columns %}
{% if col.name != 'Quantity' %}
<th>
<input type='hidden' name='col_name_{{ forloop.counter0 }}' value='{{ col.name }}'/>
<input type='hidden' name='col_guess_{{ forloop.counter0 }}' value='{{ col.guess }}'/>
@ -35,6 +38,7 @@
{{ col.name }}
{% endif %}
</th>
{% endif %}
{% endfor %}
</tr>
</thead>
@ -42,13 +46,12 @@
{% for row in rows %}
<tr {% if row.errors %} style='background: #ffeaea;'{% endif %} part-select='#select_part_{{ row.index }}'>
<td>
<button class='btn btn-default btn-remove' onClick='removeRowFromBomWizard()' id='del_row_{{ forloop.counter }}' style='display: inline; float: right;' title='{% trans "Remove row" %}'>
<button class='btn btn-default btn-remove' onClick='removeRowFromBomWizard()' id='del_row_{{ forloop.counter0 }}' style='display: inline; float: right;' title='{% trans "Remove row" %}'>
<span row_id='{{ forloop.counter }}' class='fas fa-trash-alt icon-red'></span>
</button>
</td>
<td></td>
<td>
{% add row.index 1 %}
{{ row.index }}
</td>
<td>
{% for field in form.visible_fields %}
@ -60,18 +63,20 @@
<p class='help-inline'>{{ row.errors.part }}</p>
{% endif %}
</td>
{% for item in row.data %}
<td>
{% if item.column.guess == 'Quantity' %}
{% for field in form.visible_fields %}
{% if field.name == row.quantity_select %}
{{ field }}
{% endif %}
{% endfor %}
{% if row.errors.quantity %}
<p class='help-inline'>{{ row.errors.quantity }}</p>
{% for field in form.visible_fields %}
{% if field.name == row.quantity_select %}
{{ field }}
{% endif %}
{% elif item.column.guess == 'Purchase_Price' %}
{% endfor %}
{% if row.errors.quantity %}
<p class='help-inline'>{{ row.errors.quantity }}</p>
{% endif %}
</td>
{% for item in row.data %}
{% if item.column.guess != 'Quantity' %}
<td>
{% if item.column.guess == 'Purchase_Price' %}
{% for field in form.visible_fields %}
{% if field.name == row.price_select %}
{{ field }}
@ -82,6 +87,7 @@
{% endif %}
<input type='hidden' name='row_{{ row.index }}_col_{{ forloop.counter0 }}' value='{{ item.cell }}'/>
</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}

View File

@ -651,8 +651,8 @@ class PurchaseOrderUpload(FileManagementFormView):
except (ValueError, SupplierPart.DoesNotExist, SupplierPart.MultipleObjectsReturned):
exact_match_part = None
# Check if there is a column corresponding to "Manufacturer MPN"
if m_idx >= 0:
# Check if there is a column corresponding to "Manufacturer MPN" and no exact match found yet
if m_idx >= 0 and not exact_match_part:
mpn = row['data'][m_idx]['cell']
try:
@ -755,7 +755,7 @@ class PurchaseOrderUpload(FileManagementFormView):
order=order,
part=supplier_part,
quantity=purchase_order_item['quantity'],
purchase_price=purchase_order_item['purchase_price'],
purchase_price=purchase_order_item.get('purchase_price', None),
)
try:
purchase_order_line_item.save()