mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 12:35:46 +00:00
Update CompleteBuildOrder form (#3702)
- Load required data dynamically via the API - Hide form fields according to dynamic data - Show warnings according to dynamic data
This commit is contained in:
@ -490,6 +490,21 @@ class OverallocationChoice():
|
||||
class BuildCompleteSerializer(serializers.Serializer):
|
||||
"""DRF serializer for marking a BuildOrder as complete."""
|
||||
|
||||
def get_context_data(self):
|
||||
"""Retrieve extra context data for this serializer.
|
||||
|
||||
This is so we can determine (at run time) whether the build is ready to be completed.
|
||||
"""
|
||||
|
||||
build = self.context['build']
|
||||
|
||||
return {
|
||||
'overallocated': build.has_overallocated_parts(),
|
||||
'allocated': build.are_untracked_parts_allocated(),
|
||||
'remaining': build.remaining,
|
||||
'incomplete': build.incomplete_count,
|
||||
}
|
||||
|
||||
accept_overallocated = serializers.ChoiceField(
|
||||
label=_('Overallocated Stock'),
|
||||
choices=list(OverallocationChoice.OPTIONS.items()),
|
||||
|
@ -228,11 +228,7 @@ src="{% static 'img/blank_image.png' %}"
|
||||
});
|
||||
|
||||
$("#build-complete").on('click', function() {
|
||||
completeBuildOrder({{ build.pk }}, {
|
||||
overallocated: {% if build.has_overallocated_parts %}true{% else %}false{% endif %},
|
||||
allocated: {% if build.are_untracked_parts_allocated %}true{% else %}false{% endif %},
|
||||
completed: {% if build.remaining == 0 %}true{% else %}false{% endif %},
|
||||
});
|
||||
completeBuildOrder({{ build.pk }});
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
|
Reference in New Issue
Block a user