mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 15:15:42 +00:00 
			
		
		
		
	Bug fix for ensuring location and category names are unique for common parent (#4361)
* Update Meta class for StockLocation and PartCategory * Migration files * Add extra unique requirements to InvenTreeTree model - unique_together does not work as expected with null values
This commit is contained in:
		@@ -66,6 +66,11 @@ class PartCategory(MetadataMixin, InvenTreeTree):
 | 
			
		||||
        default_keywords: Default keywords for parts created in this category
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        """Metaclass defines extra model properties"""
 | 
			
		||||
        verbose_name = _("Part Category")
 | 
			
		||||
        verbose_name_plural = _("Part Categories")
 | 
			
		||||
 | 
			
		||||
    def delete_recursive(self, *args, **kwargs):
 | 
			
		||||
        """This function handles the recursive deletion of subcategories depending on kwargs contents"""
 | 
			
		||||
        delete_parts = kwargs.get('delete_parts', False)
 | 
			
		||||
@@ -154,11 +159,6 @@ class PartCategory(MetadataMixin, InvenTreeTree):
 | 
			
		||||
                  "are already assigned to it!"))
 | 
			
		||||
        super().clean()
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        """Metaclass defines extra model properties"""
 | 
			
		||||
        verbose_name = _("Part Category")
 | 
			
		||||
        verbose_name_plural = _("Part Categories")
 | 
			
		||||
 | 
			
		||||
    def get_parts(self, cascade=True) -> set[Part]:
 | 
			
		||||
        """Return a queryset for all parts under this category.
 | 
			
		||||
 | 
			
		||||
@@ -747,7 +747,7 @@ class Part(InvenTreeBarcodeMixin, MetadataMixin, MPTTModel):
 | 
			
		||||
            return helpers.getBlankThumbnail()
 | 
			
		||||
 | 
			
		||||
    def validate_unique(self, exclude=None):
 | 
			
		||||
        """Validate that a part is 'unique'.
 | 
			
		||||
        """Validate that this Part instance is 'unique'.
 | 
			
		||||
 | 
			
		||||
        Uniqueness is checked across the following (case insensitive) fields:
 | 
			
		||||
        - Name
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user