Fixes for 'order parts' form

- Sometimes the part pk was not being retrieved properly
This commit is contained in:
Oliver Walters 2020-11-27 11:18:45 +11:00
parent 607cc90ce0
commit 7068f70811
2 changed files with 16 additions and 9 deletions

View File

@ -11,11 +11,11 @@
{% if parts|length > 0 %}
<div class='alert alert-info alert-block' role='alert'>
{% trans "Select suppliers." %}
{% trans "Select suppliers" %}
</div>
{% else %}
<div class='alert alert-warning alert-block' role='alert'>
{% trans "No purchaseable parts selected." %}
{% trans "No purchaseable parts selected" %}
</div>
{% endif %}
@ -39,8 +39,8 @@
{{ part.full_name }} <small><i>{{ part.description }}</i></small>
</td>
<td>
<button class='btn btn-default btn-create' onClick='newSupplierPartFromOrderWizard()' id='new_supplier_part_{{ part.id }}' title='Create new supplier part for {{ part }}' type='button'>
<span part-id='{{ part.id }}' class='fas fa-plus-circle'></span>
<button class='btn btn-default btn-create' onClick='newSupplierPartFromOrderWizard()' id='new_supplier_part_{{ part.id }}' part='{{ part.pk }}' title='{% trans "Create new supplier part" $}' type='button'>
<span part='{{ part.pk }}' class='fas fa-plus-circle'></span>
</button>
</td>
<td>

View File

@ -21,9 +21,16 @@ function newSupplierPartFromOrderWizard(e) {
e = e || window.event;
var src = e.target || e.srcElement;
var src = e.srcElement || e.target;
var part = $(src).attr('part-id');
var part = $(src).attr('part');
console.log('part: ' + part);
if (!part) {
part = $(src).closest('button').attr('part');
console.log('parent: ' + part);
}
launchModalForm("/supplier-part/new/", {
modal: '#modal-form-secondary',
@ -125,7 +132,7 @@ function loadPurchaseOrderTable(table, options) {
name: 'purchaseorder',
groupBy: false,
original: options.params,
formatNoMatches: function() { return "{% trans "No purchase orders found" %}"; },
formatNoMatches: function() { return '{% trans "No purchase orders found" %}'; },
columns: [
{
field: 'pk',
@ -208,7 +215,7 @@ function loadSalesOrderTable(table, options) {
name: 'salesorder',
groupBy: false,
original: options.params,
formatNoMatches: function() { return "{% trans "No sales orders found" %}"; },
formatNoMatches: function() { return '{% trans "No sales orders found" %}'; },
columns: [
{
field: 'pk',
@ -265,7 +272,7 @@ function loadSalesOrderTable(table, options) {
{
sortable: true,
field: 'shipment_date',
title: "{% trans "Shipment Date" %}",
title: '{% trans "Shipment Date" %}',
},
{
sortable: true,