mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Fix callbacks for adding new supplier part and/or purchase order "inline"
This commit is contained in:
parent
40c9885b87
commit
4732efb330
@ -312,7 +312,7 @@ class SupplierPartList(generics.ListCreateAPIView):
|
|||||||
try:
|
try:
|
||||||
params = self.request.query_params
|
params = self.request.query_params
|
||||||
kwargs['part_detail'] = str2bool(params.get('part_detail', None))
|
kwargs['part_detail'] = str2bool(params.get('part_detail', None))
|
||||||
kwargs['supplier_detail'] = str2bool(params.get('supplier_detail', None))
|
kwargs['supplier_detail'] = str2bool(params.get('supplier_detail', True))
|
||||||
kwargs['manufacturer_detail'] = str2bool(params.get('manufacturer_detail', None))
|
kwargs['manufacturer_detail'] = str2bool(params.get('manufacturer_detail', None))
|
||||||
kwargs['pretty'] = str2bool(params.get('pretty', None))
|
kwargs['pretty'] = str2bool(params.get('pretty', None))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -115,10 +115,6 @@ function supplierPartFields() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
part: {},
|
part: {},
|
||||||
supplier: {},
|
|
||||||
SKU: {
|
|
||||||
icon: 'fa-hashtag',
|
|
||||||
},
|
|
||||||
manufacturer_part: {
|
manufacturer_part: {
|
||||||
filters: {
|
filters: {
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
@ -126,6 +122,10 @@ function supplierPartFields() {
|
|||||||
},
|
},
|
||||||
auto_fill: true,
|
auto_fill: true,
|
||||||
},
|
},
|
||||||
|
supplier: {},
|
||||||
|
SKU: {
|
||||||
|
icon: 'fa-hashtag',
|
||||||
|
},
|
||||||
description: {},
|
description: {},
|
||||||
link: {
|
link: {
|
||||||
icon: 'fa-link',
|
icon: 'fa-link',
|
||||||
|
@ -394,7 +394,9 @@ function renderSupplierPart(name, data, parameters={}, options={}) {
|
|||||||
html += select2Thumbnail(part_image);
|
html += select2Thumbnail(part_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
html += ` <span><b>${data.supplier_detail.name}</b> - ${data.SKU}</span>`;
|
if (data.supplier_detail) {
|
||||||
|
html += ` <span><b>${data.supplier_detail.name}</b> - ${data.SKU}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.part_detail) {
|
if (data.part_detail) {
|
||||||
html += ` - <i>${data.part_detail.full_name}</i>`;
|
html += ` - <i>${data.part_detail.full_name}</i>`;
|
||||||
|
@ -260,8 +260,8 @@ function createPurchaseOrder(options={}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
supplier_reference: {},
|
|
||||||
description: {},
|
description: {},
|
||||||
|
supplier_reference: {},
|
||||||
target_date: {
|
target_date: {
|
||||||
icon: 'fa-calendar-alt',
|
icon: 'fa-calendar-alt',
|
||||||
},
|
},
|
||||||
@ -670,61 +670,51 @@ function orderParts(parts_list, options={}) {
|
|||||||
auto_fill: false,
|
auto_fill: false,
|
||||||
filters: {
|
filters: {
|
||||||
status: {{ PurchaseOrderStatus.PENDING }},
|
status: {{ PurchaseOrderStatus.PENDING }},
|
||||||
},
|
supplier_detail: true,
|
||||||
adjustFilters: function(query, opts) {
|
|
||||||
|
|
||||||
// Whenever we open the drop-down to select an order,
|
|
||||||
// ensure we are only displaying orders which match the selected supplier part
|
|
||||||
var supplier_part_pk = getFormFieldValue(`supplier_part_${part.pk}`, opts);
|
|
||||||
|
|
||||||
inventreeGet(
|
|
||||||
`/api/company/part/${supplier_part_pk}/`,
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
async: false,
|
|
||||||
success: function(data) {
|
|
||||||
query.supplier = data.supplier;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return query;
|
|
||||||
},
|
},
|
||||||
noResults: function(query) {
|
noResults: function(query) {
|
||||||
return '{% trans "No matching purchase orders" %}';
|
return '{% trans "No matching purchase orders" %}';
|
||||||
}
|
}
|
||||||
}, null, opts);
|
}, null, opts);
|
||||||
|
});
|
||||||
|
|
||||||
// Add callback for "remove row" button
|
// Add callback for "remove row" button
|
||||||
$(opts.modal).find('.button-row-remove').click(function() {
|
$(opts.modal).find('.button-row-remove').click(function() {
|
||||||
var pk = $(this).attr('pk');
|
var pk = $(this).attr('pk');
|
||||||
|
|
||||||
$(opts.modal).find(`#order_row_${pk}`).remove();
|
$(opts.modal).find(`#order_row_${pk}`).remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add callback for "new supplier part" button
|
||||||
|
$(opts.modal).find('.button-row-new-sp').click(function() {
|
||||||
|
var pk = $(this).attr('pk');
|
||||||
|
|
||||||
|
// Launch dialog to create new supplier part
|
||||||
|
createSupplierPart({
|
||||||
|
part: pk,
|
||||||
|
onSuccess: function(response) {
|
||||||
|
setRelatedFieldData(
|
||||||
|
`supplier_part_${pk}`,
|
||||||
|
response,
|
||||||
|
opts
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Add callback for "new supplier part" button
|
// Add callback for "new purchase order" button
|
||||||
$(opts.modal).find('.button-row-new-sp').click(function() {
|
$(opts.modal).find('.button-row-new-po').click(function() {
|
||||||
var pk = $(this).attr('pk');
|
var pk = $(this).attr('pk');
|
||||||
|
|
||||||
// Launch dialog to create new supplier part
|
// Launch dialog to create new purchase order
|
||||||
createSupplierPart({
|
createPurchaseOrder({
|
||||||
part: pk,
|
onSuccess: function(response) {
|
||||||
onSuccess: function(response) {
|
setRelatedFieldData(
|
||||||
// TODO
|
`purchase_order_${pk}`,
|
||||||
}
|
response,
|
||||||
});
|
opts
|
||||||
});
|
);
|
||||||
|
}
|
||||||
// Add callback for "new purchase order" button
|
|
||||||
$(opts.modal).find('.button-row-new-po').click(function() {
|
|
||||||
var pk = $(this).attr('pk');
|
|
||||||
|
|
||||||
// Launch dialog to create new purchase order
|
|
||||||
createPurchaseOrder({
|
|
||||||
onSuccess: function(response) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user