mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Use set_null instead
This commit is contained in:
		| @@ -21,7 +21,6 @@ class CompanyResource(ModelResource): | ||||
|  | ||||
|     class Meta: | ||||
|         model = Company | ||||
|         exclude = ('is_deleted', ) | ||||
|         skip_unchanged = True | ||||
|         report_skipped = False | ||||
|         clean_model_instances = True | ||||
| @@ -38,14 +37,6 @@ class CompanyAdmin(ImportExportModelAdmin): | ||||
|         'description', | ||||
|     ] | ||||
|  | ||||
|     exclude = ('is_deleted',) | ||||
|  | ||||
|     def has_delete_permission(self, request, obj=None): | ||||
|         """Magic objects are not allowd to be deleted""" | ||||
|         if obj and obj.is_deleted: | ||||
|             return False | ||||
|         return True | ||||
|  | ||||
|  | ||||
| class SupplierPartResource(ModelResource): | ||||
|     """ | ||||
|   | ||||
| @@ -60,20 +60,6 @@ def rename_company_image(instance, filename): | ||||
|     return os.path.join(base, fn) | ||||
|  | ||||
|  | ||||
| def get_deleted_company(): | ||||
|     """ | ||||
|     Returns the deleted company object | ||||
|     """ | ||||
|     return Company.objects.get_or_create( | ||||
|         name='deleted', | ||||
|         email='deleted', | ||||
|         is_deleted=True, | ||||
|         is_customer=True, | ||||
|         is_supplier=True, | ||||
|         is_manufacturer=True | ||||
|     )[0] | ||||
|  | ||||
|  | ||||
| class Company(models.Model): | ||||
|     """ A Company object represents an external company. | ||||
|     It may be a supplier or a customer or a manufacturer (or a combination) | ||||
| @@ -161,8 +147,6 @@ class Company(models.Model): | ||||
|  | ||||
|     is_manufacturer = models.BooleanField(default=False, verbose_name=_('is manufacturer'), help_text=_('Does this company manufacture parts?')) | ||||
|  | ||||
|     is_deleted = models.BooleanField(default=False, verbose_name=_('is deleted'), help_text=_('Is this company a deleted placeholder?')) | ||||
|  | ||||
|     currency = models.CharField( | ||||
|         max_length=3, | ||||
|         verbose_name=_('Currency'), | ||||
| @@ -282,18 +266,6 @@ class Company(models.Model): | ||||
|  | ||||
|         return self.purchase_orders.filter(status__in=PurchaseOrderStatus.FAILED) | ||||
|  | ||||
|     def save(self, *args, **kwargs): | ||||
|         """Save the instance, unless it is the magic already deleted object""" | ||||
|         if self.pk and self.is_deleted: | ||||
|             raise PermissionDenied(_('This company is a placeholder and can not be updated')) | ||||
|         return super().save(*args, **kwargs) | ||||
|  | ||||
|     def delete(self, *args, **kwargs): | ||||
|         """Delete the instance, unless it is the magic already deleted object""" | ||||
|         if self.is_deleted: | ||||
|             raise PermissionDenied(_('This company is a placeholder and can not be deleted')) | ||||
|         return super().delete(*args, **kwargs) | ||||
|  | ||||
|  | ||||
| class Contact(models.Model): | ||||
|     """ A Contact represents a person who works at a particular company. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user