Merge pull request #2408 from SchrodingersGat/initial-stock-when-duplicating

Add option for creating initial stock quantity when duplicating a part
This commit is contained in:
Oliver 2021-12-03 00:29:37 +11:00 committed by GitHub
commit 96c1f74cd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -153,12 +153,7 @@ function partFields(options={}) {
delete fields['default_expiry'];
}
// Additional fields when "creating" a new part
if (options.create) {
// No supplier parts available yet
delete fields['default_supplier'];
if (options.create || options.duplicate) {
if (global_settings.PART_CREATE_INITIAL) {
fields.initial_stock = {
@ -187,6 +182,13 @@ function partFields(options={}) {
group: 'create',
};
}
}
// Additional fields when "creating" a new part
if (options.create) {
// No supplier parts available yet
delete fields['default_supplier'];
fields.copy_category_parameters = {
type: 'boolean',
@ -349,6 +351,10 @@ function duplicatePart(pk, options={}) {
duplicate: pk,
});
if (fields.initial_stock_location) {
fields.initial_stock_location.value = data.default_location;
}
// Remove "default_supplier" field
delete fields['default_supplier'];