From 752fb97d2f0da8e565635ec4e04a9ecb77e264b0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 28 Jun 2023 21:59:47 +1000 Subject: [PATCH] Transfer stock location (#5117) * Hide info messages if no data * pre-fill location when transferring stock * Change iteration variable * Measure twice, cut once * js improvements --- InvenTree/part/tasks.py | 6 ++++-- InvenTree/templates/js/translated/stock.js | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/tasks.py b/InvenTree/part/tasks.py index d04d1b7794..23781fd839 100644 --- a/InvenTree/part/tasks.py +++ b/InvenTree/part/tasks.py @@ -459,7 +459,8 @@ def rebuild_parameters(template_id): parameter.save() n += 1 - logger.info(f"Rebuilt {n} parameters for template '{template.name}'") + if n > 0: + logger.info(f"Rebuilt {n} parameters for template '{template.name}'") def rebuild_supplier_parts(part_id): @@ -486,4 +487,5 @@ def rebuild_supplier_parts(part_id): except ValidationError: pass - logger.info(f"Rebuilt {n} supplier parts for part '{prt.name}'") + if n > 0: + logger.info(f"Rebuilt {n} supplier parts for part '{prt.name}'") diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index af07802601..94d77e8719 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -1148,7 +1148,26 @@ function adjustStock(action, items, options={}) { var extraFields = {}; if (specifyLocation) { + + // If a common location is specified, use that as the default + let commonLocation = null; + + for (const item of items) { + + if (item.location == commonLocation) { + continue; + } + + if (commonLocation == null) { + commonLocation = item.location; + } else { + commonLocation = null; + break; + } + } + extraFields.location = { + value: commonLocation, filters: { structural: false, },