mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Only run check stock function when updating an existing part
This commit is contained in:
parent
99b324d1ef
commit
01191d84c5
@ -8,8 +8,6 @@ import decimal
|
||||
|
||||
import os
|
||||
from datetime import datetime
|
||||
from django import dispatch
|
||||
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError
|
||||
|
@ -9,8 +9,6 @@ from django.template.loader import render_to_string
|
||||
|
||||
from allauth.account.models import EmailAddress
|
||||
|
||||
from common.models import NotificationEntry
|
||||
|
||||
import build.models
|
||||
import InvenTree.helpers
|
||||
import InvenTree.tasks
|
||||
|
@ -2102,13 +2102,16 @@ class Part(MPTTModel):
|
||||
|
||||
|
||||
@receiver(post_save, sender=Part, dispatch_uid='part_post_save_log')
|
||||
def after_save_part(sender, instance: Part, **kwargs):
|
||||
def after_save_part(sender, instance: Part, created, **kwargs):
|
||||
"""
|
||||
Function to be executed after a Part is saved
|
||||
"""
|
||||
|
||||
# Run this check in the background
|
||||
InvenTree.tasks.offload_task('part.tasks.notify_low_stock_if_required', instance)
|
||||
if not created:
|
||||
# Check part stock only if we are *updating* the part (not creating it)
|
||||
|
||||
# Run this check in the background
|
||||
InvenTree.tasks.offload_task('part.tasks.notify_low_stock_if_required', instance)
|
||||
|
||||
|
||||
def attach_file(instance, filename):
|
||||
|
Loading…
Reference in New Issue
Block a user