Override 'add_note' when new StockItem is created

- This allows us to prevent the issue of duplicate notes being created
This commit is contained in:
Oliver Walters 2021-05-11 22:51:29 +10:00
parent 0c19a94f5c
commit 84bfffd5a7
2 changed files with 5 additions and 2 deletions

View File

@ -366,7 +366,7 @@ class PurchaseOrder(Order):
purchase_price=purchase_price,
)
stock.save()
stock.save(add_note=False)
tracking_info = {
'status': status,

View File

@ -183,9 +183,12 @@ class StockItem(MPTTModel):
self.validate_unique()
self.clean()
# If 'add_note = False' specified, then no tracking note will be added for item creation
add_note = kwargs.pop('add_note', True)
if not self.pk:
# StockItem has not yet been saved
add_note = True
add_note = add_note and True
else:
# StockItem has already been saved
add_note = False