mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 21:25:42 +00:00 
			
		
		
		
	Merge pull request #2477 from SchrodingersGat/duplicate-bom-form
Duplicate bom form
This commit is contained in:
		| @@ -207,6 +207,11 @@ function showApiError(xhr, url) { | ||||
|         title = '{% trans "Error 404: Resource Not Found" %}'; | ||||
|         message = '{% trans "The requested resource could not be located on the server" %}'; | ||||
|         break; | ||||
|     // Method not allowed | ||||
|     case 405: | ||||
|         title = '{% trans "Error 405: Method Not Allowed" %}'; | ||||
|         message = '{% trans "HTTP method not allowed at URL" %}'; | ||||
|         break; | ||||
|     // Timeout | ||||
|     case 408: | ||||
|         title = '{% trans "Error 408: Timeout" %}'; | ||||
|   | ||||
| @@ -661,7 +661,7 @@ function loadBomTable(table, options={}) { | ||||
|             if (!row.inherited) { | ||||
|                 return yesNoLabel(false); | ||||
|             } else if (row.part == options.parent_id) { | ||||
|                 return '{% trans "Inherited" %}'; | ||||
|                 return yesNoLabel(true); | ||||
|             } else { | ||||
|                 // If this BOM item is inherited from a parent part | ||||
|                 return renderLink( | ||||
|   | ||||
| @@ -21,6 +21,7 @@ | ||||
| */ | ||||
|  | ||||
| /* exported | ||||
|     duplicateBom, | ||||
|     duplicatePart, | ||||
|     editCategory, | ||||
|     editPart, | ||||
| @@ -39,6 +40,7 @@ | ||||
|     loadStockPricingChart, | ||||
|     partStockLabel, | ||||
|     toggleStar, | ||||
|     validateBom, | ||||
| */ | ||||
|  | ||||
| /* Part API functions | ||||
| @@ -428,6 +430,59 @@ function toggleStar(options) { | ||||
| } | ||||
|  | ||||
|  | ||||
| /* Validate a BOM */ | ||||
| function validateBom(part_id, options={}) { | ||||
|  | ||||
|     var html = ` | ||||
|     <div class='alert alert-block alert-success'> | ||||
|     {% trans "Validating the BOM will mark each line item as valid" %} | ||||
|     </div> | ||||
|     `; | ||||
|  | ||||
|     constructForm(`/api/part/${part_id}/bom-validate/`, { | ||||
|         method: 'PUT', | ||||
|         fields: { | ||||
|             valid: {}, | ||||
|         }, | ||||
|         preFormContent: html, | ||||
|         title: '{% trans "Validate Bill of Materials" %}', | ||||
|         reload: options.reload, | ||||
|         onSuccess: function(response) { | ||||
|             showMessage('{% trans "Validated Bill of Materials" %}'); | ||||
|         } | ||||
|     }); | ||||
| } | ||||
|  | ||||
|  | ||||
| /* Duplicate a BOM */ | ||||
| function duplicateBom(part_id, options={}) { | ||||
|  | ||||
|     constructForm(`/api/part/${part_id}/bom-copy/`, { | ||||
|         method: 'POST', | ||||
|         fields: { | ||||
|             part: { | ||||
|                 icon: 'fa-shapes', | ||||
|                 filters: { | ||||
|                     assembly: true, | ||||
|                     exclude_tree: part_id, | ||||
|                 } | ||||
|             }, | ||||
|             include_inherited: {}, | ||||
|             remove_existing: {}, | ||||
|             skip_invalid: {}, | ||||
|         }, | ||||
|         confirm: true, | ||||
|         title: '{% trans "Copy Bill of Materials" %}', | ||||
|         onSuccess: function(response) { | ||||
|             if (options.success) { | ||||
|                 options.success(response); | ||||
|             } | ||||
|         }, | ||||
|     }); | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| function partStockLabel(part, options={}) { | ||||
|  | ||||
|     if (part.in_stock) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user