mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Bug fix for creating Part or Company via API (#4264)
- If specified, the "remote_image" field is passed through to the __init__ method - Throws a 500 error - Solution is to explicitly ignore the provided field
This commit is contained in:
		| @@ -94,6 +94,17 @@ class Company(MetadataMixin, models.Model): | ||||
|         ] | ||||
|         verbose_name_plural = "Companies" | ||||
|  | ||||
|     def __init__(self, *args, **kwargs): | ||||
|         """Custom initialization routine for the Company model. | ||||
|  | ||||
|         Ensures that custom serializer fields (without matching model fields) are removed | ||||
|         """ | ||||
|  | ||||
|         # Remote image specified during creation via API | ||||
|         kwargs.pop('remote_image', None) | ||||
|  | ||||
|         super().__init__(*args, **kwargs) | ||||
|  | ||||
|     name = models.CharField(max_length=100, blank=False, | ||||
|                             help_text=_('Company name'), | ||||
|                             verbose_name=_('Company name')) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user