`;
// Does this input deserve "extra" decorators?
- var extra = parameters.prefix != null;
+ var extra = (parameters.icon != null) || (parameters.prefix != null) || (parameters.prefixRaw != null);
// Some fields can have 'clear' inputs associated with them
if (!parameters.required && !parameters.read_only) {
@@ -1998,9 +1998,13 @@ function constructField(name, parameters, options) {
if (extra) {
html += `
`;
-
+
if (parameters.prefix) {
html += `
${parameters.prefix}`;
+ } else if (parameters.prefixRaw) {
+ html += parameters.prefixRaw;
+ } else if (parameters.icon) {
+ html += `
`;
}
}
@@ -2147,6 +2151,10 @@ function constructInputOptions(name, classes, type, parameters, options={}) {
opts.push(`type='${type}'`);
+ if (parameters.title || parameters.help_text) {
+ opts.push(`title='${parameters.title || parameters.help_text}'`);
+ }
+
// Read only?
if (parameters.read_only) {
opts.push(`readonly=''`);
@@ -2192,11 +2200,6 @@ function constructInputOptions(name, classes, type, parameters, options={}) {
opts.push(`required=''`);
}
- // Custom mouseover title?
- if (parameters.title != null) {
- opts.push(`title='${parameters.title}'`);
- }
-
// Placeholder?
if (parameters.placeholder != null) {
opts.push(`placeholder='${parameters.placeholder}'`);
diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js
index 008091bf15..0ec50022aa 100644
--- a/InvenTree/templates/js/translated/order.js
+++ b/InvenTree/templates/js/translated/order.js
@@ -476,6 +476,25 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
quantity = 0;
}
+ // Prepend toggles to the quantity input
+ var toggle_batch = `
+
+
+
+ `;
+
+ var toggle_serials = `
+
+
+
+ `;
+
+ var prefix_buttons = toggle_batch;
+
+ if (line_item.part_detail.trackable) {
+ prefix_buttons += toggle_serials;
+ }
+
// Quantity to Receive
var quantity_input = constructField(
`items_quantity_${pk}`,
@@ -485,12 +504,49 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
value: quantity,
title: '{% trans "Quantity to receive" %}',
required: true,
+ prefixRaw: prefix_buttons,
},
{
hideLabels: true,
}
);
+ // Add in options for "batch code" and "serial numbers"
+ var batch_input = constructField(
+ `items_batch_code_${pk}`,
+ {
+ type: 'string',
+ required: true,
+ label: '{% trans "Batch Code" %}',
+ help_text: '{% trans "Enter batch code for incoming stock items" %}',
+ prefixRaw: toggle_batch,
+ },
+ {
+ hideLabels: true,
+ }
+ );
+
+ var sn_input = constructField(
+ `items_serial_numbers_${pk}`,
+ {
+ type: 'string',
+ required: true,
+ label: '{% trans "Serial Numbers" %}',
+ help_text: '{% trans "Enter serial numbers for incoming stock items" %}',
+ prefixRaw: toggle_serials,
+ },
+ {
+ hideLabels: true
+ }
+ );
+
+ // Hidden inputs below the "quantity" field
+ var quantity_input_group = `${quantity_input}
${batch_input}
`;
+
+ if (line_item.part_detail.trackable) {
+ quantity_input_group += `
${sn_input}
`;
+ }
+
// Construct list of StockItem status codes
var choices = [];
@@ -554,7 +610,7 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
${line_item.received}
- ${quantity_input}
+ ${quantity_input_group}
|
${status_input}
@@ -678,13 +734,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);
}
|