diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index b2a7e1de16..d5d0ae06b7 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -587,17 +587,8 @@ class Build(MPTTModel, ReferenceIndexingMixin): # which point to thie Build Order self.allocated_stock.all().delete() - if user: - user_id = user.pk - else: - user_id = None - # Register an event - trigger_event( - 'build.completed', - build_id=self.pk, - user_id=user_id, - ) + trigger_event('build.completed', id=self.pk) @transaction.atomic def cancelBuild(self, user): @@ -618,16 +609,7 @@ class Build(MPTTModel, ReferenceIndexingMixin): self.status = BuildStatus.CANCELLED self.save() - if user: - user_id = user.pk - else: - user_id = None - - trigger_event( - 'build.cancelled', - build_id=self.pk, - user_id=user_id, - ) + trigger_event('build.cancelled', id=self.pk) @transaction.atomic def unallocateStock(self, bom_item=None, output=None): diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index 815c840dac..ef3c8aad2e 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -11,8 +11,6 @@ from django.utils.translation import ugettext_lazy as _ from django.core.validators import MinValueValidator from django.core.exceptions import ValidationError -from django.db.models.signals import post_save -from django.dispatch.dispatcher import receiver from django.db import models from django.db.models import Sum, Q, UniqueConstraint @@ -35,8 +33,6 @@ import common.models import common.settings from common.settings import currency_code_default -from plugin.events import trigger_event - def rename_company_image(instance, filename): """ Function to rename a company image after upload diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index d437de1685..a86c437e05 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -11,8 +11,7 @@ from decimal import Decimal from django.db import models, transaction from django.db.models import Q, F, Sum from django.db.models.functions import Coalesce -from django.db.models.signals import post_save -from django.dispatch.dispatcher import receiver + from django.core.validators import MinValueValidator from django.core.exceptions import ValidationError from django.contrib.auth.models import User @@ -320,7 +319,7 @@ class PurchaseOrder(Order): self.issue_date = datetime.now().date() self.save() - trigger_event('purchaseorder.placed', order_id=self.pk) + trigger_event('purchaseorder.placed', id=self.pk) @transaction.atomic def complete_order(self): @@ -331,7 +330,7 @@ class PurchaseOrder(Order): self.complete_date = datetime.now().date() self.save() - trigger_event('purchaseorder.completed', order_id=self.pk) + trigger_event('purchaseorder.completed', id=self.pk) @property def is_overdue(self): @@ -363,7 +362,7 @@ class PurchaseOrder(Order): self.status = PurchaseOrderStatus.CANCELLED self.save() - trigger_event('purchaseorder.cancelled', order_id=self.pk) + trigger_event('purchaseorder.cancelled', id=self.pk) def pending_line_items(self): """ Return a list of pending line items for this order. @@ -676,7 +675,7 @@ class SalesOrder(Order): self.save() - trigger_event('salesorder.completed', order_id=self.pk) + trigger_event('salesorder.completed', id=self.pk) return True @@ -709,7 +708,7 @@ class SalesOrder(Order): for allocation in line.allocations.all(): allocation.delete() - trigger_event('salesorder.cancelled', order_id=self.pk) + trigger_event('salesorder.cancelled', id=self.pk) return True @@ -1117,7 +1116,7 @@ class SalesOrderShipment(models.Model): self.save() - trigger_event('salesordershipment.completed', shipment_id=self.pk) + trigger_event('salesordershipment.completed', id=self.pk) class SalesOrderAllocation(models.Model): diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 124140b5bd..604d384a67 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -60,8 +60,6 @@ import common.models import part.settings as part_settings -from plugin.events import trigger_event - logger = logging.getLogger("inventree") diff --git a/InvenTree/plugin/events.py b/InvenTree/plugin/events.py index 3c7211f95b..a86886ff42 100644 --- a/InvenTree/plugin/events.py +++ b/InvenTree/plugin/events.py @@ -91,10 +91,6 @@ def process_event(plugin_slug, event, *args, **kwargs): plugin.process_event(event, *args, **kwargs) -""" -Register some default event triggers on model signals -""" - @receiver(post_save) def after_save(sender, instance, created, **kwargs): """ diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index f4d2471519..140bd9c8e3 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -722,8 +722,8 @@ class StockItem(MPTTModel): trigger_event( 'stockitem.assignedtocustomer', - item_id=self.id, - customer_id=customer.id, + id=self.id, + customer=customer.id, ) # Return the reference to the stock item @@ -755,7 +755,7 @@ class StockItem(MPTTModel): trigger_event( 'stockitem.returnedfromcustomer', - item_id=self.id, + id=self.id, ) self.save()