mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add serial number suggestions
This commit is contained in:
parent
8d0845d92b
commit
5988e847ce
@ -53,6 +53,15 @@ class BuildOutputCreateForm(HelperForm):
|
||||
Form for creating a new build output.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
build = kwargs.pop('build', None)
|
||||
|
||||
if build:
|
||||
self.field_placeholder['serial_numbers'] = build.part.getSerialNumberString()
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
field_prefix = {
|
||||
'serial_numbers': 'fa-hashtag',
|
||||
}
|
||||
|
@ -252,11 +252,17 @@ class BuildOutputCreate(AjaxUpdateView):
|
||||
|
||||
def get_form(self):
|
||||
|
||||
form = super().get_form()
|
||||
|
||||
build = self.get_object()
|
||||
part = build.part
|
||||
|
||||
context = self.get_form_kwargs()
|
||||
|
||||
# Pass the 'part' through to the form,
|
||||
# so we can add the next serial number as a placeholder
|
||||
context['build'] = build
|
||||
|
||||
form = self.form_class(**context)
|
||||
|
||||
# If the part is not trackable, hide the serial number input
|
||||
if not part.trackable:
|
||||
form.fields['serial_numbers'].widget = HiddenInput()
|
||||
|
Loading…
Reference in New Issue
Block a user