mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	form overrides
This commit is contained in:
		| @@ -191,10 +191,27 @@ class FileManagementFormView(MultiStepFormView): | ||||
|  | ||||
|     def __init__(self, *args, **kwargs): | ||||
|         """ initialize the FormView """ | ||||
|         # perform all checks and inits from MultiStepFormView | ||||
|         # check if form_list should be overriden | ||||
|         if hasattr(self, 'form_list_override'): | ||||
|             # check for list | ||||
|             if not isinstance(self.form_list_override, list): | ||||
|                 raise ValueError('form_list_override must be a list') | ||||
|  | ||||
|             # loop through and override /add form_list enrties | ||||
|             for entry in self.form_list_override: | ||||
|                 # fetch postition | ||||
|                 pos = [self.form_list.index(i) for i in self.form_list if i[0] == 'items'] | ||||
|                 # replace if exists | ||||
|                 if pos: | ||||
|                     self.form_list[pos[0]] = entry | ||||
|                 # or append | ||||
|                 else: | ||||
|                     self.form_list.append(entry) | ||||
|  | ||||
|         # perform all checks and inits for MultiStepFormView | ||||
|         super().__init__(*args, **kwargs) | ||||
|  | ||||
|         # Check  | ||||
|         # Check for file manager class | ||||
|         if not(hasattr(self, 'file_manager_class') and issubclass(self.file_manager_class, FileManager)): | ||||
|             raise NotImplementedError('A subclass of a file manager class needs to be set!') | ||||
|  | ||||
|   | ||||
| @@ -32,6 +32,7 @@ from part.models import Part | ||||
| from common.models import InvenTreeSetting | ||||
| from common.views import FileManagementFormView | ||||
| from common.files import FileManager | ||||
| from common import forms as cm_forms | ||||
|  | ||||
| from . import forms as order_forms | ||||
| from part.views import PartPricing | ||||
| @@ -573,7 +574,16 @@ class SalesOrderShip(AjaxUpdateView): | ||||
| class PurchaseOrderUpload(FileManagementFormView): | ||||
|     ''' PurchaseOrder: Upload file, match to fields and parts (using multi-Step form) ''' | ||||
|  | ||||
|     class MyMatch(cm_forms.MatchItem): | ||||
|         """ override MatchItem fields """ | ||||
|         def get_special_field(self, col_guess, row, file_manager): | ||||
|             """ set special field """ | ||||
|             # run default | ||||
|             super().get_special_field(col_guess, row, file_manager) | ||||
|     name = 'order' | ||||
|     form_list_override = [ | ||||
|         ('items', MyMatch), | ||||
|     ] | ||||
|     form_steps_template = [ | ||||
|         'order/order_wizard/po_upload.html', | ||||
|         'order/order_wizard/match_fields.html', | ||||
| @@ -584,7 +594,6 @@ class PurchaseOrderUpload(FileManagementFormView): | ||||
|         _("Match Fields"), | ||||
|         _("Match Supplier Parts"), | ||||
|     ] | ||||
|     # Form field name: PurchaseOrderLineItem field | ||||
|     form_field_map = { | ||||
|         'item_select': 'part', | ||||
|         'quantity': 'quantity', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user