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

Only allow pricing update when creating a new PurchaseOrderLineItem (#4537)

Fixes https://github.com/inventree/InvenTree/issues/4485
This commit is contained in:
Oliver 2023-03-29 14:59:28 +11:00 committed by GitHub
parent e8e2985454
commit 66b8fb6bc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -252,34 +252,36 @@ function poLineItemFields(options={}) {
} }
}).then(function() { }).then(function() {
// Update pricing data (if available) // Update pricing data (if available)
inventreeGet( if (options.update_pricing) {
'{% url "api-part-supplier-price-list" %}', inventreeGet(
{ '{% url "api-part-supplier-price-list" %}',
part: supplier_part_id, {
ordering: 'quantity', part: supplier_part_id,
}, ordering: 'quantity',
{ },
success: function(response) { {
// Returned prices are in increasing order of quantity success: function(response) {
if (response.length > 0) { // Returned prices are in increasing order of quantity
var idx = 0; if (response.length > 0) {
var index = 0; var idx = 0;
var index = 0;
for (var idx = 0; idx < response.length; idx++) { for (var idx = 0; idx < response.length; idx++) {
if (response[idx].quantity > quantity) { if (response[idx].quantity > quantity) {
break; break;
}
index = idx;
} }
index = idx; // Update price and currency data in the form
updateFieldValue('purchase_price', response[index].price, {}, opts);
updateFieldValue('purchase_price_currency', response[index].price_currency, {}, opts);
} }
// Update price and currency data in the form
updateFieldValue('purchase_price', response[index].price, {}, opts);
updateFieldValue('purchase_price_currency', response[index].price_currency, {}, opts);
} }
} }
} );
); }
}); });
}, },
secondary: { secondary: {
@ -356,6 +358,7 @@ function createPurchaseOrderLineItem(order, options={}) {
supplier: options.supplier, supplier: options.supplier,
currency: options.currency, currency: options.currency,
target_date: options.target_date, target_date: options.target_date,
update_pricing: true,
}); });
constructForm('{% url "api-po-line-list" %}', { constructForm('{% url "api-po-line-list" %}', {