mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Sales order barcode allocate (#6072)
* Bug fix for BarcodePOReceive endpoint - Existing scan must match "stockitem" to raise an error * bug fix: barcode.js - Handle new return data from barcode scan endpoint * Add barcode endpoint for allocating stock to sales order * Improve logic for preventing over allocation of stock item to sales order * Test for sufficient quantity * Bump API version * Bug fix and extra check * Cleanup unit tests * Add unit testing for new endpoint * Add blank page for app sales orders docs * Add docs for new barcode features in app * Fix unit tests * Remove debug statement
This commit is contained in:
@ -419,6 +419,18 @@ function barcodeScanDialog(options={}) {
|
||||
let modal = options.modal || createNewModal();
|
||||
let title = options.title || '{% trans "Scan Barcode" %}';
|
||||
|
||||
const matching_models = [
|
||||
'build',
|
||||
'manufacturerpart',
|
||||
'part',
|
||||
'purchaseorder',
|
||||
'returnorder',
|
||||
'salesorder',
|
||||
'supplierpart',
|
||||
'stockitem',
|
||||
'stocklocation'
|
||||
];
|
||||
|
||||
barcodeDialog(
|
||||
title,
|
||||
{
|
||||
@ -428,19 +440,24 @@ function barcodeScanDialog(options={}) {
|
||||
if (options.onScan) {
|
||||
options.onScan(response);
|
||||
} else {
|
||||
// Find matching model
|
||||
matching_models.forEach(function(model) {
|
||||
if (model in response) {
|
||||
let instance = response[model];
|
||||
let url = instance.web_url || instance.url;
|
||||
if (url) {
|
||||
window.location.href = url;
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let url = response.url;
|
||||
|
||||
if (url) {
|
||||
$(modal).modal('hide');
|
||||
window.location.href = url;
|
||||
} else {
|
||||
showBarcodeMessage(
|
||||
modal,
|
||||
'{% trans "No URL in response" %}',
|
||||
'warning'
|
||||
);
|
||||
}
|
||||
// No match
|
||||
showBarcodeMessage(
|
||||
modal,
|
||||
'{% trans "No URL in response" %}',
|
||||
'warning'
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user