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) { function reloadFieldOptions(fieldName, options) {
/* Reload the options for a given field, /* Reload the options for a given field,
* using an AJAX request. * using an AJAX request.

View File

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