From b9291c6705a464ae7b0a1a3327bf7b4db4841dd5 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 4 Oct 2020 23:33:43 +1100 Subject: [PATCH] Improve transaction note recording for the StockItem model --- InvenTree/stock/models.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 964ab43e8a..b78b0e9410 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -625,11 +625,19 @@ class StockItem(MPTTModel): stock_item.belongs_to = self stock_item.save() - # Add a transaction note! + # Add a transaction note to the other item stock_item.addTransactionNote( _('Installed into stock item') + ' ' + str(self.pk), user, - notes=notes + notes=notes, + url=self.get_absolute_url() + ) + + # Add a transaction note to this item + self.addTransactionNote( + _('Installed stock item') + ' ' + str(stock_item.pk), + user, notes=notes, + url=stock_item.get_absolute_url() ) @transaction.atomic @@ -649,16 +657,31 @@ class StockItem(MPTTModel): # TODO - Are there any other checks that need to be performed at this stage? + # Add a transaction note to the parent item + self.belongs_to.addTransactionNote( + _("Uninstalled stock item") + ' ' + str(self.pk), + user, + notes=notes, + url=self.get_absolute_url(), + ) + + # Mark this stock item as *not* belonging to anyone self.belongs_to = None self.location = location self.save() + if location: + url = location.get_absolute_url() + else: + url = '' + # Add a transaction note! self.addTransactionNote( _('Uninstalled into location') + ' ' + str(location), user, - notes=notes + notes=notes, + url=url ) @property