mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	Add serial number suggestions
This commit is contained in:
		| @@ -53,6 +53,15 @@ class BuildOutputCreateForm(HelperForm): | |||||||
|     Form for creating a new build output. |     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 = { |     field_prefix = { | ||||||
|         'serial_numbers': 'fa-hashtag', |         'serial_numbers': 'fa-hashtag', | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -252,11 +252,17 @@ class BuildOutputCreate(AjaxUpdateView): | |||||||
|  |  | ||||||
|     def get_form(self): |     def get_form(self): | ||||||
|  |  | ||||||
|         form = super().get_form() |  | ||||||
|  |  | ||||||
|         build = self.get_object() |         build = self.get_object() | ||||||
|         part = build.part |         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 the part is not trackable, hide the serial number input | ||||||
|         if not part.trackable: |         if not part.trackable: | ||||||
|             form.fields['serial_numbers'].widget = HiddenInput() |             form.fields['serial_numbers'].widget = HiddenInput() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user