Merge pull request #1593 from SchrodingersGat/hide-purchase-price

Disable "purchase price" field for non-purchaseable parts
This commit is contained in:
Oliver 2021-05-17 20:45:06 +10:00 committed by GitHub
commit 56fd8132c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -89,6 +89,15 @@ function setFieldOptions(fieldName, optionList, options={}) {
}
function clearFieldOptions(fieldName) {
/**
* Clear (emtpy) the options list for a particular field
*/
setFieldOptions(fieldName, []);
}
function reloadFieldOptions(fieldName, options) {
/* Reload the options for a given field,
* using an AJAX request.

View File

@ -1218,6 +1218,17 @@ function createNewStockItem(options) {
field: 'part',
action: function(value) {
if (!value) {
// No part chosen
clearFieldOptions('supplier_part');
enableField('serial_numbers', false);
enableField('purchase_price_0', false);
enableField('purchase_price_1', false);
return;
}
// Reload options for supplier part
reloadFieldOptions(
'supplier_part',
@ -1243,6 +1254,9 @@ function createNewStockItem(options) {
enableField('serial_numbers', response.trackable);
clearField('serial_numbers');
enableField('purchase_price_0', response.purchaseable);
enableField('purchase_price_1', response.purchaseable);
// Populate the expiry date
if (response.default_expiry <= 0) {
// No expiry date