mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Merge pull request #1789 from SchrodingersGat/supplier-part-table
Add more fields to ManufacturerPart and SupplierPart tables
This commit is contained in:
		| @@ -35,8 +35,8 @@ function loadTree(url, tree, options={}) { | |||||||
|                     showTags: true, |                     showTags: true, | ||||||
|                 }); |                 }); | ||||||
|  |  | ||||||
|                 if (sessionStorage.getItem(key)) { |                 if (localStorage.getItem(key)) { | ||||||
|                     var saved_exp = sessionStorage.getItem(key).split(","); |                     var saved_exp = localStorage.getItem(key).split(","); | ||||||
|  |  | ||||||
|                     // Automatically expand the desired notes |                     // Automatically expand the desired notes | ||||||
|                     for (var q = 0; q < saved_exp.length; q++) { |                     for (var q = 0; q < saved_exp.length; q++) { | ||||||
| @@ -57,7 +57,7 @@ function loadTree(url, tree, options={}) { | |||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     // Save the expanded nodes |                     // Save the expanded nodes | ||||||
|                     sessionStorage.setItem(key, exp); |                     localStorage.setItem(key, exp); | ||||||
|                 }); |                 }); | ||||||
|             } |             } | ||||||
|         }, |         }, | ||||||
| @@ -106,17 +106,17 @@ function initNavTree(options) { | |||||||
|                             width: '0px' |                             width: '0px' | ||||||
|                         }, 50); |                         }, 50); | ||||||
|  |  | ||||||
|                         sessionStorage.setItem(stateLabel, 'closed'); |                         localStorage.setItem(stateLabel, 'closed'); | ||||||
|                     } else { |                     } else { | ||||||
|                         sessionStorage.setItem(stateLabel, 'open'); |                         localStorage.setItem(stateLabel, 'open'); | ||||||
|                         sessionStorage.setItem(widthLabel, `${width}px`); |                         localStorage.setItem(widthLabel, `${width}px`); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         var state = sessionStorage.getItem(stateLabel); |         var state = localStorage.getItem(stateLabel); | ||||||
|         var width = sessionStorage.getItem(widthLabel) || '300px'; |         var width = localStorage.getItem(widthLabel) || '300px'; | ||||||
|  |  | ||||||
|         if (state && state == 'open') { |         if (state && state == 'open') { | ||||||
|  |  | ||||||
| @@ -131,21 +131,21 @@ function initNavTree(options) { | |||||||
|          |          | ||||||
|         $(toggleId).click(function() { |         $(toggleId).click(function() { | ||||||
|  |  | ||||||
|             var state = sessionStorage.getItem(stateLabel) || 'closed'; |             var state = localStorage.getItem(stateLabel) || 'closed'; | ||||||
|             var width = sessionStorage.getItem(widthLabel) || '300px'; |             var width = localStorage.getItem(widthLabel) || '300px'; | ||||||
|  |  | ||||||
|             if (state == 'open') { |             if (state == 'open') { | ||||||
|                 $(treeId).animate({ |                 $(treeId).animate({ | ||||||
|                     width: '0px' |                     width: '0px' | ||||||
|                 }, 50); |                 }, 50); | ||||||
|  |  | ||||||
|                 sessionStorage.setItem(stateLabel, 'closed'); |                 localStorage.setItem(stateLabel, 'closed'); | ||||||
|             } else { |             } else { | ||||||
|                 $(treeId).animate({ |                 $(treeId).animate({ | ||||||
|                     width: width, |                     width: width, | ||||||
|                 }, 50); |                 }, 50); | ||||||
|  |  | ||||||
|                 sessionStorage.setItem(stateLabel, 'open'); |                 localStorage.setItem(stateLabel, 'open'); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| @@ -198,17 +198,20 @@ function enableNavbar(options) { | |||||||
|                             width: '45px' |                             width: '45px' | ||||||
|                         }, 50); |                         }, 50); | ||||||
|  |  | ||||||
|                         sessionStorage.setItem(stateLabel, 'closed'); |                         localStorage.setItem(stateLabel, 'closed'); | ||||||
|                     } else { |                     } else { | ||||||
|                         sessionStorage.setItem(widthLabel, `${width}px`); |                         localStorage.setItem(widthLabel, `${width}px`); | ||||||
|                         sessionStorage.setItem(stateLabel, 'open'); |                         localStorage.setItem(stateLabel, 'open'); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         var state = sessionStorage.getItem(stateLabel); |         var state = localStorage.getItem(stateLabel); | ||||||
|         var width = sessionStorage.getItem(widthLabel) || '250px'; |  | ||||||
|  |         console.log(stateLabel, '->', state); | ||||||
|  |  | ||||||
|  |         var width = localStorage.getItem(widthLabel) || '250px'; | ||||||
|          |          | ||||||
|         if (state && state == 'open') { |         if (state && state == 'open') { | ||||||
|  |  | ||||||
| @@ -224,8 +227,8 @@ function enableNavbar(options) { | |||||||
|  |  | ||||||
|         $(toggleId).click(function() { |         $(toggleId).click(function() { | ||||||
|  |  | ||||||
|             var state = sessionStorage.getItem(stateLabel) || 'closed'; |             var state = localStorage.getItem(stateLabel) || 'closed'; | ||||||
|             var width = sessionStorage.getItem(widthLabel) || '250px'; |             var width = localStorage.getItem(widthLabel) || '250px'; | ||||||
|  |  | ||||||
|             if (state == 'open') { |             if (state == 'open') { | ||||||
|                 $(navId).animate({ |                 $(navId).animate({ | ||||||
| @@ -233,7 +236,7 @@ function enableNavbar(options) { | |||||||
|                     minWidth: '45px', |                     minWidth: '45px', | ||||||
|                 }, 50); |                 }, 50); | ||||||
|  |  | ||||||
|                 sessionStorage.setItem(stateLabel, 'closed'); |                 localStorage.setItem(stateLabel, 'closed'); | ||||||
|  |  | ||||||
|             } else { |             } else { | ||||||
|  |  | ||||||
| @@ -241,7 +244,7 @@ function enableNavbar(options) { | |||||||
|                     'width': width |                     'width': width | ||||||
|                 }, 50); |                 }, 50); | ||||||
|  |  | ||||||
|                 sessionStorage.setItem(stateLabel, 'open'); |                 localStorage.setItem(stateLabel, 'open'); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -206,24 +206,27 @@ class SupplierPartSerializer(InvenTreeModelSerializer): | |||||||
|  |  | ||||||
|     MPN = serializers.StringRelatedField(source='manufacturer_part.MPN') |     MPN = serializers.StringRelatedField(source='manufacturer_part.MPN') | ||||||
|  |  | ||||||
|     manufacturer_part = ManufacturerPartSerializer(read_only=True) |     manufacturer_part_detail = ManufacturerPartSerializer(source='manufacturer_part', read_only=True) | ||||||
|  |  | ||||||
|     class Meta: |     class Meta: | ||||||
|         model = SupplierPart |         model = SupplierPart | ||||||
|         fields = [ |         fields = [ | ||||||
|  |             'description', | ||||||
|  |             'link', | ||||||
|  |             'manufacturer', | ||||||
|  |             'manufacturer_detail', | ||||||
|  |             'manufacturer_part', | ||||||
|  |             'manufacturer_part_detail', | ||||||
|  |             'MPN', | ||||||
|  |             'note', | ||||||
|             'pk', |             'pk', | ||||||
|  |             'packaging', | ||||||
|             'part', |             'part', | ||||||
|             'part_detail', |             'part_detail', | ||||||
|             'pretty_name', |             'pretty_name', | ||||||
|  |             'SKU', | ||||||
|             'supplier', |             'supplier', | ||||||
|             'supplier_detail', |             'supplier_detail', | ||||||
|             'SKU', |  | ||||||
|             'manufacturer', |  | ||||||
|             'MPN', |  | ||||||
|             'manufacturer_detail', |  | ||||||
|             'manufacturer_part', |  | ||||||
|             'description', |  | ||||||
|             'link', |  | ||||||
|         ] |         ] | ||||||
|  |  | ||||||
|     def create(self, validated_data): |     def create(self, validated_data): | ||||||
|   | |||||||
| @@ -230,7 +230,7 @@ class ManufacturerTest(InvenTreeAPITestCase): | |||||||
|         self.assertEqual(response.status_code, status.HTTP_201_CREATED) |         self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||||||
|  |  | ||||||
|         # Check manufacturer part |         # Check manufacturer part | ||||||
|         manufacturer_part_id = int(response.data['manufacturer_part']['pk']) |         manufacturer_part_id = int(response.data['manufacturer_part_detail']['pk']) | ||||||
|         url = reverse('api-manufacturer-part-detail', kwargs={'pk': manufacturer_part_id}) |         url = reverse('api-manufacturer-part-detail', kwargs={'pk': manufacturer_part_id}) | ||||||
|         response = self.get(url) |         response = self.get(url) | ||||||
|         self.assertEqual(response.data['MPN'], 'PART_NUMBER') |         self.assertEqual(response.data['MPN'], 'PART_NUMBER') | ||||||
|   | |||||||
| @@ -318,6 +318,12 @@ function loadManufacturerPartTable(table, url, options) { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|  |             { | ||||||
|  |                 field: 'description', | ||||||
|  |                 title: '{% trans "Description" %}', | ||||||
|  |                 sortable: false, | ||||||
|  |                 switchable: true, | ||||||
|  |             } | ||||||
|         ], |         ], | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
| @@ -550,6 +556,21 @@ function loadSupplierPartTable(table, url, options) { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|  |             { | ||||||
|  |                 field: 'description', | ||||||
|  |                 title: '{% trans "Description" %}', | ||||||
|  |                 sortable: false, | ||||||
|  |             }, | ||||||
|  |             { | ||||||
|  |                 field: 'note', | ||||||
|  |                 title: '{% trans "Notes" %}', | ||||||
|  |                 sortable: false, | ||||||
|  |             }, | ||||||
|  |             { | ||||||
|  |                 field: 'packaging', | ||||||
|  |                 title: '{% trans "Packaging" %}', | ||||||
|  |                 sortable: false, | ||||||
|  |             } | ||||||
|         ], |         ], | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
		Reference in New Issue
	
	Block a user