diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 6564568fd3..d124129b47 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -453,7 +453,7 @@ class PartScheduling(generics.RetrieveAPIView): schedule = [] - def add_schedule_entry(date, quantity, label, url): + def add_schedule_entry(date, quantity, title, label, url): """ Check if a scheduled entry should be added: - date must be non-null @@ -465,8 +465,9 @@ class PartScheduling(generics.RetrieveAPIView): schedule.append({ 'date': date, 'quantity': quantity, - 'url': url, + 'title': title, 'label': label, + 'url': url, }) # Add purchase order (incoming stock) information @@ -484,6 +485,7 @@ class PartScheduling(generics.RetrieveAPIView): add_schedule_entry( target_date, quantity, + _('Incoming Purchase Order'), str(line.order), line.order.get_absolute_url() ) @@ -503,6 +505,7 @@ class PartScheduling(generics.RetrieveAPIView): add_schedule_entry( target_date, -quantity, + _('Outgoing Sales Order'), str(line.order), line.order.get_absolute_url(), ) @@ -520,6 +523,7 @@ class PartScheduling(generics.RetrieveAPIView): add_schedule_entry( build.target_date, quantity, + _('Stock produced by Build Order'), str(build), build.get_absolute_url(), ) @@ -551,6 +555,7 @@ class PartScheduling(generics.RetrieveAPIView): add_schedule_entry( allocation.build.target_date, -allocation.quantity, + _('Stock required for Build Order'), str(allocation.build), allocation.build.get_absolute_url(), ) diff --git a/InvenTree/templates/js/translated/part.js b/InvenTree/templates/js/translated/part.js index 2f3a8b29e8..eb94070746 100644 --- a/InvenTree/templates/js/translated/part.js +++ b/InvenTree/templates/js/translated/part.js @@ -1999,6 +1999,7 @@ function loadPartSchedulingChart(canvas_id, part_id) { { date: today, delta: 0, + label: '{% trans "Current Stock" %}', } ]; @@ -2016,6 +2017,7 @@ function loadPartSchedulingChart(canvas_id, part_id) { stock_schedule.push({ date: moment(entry.date), delta: entry.quantity, + title: entry.title, label: entry.label, url: entry.url, }) @@ -2042,7 +2044,9 @@ function loadPartSchedulingChart(canvas_id, part_id) { datasets: [{ label: '{% trans "Scheduled Stock Quantities" %}', data: stock_schedule, - backgroundColor: 'rgb(255, 99, 132)' + backgroundColor: 'rgb(220, 160, 80)', + borderWidth: 2, + borderColor: 'rgb(90, 130, 150)' }], }; @@ -2069,7 +2073,21 @@ function loadPartSchedulingChart(canvas_id, part_id) { tooltip: { callbacks: { label: function(item) { - return renderLink(item.raw.label, item.raw.url); + return item.raw.label; + }, + beforeLabel: function(item) { + return item.raw.title; + }, + afterLabel: function(item) { + var delta = item.raw.delta; + + if (delta == 0) { + delta = ''; + } else { + delta = ` (${item.raw.delta > 0 ? "+" : ""}${item.raw.delta})`; + } + + return `{% trans "Quantity" %}: ${item.raw.y}${delta}`; } } }