Translations for stock transaction notes

This commit is contained in:
Oliver Walters 2021-01-29 12:23:22 +11:00
parent 282ed0c637
commit 4ef6a6dc62
2 changed files with 39 additions and 21 deletions

View File

@ -343,11 +343,11 @@ class PurchaseOrder(Order):
stock.save() stock.save()
text = _("Received items")
note = f"{_('Received')} {quantity} {_('items against order')} {str(self)}"
# Add a new transaction note to the newly created stock item # Add a new transaction note to the newly created stock item
stock.addTransactionNote("Received items", user, "Received {q} items against order '{po}'".format( stock.addTransactionNote(text, user, note)
q=quantity,
po=str(self))
)
# Update the number of parts received against the particular line item # Update the number of parts received against the particular line item
line.received += quantity line.received += quantity

View File

@ -195,11 +195,14 @@ class StockItem(MPTTModel):
super(StockItem, self).save(*args, **kwargs) super(StockItem, self).save(*args, **kwargs)
if add_note: if add_note:
note = f"{_('Created new stock item for')} {str(self.part)}"
# This StockItem is being saved for the first time # This StockItem is being saved for the first time
self.addTransactionNote( self.addTransactionNote(
_('Created stock item'), _('Created stock item'),
user, user,
notes="Created new stock item for part '{p}'".format(p=str(self.part)), note,
system=True system=True
) )
@ -611,9 +614,9 @@ class StockItem(MPTTModel):
""" """
self.addTransactionNote( self.addTransactionNote(
_("Returned from customer") + " " + self.customer.name, _("Returned from customer") + f" {self.customer.name}",
user, user,
notes=_("Returned to location") + " " + location.name, notes=_("Returned to location") + f" {location.name}",
system=True system=True
) )
@ -1000,9 +1003,10 @@ class StockItem(MPTTModel):
# Add a new tracking item for the new stock item # Add a new tracking item for the new stock item
new_stock.addTransactionNote( new_stock.addTransactionNote(
"Split from existing stock", _("Split from existing stock"),
user, user,
"Split {n} from existing stock item".format(n=quantity)) _("Split") + f" {helpers.normalize(quantity)} " + _("items")
)
# Remove the specified quantity from THIS stock item # Remove the specified quantity from THIS stock item
self.take_stock(quantity, user, 'Split {n} items into new stock item'.format(n=quantity)) self.take_stock(quantity, user, 'Split {n} items into new stock item'.format(n=quantity))
@ -1054,10 +1058,10 @@ class StockItem(MPTTModel):
return True return True
msg = "Moved to {loc}".format(loc=str(location)) msg = f"{_('Moved to')} {str(location)}"
if self.location: if self.location:
msg += " (from {loc})".format(loc=str(self.location)) msg += f" ({_('from')} {str(self.location)})"
self.location = location self.location = location
@ -1125,10 +1129,16 @@ class StockItem(MPTTModel):
if self.updateQuantity(count): if self.updateQuantity(count):
self.addTransactionNote('Stocktake - counted {n} items'.format(n=helpers.normalize(count)), n = helpers.normalize(count)
user,
notes=notes, text = f"{_('Counted')} {n} {_('items')}"
system=True)
self.addTransactionNote(
text,
user,
notes=notes,
system=True
)
return True return True
@ -1154,10 +1164,15 @@ class StockItem(MPTTModel):
if self.updateQuantity(self.quantity + quantity): if self.updateQuantity(self.quantity + quantity):
self.addTransactionNote('Added {n} items to stock'.format(n=helpers.normalize(quantity)), n = helpers.normalize(quantity)
user, text = f"{_('Added')} {n} {_('items')}"
notes=notes,
system=True) self.addTransactionNote(
text,
user,
notes=notes,
system=True
)
return True return True
@ -1180,7 +1195,10 @@ class StockItem(MPTTModel):
if self.updateQuantity(self.quantity - quantity): if self.updateQuantity(self.quantity - quantity):
self.addTransactionNote('Removed {n} items from stock'.format(n=helpers.normalize(quantity)), q = helpers.normalize(quantity)
text = f"{_('Removed')} {q} {_('items')}"
self.addTransactionNote(text,
user, user,
notes=notes, notes=notes,
system=True) system=True)