mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-12 10:12:58 +00:00
Display error if stock item is "double allocted"
This commit is contained in:
parent
81638d06cf
commit
6b4592b3dc
@ -630,6 +630,7 @@ class BuildAllocationItemSerializer(serializers.Serializer):
|
|||||||
|
|
||||||
super().validate(data)
|
super().validate(data)
|
||||||
|
|
||||||
|
build = self.context['build']
|
||||||
bom_item = data['bom_item']
|
bom_item = data['bom_item']
|
||||||
stock_item = data['stock_item']
|
stock_item = data['stock_item']
|
||||||
quantity = data['quantity']
|
quantity = data['quantity']
|
||||||
@ -654,16 +655,20 @@ class BuildAllocationItemSerializer(serializers.Serializer):
|
|||||||
# Output *must* be set for trackable parts
|
# Output *must* be set for trackable parts
|
||||||
if output is None and bom_item.sub_part.trackable:
|
if output is None and bom_item.sub_part.trackable:
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
'output': _('Build output must be specified for allocation of tracked parts')
|
'output': _('Build output must be specified for allocation of tracked parts'),
|
||||||
})
|
})
|
||||||
|
|
||||||
# Output *cannot* be set for un-tracked parts
|
# Output *cannot* be set for un-tracked parts
|
||||||
if output is not None and not bom_item.sub_part.trackable:
|
if output is not None and not bom_item.sub_part.trackable:
|
||||||
|
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
'output': _('Build output cannot be specified for allocation of untracked parts')
|
'output': _('Build output cannot be specified for allocation of untracked parts'),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Check if this allocation would be unique
|
||||||
|
if BuildItem.objects.filter(build=build, stock_item=stock_item, install_into=output).exists():
|
||||||
|
raise ValidationError(_('This stock item has already been allocated to this build output'))
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
@ -1982,7 +1982,7 @@ function allocateStockToBuild(build_id, part_id, bom_items, options={}) {
|
|||||||
// var stock_input = constructRelatedFieldInput(`items_stock_item_${pk}`);
|
// var stock_input = constructRelatedFieldInput(`items_stock_item_${pk}`);
|
||||||
|
|
||||||
var html = `
|
var html = `
|
||||||
<tr id='allocation_row_${pk}' class='part-allocation-row'>
|
<tr id='items_${pk}' class='part-allocation-row'>
|
||||||
<td id='part_${pk}'>
|
<td id='part_${pk}'>
|
||||||
${thumb} ${sub_part.full_name}
|
${thumb} ${sub_part.full_name}
|
||||||
</td>
|
</td>
|
||||||
@ -2167,7 +2167,7 @@ function allocateStockToBuild(build_id, part_id, bom_items, options={}) {
|
|||||||
$(options.modal).find('.button-row-remove').click(function() {
|
$(options.modal).find('.button-row-remove').click(function() {
|
||||||
var pk = $(this).attr('pk');
|
var pk = $(this).attr('pk');
|
||||||
|
|
||||||
$(options.modal).find(`#allocation_row_${pk}`).remove();
|
$(options.modal).find(`#items_${pk}`).remove();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onSubmit: function(fields, opts) {
|
onSubmit: function(fields, opts) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user