From 6335372208078d5c588938bbc9bd34500d08edc1 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 28 Jun 2021 09:28:38 +1000 Subject: [PATCH] Store instance data when performing an "update" --- InvenTree/templates/js/forms.js | 5 ++++- InvenTree/templates/js/model_renderers.js | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/InvenTree/templates/js/forms.js b/InvenTree/templates/js/forms.js index 7d6cc5cd98..063f953966 100644 --- a/InvenTree/templates/js/forms.js +++ b/InvenTree/templates/js/forms.js @@ -155,6 +155,9 @@ function constructChangeForm(fields, options) { } } + // Store the entire data object + options.instance = data; + constructFormBody(fields, options); }, error: function(request, status, error) { @@ -570,7 +573,7 @@ function initializeRelatedFields(fields, options) { * - field: Field definition from the OPTIONS request * - options: Original options object provided by the client */ -function initializeRelatedField(modal, name, field, options) { +function initializeRelatedField(name, field, options) { // Find the select element and attach a select2 to it var select = $(options.modal).find(`#id_${name}`); diff --git a/InvenTree/templates/js/model_renderers.js b/InvenTree/templates/js/model_renderers.js index 924d85d35d..ae32c06eff 100644 --- a/InvenTree/templates/js/model_renderers.js +++ b/InvenTree/templates/js/model_renderers.js @@ -1,3 +1,5 @@ +{% load i18n %} + /* * This file contains functions for rendering various InvenTree database models, * in particular for displaying them in modal forms in a 'select2' context. @@ -69,12 +71,14 @@ function renderPart(name, data, parameters, options) { // Renderer for "PartCategory" model function renderPartCategory(name, data, parameters, options) { - var html = `${data.name}`; + var html = `${data.name}`; if (data.description) { html += ` - ${data.description}`; } + html += `{% trans "Location ID" %}: ${data.pk}`; + if (data.pathstring) { html += `

${data.pathstring}

`; }