mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-26 10:57:40 +00:00
Merge remote-tracking branch 'inventree/master' into date-format
This commit is contained in:
@@ -476,6 +476,19 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
||||
quantity = 0;
|
||||
}
|
||||
|
||||
// Prepend toggles to the quantity input
|
||||
var toggle_batch = `
|
||||
<span class='input-group-text' title='{% trans "Add batch code" %}' data-bs-toggle='collapse' href='#div-batch-${pk}'>
|
||||
<span class='fas fa-layer-group'></span>
|
||||
</span>
|
||||
`;
|
||||
|
||||
var toggle_serials = `
|
||||
<span class='input-group-text' title='{% trans "Add serial numbers" %}' data-bs-toggle='collapse' href='#div-serials-${pk}'>
|
||||
<span class='fas fa-hashtag'></span>
|
||||
</span>
|
||||
`;
|
||||
|
||||
// Quantity to Receive
|
||||
var quantity_input = constructField(
|
||||
`items_quantity_${pk}`,
|
||||
@@ -491,6 +504,36 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
||||
}
|
||||
);
|
||||
|
||||
// Add in options for "batch code" and "serial numbers"
|
||||
var batch_input = constructField(
|
||||
`items_batch_code_${pk}`,
|
||||
{
|
||||
type: 'string',
|
||||
required: false,
|
||||
label: '{% trans "Batch Code" %}',
|
||||
help_text: '{% trans "Enter batch code for incoming stock items" %}',
|
||||
prefixRaw: toggle_batch,
|
||||
}
|
||||
);
|
||||
|
||||
var sn_input = constructField(
|
||||
`items_serial_numbers_${pk}`,
|
||||
{
|
||||
type: 'string',
|
||||
required: false,
|
||||
label: '{% trans "Serial Numbers" %}',
|
||||
help_text: '{% trans "Enter serial numbers for incoming stock items" %}',
|
||||
prefixRaw: toggle_serials,
|
||||
}
|
||||
);
|
||||
|
||||
// Hidden inputs below the "quantity" field
|
||||
var quantity_input_group = `${quantity_input}<div class='collapse' id='div-batch-${pk}'>${batch_input}</div>`;
|
||||
|
||||
if (line_item.part_detail.trackable) {
|
||||
quantity_input_group += `<div class='collapse' id='div-serials-${pk}'>${sn_input}</div>`;
|
||||
}
|
||||
|
||||
// Construct list of StockItem status codes
|
||||
var choices = [];
|
||||
|
||||
@@ -528,16 +571,38 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
||||
);
|
||||
|
||||
// Button to remove the row
|
||||
var delete_button = `<div class='btn-group float-right' role='group'>`;
|
||||
var buttons = `<div class='btn-group float-right' role='group'>`;
|
||||
|
||||
delete_button += makeIconButton(
|
||||
buttons += makeIconButton(
|
||||
'fa-layer-group',
|
||||
'button-row-add-batch',
|
||||
pk,
|
||||
'{% trans "Add batch code" %}',
|
||||
{
|
||||
collapseTarget: `div-batch-${pk}`
|
||||
}
|
||||
);
|
||||
|
||||
if (line_item.part_detail.trackable) {
|
||||
buttons += makeIconButton(
|
||||
'fa-hashtag',
|
||||
'button-row-add-serials',
|
||||
pk,
|
||||
'{% trans "Add serial numbers" %}',
|
||||
{
|
||||
collapseTarget: `div-serials-${pk}`,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
buttons += makeIconButton(
|
||||
'fa-times icon-red',
|
||||
'button-row-remove',
|
||||
pk,
|
||||
'{% trans "Remove row" %}',
|
||||
);
|
||||
|
||||
delete_button += '</div>';
|
||||
buttons += '</div>';
|
||||
|
||||
var html = `
|
||||
<tr id='receive_row_${pk}' class='stock-receive-row'>
|
||||
@@ -554,7 +619,7 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
||||
${line_item.received}
|
||||
</td>
|
||||
<td id='quantity_${pk}'>
|
||||
${quantity_input}
|
||||
${quantity_input_group}
|
||||
</td>
|
||||
<td id='status_${pk}'>
|
||||
${status_input}
|
||||
@@ -563,7 +628,7 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
||||
${destination_input}
|
||||
</td>
|
||||
<td id='actions_${pk}'>
|
||||
${delete_button}
|
||||
${buttons}
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
@@ -587,7 +652,7 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
||||
<th>{% trans "Order Code" %}</th>
|
||||
<th>{% trans "Ordered" %}</th>
|
||||
<th>{% trans "Received" %}</th>
|
||||
<th style='min-width: 50px;'>{% trans "Receive" %}</th>
|
||||
<th style='min-width: 50px;'>{% trans "Quantity to Receive" %}</th>
|
||||
<th style='min-width: 150px;'>{% trans "Status" %}</th>
|
||||
<th style='min-width: 300px;'>{% trans "Destination" %}</th>
|
||||
<th></th>
|
||||
@@ -678,13 +743,23 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
||||
var location = getFormFieldValue(`items_location_${pk}`, {}, opts);
|
||||
|
||||
if (quantity != null) {
|
||||
data.items.push({
|
||||
|
||||
var line = {
|
||||
line_item: pk,
|
||||
quantity: quantity,
|
||||
status: status,
|
||||
location: location,
|
||||
});
|
||||
};
|
||||
|
||||
if (getFormFieldElement(`items_batch_code_${pk}`).exists()) {
|
||||
line.batch_code = getFormFieldValue(`items_batch_code_${pk}`);
|
||||
}
|
||||
|
||||
if (getFormFieldElement(`items_serial_numbers_${pk}`).exists()) {
|
||||
line.serial_numbers = getFormFieldValue(`items_serial_numbers_${pk}`);
|
||||
}
|
||||
|
||||
data.items.push(line);
|
||||
item_pk_values.push(pk);
|
||||
}
|
||||
|
||||
@@ -936,6 +1011,7 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
|
||||
reference: {},
|
||||
purchase_price: {},
|
||||
purchase_price_currency: {},
|
||||
target_date: {},
|
||||
destination: {},
|
||||
notes: {},
|
||||
},
|
||||
@@ -977,7 +1053,11 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
|
||||
],
|
||||
{
|
||||
success: function() {
|
||||
// Reload the line item table
|
||||
$(table).bootstrapTable('refresh');
|
||||
|
||||
// Reload the "received stock" table
|
||||
$('#stock-table').bootstrapTable('refresh');
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -1117,6 +1197,28 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
|
||||
return formatter.format(total);
|
||||
}
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'target_date',
|
||||
switchable: true,
|
||||
title: '{% trans "Target Date" %}',
|
||||
formatter: function(value, row) {
|
||||
if (row.target_date) {
|
||||
var html = row.target_date;
|
||||
|
||||
if (row.overdue) {
|
||||
html += `<span class='fas fa-calendar-alt icon-red float-right' title='{% trans "This line item is overdue" %}'></span>`;
|
||||
}
|
||||
|
||||
return html;
|
||||
|
||||
} else if (row.order_detail && row.order_detail.target_date) {
|
||||
return `<em>${row.order_detail.target_date}</em>`;
|
||||
} else {
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
sortable: false,
|
||||
field: 'received',
|
||||
@@ -1163,15 +1265,15 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
|
||||
|
||||
var pk = row.pk;
|
||||
|
||||
if (options.allow_receive && row.received < row.quantity) {
|
||||
html += makeIconButton('fa-sign-in-alt icon-green', 'button-line-receive', pk, '{% trans "Receive line item" %}');
|
||||
}
|
||||
|
||||
if (options.allow_edit) {
|
||||
html += makeIconButton('fa-edit icon-blue', 'button-line-edit', pk, '{% trans "Edit line item" %}');
|
||||
html += makeIconButton('fa-trash-alt icon-red', 'button-line-delete', pk, '{% trans "Delete line item" %}');
|
||||
}
|
||||
|
||||
if (options.allow_receive && row.received < row.quantity) {
|
||||
html += makeIconButton('fa-sign-in-alt', 'button-line-receive', pk, '{% trans "Receive line item" %}');
|
||||
}
|
||||
|
||||
html += `</div>`;
|
||||
|
||||
return html;
|
||||
@@ -2223,6 +2325,28 @@ function loadSalesOrderLineItemTable(table, options={}) {
|
||||
return formatter.format(total);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'target_date',
|
||||
title: '{% trans "Target Date" %}',
|
||||
sortable: true,
|
||||
switchable: true,
|
||||
formatter: function(value, row) {
|
||||
if (row.target_date) {
|
||||
var html = row.target_date;
|
||||
|
||||
if (row.overdue) {
|
||||
html += `<span class='fas fa-calendar-alt icon-red float-right' title='{% trans "This line item is overdue" %}'></span>`;
|
||||
}
|
||||
|
||||
return html;
|
||||
|
||||
} else if (row.order_detail && row.order_detail.target_date) {
|
||||
return `<em>${row.order_detail.target_date}</em>`;
|
||||
} else {
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
if (pending) {
|
||||
@@ -2366,6 +2490,7 @@ function loadSalesOrderLineItemTable(table, options={}) {
|
||||
reference: {},
|
||||
sale_price: {},
|
||||
sale_price_currency: {},
|
||||
target_date: {},
|
||||
notes: {},
|
||||
},
|
||||
title: '{% trans "Edit Line Item" %}',
|
||||
|
||||
Reference in New Issue
Block a user