2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-06 05:30:56 +00:00

Remove the "scheduled_for_deletion" field from the StockItem model

Reverts back to the original behaviour - stock items are just deleted
This commit is contained in:
Oliver
2021-12-05 18:14:14 +11:00
parent a821717103
commit 93a240d9c3
9 changed files with 35 additions and 107 deletions

View File

@ -212,18 +212,12 @@ class StockItem(MPTTModel):
belongs_to=None,
customer=None,
is_building=False,
status__in=StockStatus.AVAILABLE_CODES,
scheduled_for_deletion=False,
status__in=StockStatus.AVAILABLE_CODES
)
# A query filter which can be used to filter StockItem objects which have expired
EXPIRED_FILTER = IN_STOCK_FILTER & ~Q(expiry_date=None) & Q(expiry_date__lt=datetime.now().date())
def mark_for_deletion(self):
self.scheduled_for_deletion = True
self.save()
def update_serial_number(self):
"""
Update the 'serial_int' field, to be an integer representation of the serial number.
@ -615,12 +609,6 @@ class StockItem(MPTTModel):
help_text=_('Select Owner'),
related_name='stock_items')
scheduled_for_deletion = models.BooleanField(
default=False,
verbose_name=_('Scheduled for deletion'),
help_text=_('This StockItem will be deleted by the background worker'),
)
def is_stale(self):
"""
Returns True if this Stock item is "stale".
@ -1327,7 +1315,7 @@ class StockItem(MPTTModel):
self.quantity = quantity
if quantity == 0 and self.delete_on_deplete and self.can_delete():
self.mark_for_deletion()
self.delete()
return False
else: