From f2806b2e41e8219359f1f6aea6aeab8e10005a81 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 21 Mar 2022 23:19:27 +1100 Subject: [PATCH] Tweaks for existing form code --- InvenTree/templates/js/translated/forms.js | 5 +++++ InvenTree/templates/js/translated/model_renderers.js | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/InvenTree/templates/js/translated/forms.js b/InvenTree/templates/js/translated/forms.js index 88c9c5badb..e01835ae36 100644 --- a/InvenTree/templates/js/translated/forms.js +++ b/InvenTree/templates/js/translated/forms.js @@ -1780,6 +1780,11 @@ function initializeRelatedField(field, fields, options={}) { // Only a single result is available, given the provided filters if (data.count == 1) { setRelatedFieldData(name, data.results[0], options); + + // Run "callback" function (if supplied) + if (field.onEdit) { + field.onEdit(data.results[0], name, field, options); + } } } }); diff --git a/InvenTree/templates/js/translated/model_renderers.js b/InvenTree/templates/js/translated/model_renderers.js index e3abe1186f..72c1ed378b 100644 --- a/InvenTree/templates/js/translated/model_renderers.js +++ b/InvenTree/templates/js/translated/model_renderers.js @@ -371,10 +371,16 @@ function renderSupplierPart(name, data, parameters, options) { var html = ''; html += select2Thumbnail(supplier_image); - html += select2Thumbnail(part_image); + + if (data.part_detail) { + html += select2Thumbnail(part_image); + } html += ` ${data.supplier_detail.name} - ${data.SKU}`; - html += ` - ${data.part_detail.full_name}`; + + if (data.part_detail) { + html += ` - ${data.part_detail.full_name}`; + } html += `{% trans "Supplier Part ID" %}: ${data.pk}`;