From 4f8bca4ea439d6fc6463acb10f5953936fe04ba5 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 6 Nov 2023 21:14:23 +1100 Subject: [PATCH] PO auto fill fix (#5871) * Take "on_order" quantity into account when ordering items * Clean up panel.md * update urls.d --- .../templates/js/translated/purchase_order.js | 16 ++++++++++++---- docs/docs/extend/plugins/panel.md | 6 ++---- docs/docs/extend/plugins/urls.md | 6 +++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/InvenTree/templates/js/translated/purchase_order.js b/InvenTree/templates/js/translated/purchase_order.js index 31ade365b0..8807942430 100644 --- a/InvenTree/templates/js/translated/purchase_order.js +++ b/InvenTree/templates/js/translated/purchase_order.js @@ -883,16 +883,24 @@ function orderParts(parts_list, options={}) { // Request 'requirements' information for each part inventreeGet(`{% url "api-part-list" %}${part.pk}/requirements/`, {}, { success: function(response) { - var required = response.required || 0; - var allocated = response.allocated || 0; - var available = response.available_stock || 0; + let required = response.required || 0; + let allocated = response.allocated || 0; + let available = response.available_stock || 0; + let on_order = response.on_order || 0; // Based on what we currently 'have' on hand, what do we need to order? - var deficit = Math.max(required - allocated, 0); + let deficit = Math.max(required - allocated, 0); if (available < deficit) { var q = deficit - available; + // If we have some on order, subtract that from the quantity we need to order + if (on_order > 0) { + q -= on_order; + } + + q = Math.max(q, 0); + updateFieldValue( `quantity_${part.pk}`, q, diff --git a/docs/docs/extend/plugins/panel.md b/docs/docs/extend/plugins/panel.md index e518ced947..51bbc016f5 100644 --- a/docs/docs/extend/plugins/panel.md +++ b/docs/docs/extend/plugins/panel.md @@ -18,12 +18,10 @@ Each plugin which implements this mixin can return zero or more custom panels fo Panel content can be rendered by returning HTML directly, or by rendering from a template file. - Each plugin can register templates simply by providing a 'templates' directory in its root path. The convention is that each 'templates' directory contains a subdirectory with the same name as the plugin (e.g. `templates/myplugin/my_template.html`) - In this case, the template can then be loaded (from any plugin!) by loading `myplugin/my_template.html`. @@ -231,8 +229,8 @@ async function example_select(){ } -
- Number of Layers
+ + Number of Layers

Size of Board in mm
diff --git a/docs/docs/extend/plugins/urls.md b/docs/docs/extend/plugins/urls.md index d3da0433ff..ed6b019442 100644 --- a/docs/docs/extend/plugins/urls.md +++ b/docs/docs/extend/plugins/urls.md @@ -60,8 +60,8 @@ The current page base can be found [here](https://github.com/inventree/InvenTree {% block js_ready %} {{ block.super }} enableSidebar('stocklocation'); - - + + {% endblock js_ready %} {% endraw %} - ``` \ No newline at end of file + ```