mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 20:45:44 +00:00
Add a "sales_order" reference to the Build model
- If a build order is made to fulfil a sales order - Add sales_order filtering to the Build API - Pass initial information through to the BuildCreate view
This commit is contained in:
@ -6,6 +6,9 @@
|
||||
{% load static %}
|
||||
|
||||
{% block details %}
|
||||
|
||||
{% include "order/so_tabs.html" with tab='details' %}
|
||||
|
||||
<hr>
|
||||
|
||||
<h4>{% trans "Sales Order Items" %}</h4>
|
||||
@ -45,6 +48,7 @@ $("#so-lines-table").inventreeTable({
|
||||
part_detail: true,
|
||||
allocations: true,
|
||||
},
|
||||
uniqueId: 'pk',
|
||||
url: "{% url 'api-so-line-list' %}",
|
||||
onPostBody: setupCallbacks,
|
||||
detailViewByClick: true,
|
||||
@ -242,12 +246,28 @@ function setupCallbacks() {
|
||||
});
|
||||
|
||||
table.find(".button-build").click(function() {
|
||||
|
||||
var pk = $(this).attr('pk');
|
||||
|
||||
// Extract the row data from the table!
|
||||
var idx = $(this).closest('tr').attr('data-index');
|
||||
|
||||
var row = table.bootstrapTable('getData')[idx];
|
||||
|
||||
console.log('Row ' + idx + ' - ' + row.pk + ', ' + row.quantity);
|
||||
|
||||
var quantity = 1;
|
||||
|
||||
if (row.allocated < row.quantity) {
|
||||
quantity = row.quantity - row.allocated;
|
||||
}
|
||||
|
||||
launchModalForm(`/build/new/`, {
|
||||
follow: true,
|
||||
data: {
|
||||
part: pk,
|
||||
sales_order: {{ order.id }},
|
||||
quantity: quantity,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user