2
0
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:
Oliver
2022-09-21 18:19:31 +10:00
committed by GitHub
parent 2a846c7030
commit 33326f6eaf
3 changed files with 71 additions and 44 deletions

View File

@ -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()),

View File

@ -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 %}