mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge remote-tracking branch 'inventree/master'
This commit is contained in:
commit
eee93b49c2
@ -74,7 +74,7 @@ def validate_build_order_reference(value):
|
|||||||
match = re.search(pattern, value)
|
match = re.search(pattern, value)
|
||||||
|
|
||||||
if match is None:
|
if match is None:
|
||||||
raise ValidationError(_('Reference must match pattern') + f" '{pattern}'")
|
raise ValidationError(_('Reference must match pattern {pattern}').format(pattern=pattern))
|
||||||
|
|
||||||
|
|
||||||
def validate_purchase_order_reference(value):
|
def validate_purchase_order_reference(value):
|
||||||
@ -88,7 +88,7 @@ def validate_purchase_order_reference(value):
|
|||||||
match = re.search(pattern, value)
|
match = re.search(pattern, value)
|
||||||
|
|
||||||
if match is None:
|
if match is None:
|
||||||
raise ValidationError(_('Reference must match pattern') + f" '{pattern}'")
|
raise ValidationError(_('Reference must match pattern {pattern}').format(pattern=pattern))
|
||||||
|
|
||||||
|
|
||||||
def validate_sales_order_reference(value):
|
def validate_sales_order_reference(value):
|
||||||
@ -102,7 +102,7 @@ def validate_sales_order_reference(value):
|
|||||||
match = re.search(pattern, value)
|
match = re.search(pattern, value)
|
||||||
|
|
||||||
if match is None:
|
if match is None:
|
||||||
raise ValidationError(_('Reference must match pattern') + f" '{pattern}'")
|
raise ValidationError(_('Reference must match pattern {pattern}').format(pattern=pattern))
|
||||||
|
|
||||||
|
|
||||||
def validate_tree_name(value):
|
def validate_tree_name(value):
|
||||||
|
@ -158,6 +158,8 @@ $('#view-calendar').click(function() {
|
|||||||
|
|
||||||
$("#build-order-calendar").show();
|
$("#build-order-calendar").show();
|
||||||
$("#view-list").show();
|
$("#view-list").show();
|
||||||
|
|
||||||
|
calendar.render();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#view-list").click(function() {
|
$("#view-list").click(function() {
|
||||||
|
@ -202,7 +202,7 @@ class CompanyImageDownloadFromURL(AjaxUpdateView):
|
|||||||
|
|
||||||
# Check for valid response code
|
# Check for valid response code
|
||||||
if not response.status_code == 200:
|
if not response.status_code == 200:
|
||||||
form.add_error('url', f"{_('Invalid response')}: {response.status_code}")
|
form.add_error('url', _('Invalid response: {code}').format(code=response.status_code))
|
||||||
return
|
return
|
||||||
|
|
||||||
response.raw.decode_content = True
|
response.raw.decode_content = True
|
||||||
|
@ -367,7 +367,7 @@ class PurchaseOrder(Order):
|
|||||||
stock.save()
|
stock.save()
|
||||||
|
|
||||||
text = _("Received items")
|
text = _("Received items")
|
||||||
note = f"{_('Received')} {quantity} {_('items against order')} {str(self)}"
|
note = _('Received {n} items against order {name}').format(n=quantity, name=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(text, user, note)
|
stock.addTransactionNote(text, user, note)
|
||||||
|
@ -146,6 +146,8 @@ $('#view-calendar').click(function() {
|
|||||||
|
|
||||||
$("#purchase-order-calendar").show();
|
$("#purchase-order-calendar").show();
|
||||||
$("#view-list").show();
|
$("#view-list").show();
|
||||||
|
|
||||||
|
calendar.render();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#view-list").click(function() {
|
$("#view-list").click(function() {
|
||||||
|
@ -141,9 +141,11 @@ $('#view-calendar').click(function() {
|
|||||||
$(".columns-right").hide();
|
$(".columns-right").hide();
|
||||||
$(".search").hide();
|
$(".search").hide();
|
||||||
$('#filter-list-salesorder').hide();
|
$('#filter-list-salesorder').hide();
|
||||||
|
|
||||||
$("#sales-order-calendar").show();
|
$("#sales-order-calendar").show();
|
||||||
$("#view-list").show();
|
$("#view-list").show();
|
||||||
|
|
||||||
|
calendar.render();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#view-list").click(function() {
|
$("#view-list").click(function() {
|
||||||
|
@ -1407,7 +1407,7 @@ class SalesOrderAssignSerials(AjaxView, FormMixin):
|
|||||||
except StockItem.DoesNotExist:
|
except StockItem.DoesNotExist:
|
||||||
self.form.add_error(
|
self.form.add_error(
|
||||||
'serials',
|
'serials',
|
||||||
_('No matching item for serial') + f" '{serial}'"
|
_('No matching item for serial {serial}').format(serial=serial)
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -1417,7 +1417,7 @@ class SalesOrderAssignSerials(AjaxView, FormMixin):
|
|||||||
if not stock_item.in_stock:
|
if not stock_item.in_stock:
|
||||||
self.form.add_error(
|
self.form.add_error(
|
||||||
'serials',
|
'serials',
|
||||||
f"'{serial}' " + _("is not in stock")
|
_('{serial} is not in stock').format(serial=serial)
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -1425,7 +1425,7 @@ class SalesOrderAssignSerials(AjaxView, FormMixin):
|
|||||||
if stock_item.is_allocated():
|
if stock_item.is_allocated():
|
||||||
self.form.add_error(
|
self.form.add_error(
|
||||||
'serials',
|
'serials',
|
||||||
f"'{serial}' " + _("already allocated to an order")
|
_('{serial} already allocated to an order').format(serial=serial)
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -884,7 +884,7 @@ class PartImageDownloadFromURL(AjaxUpdateView):
|
|||||||
|
|
||||||
# Check for valid response code
|
# Check for valid response code
|
||||||
if not response.status_code == 200:
|
if not response.status_code == 200:
|
||||||
form.add_error('url', f"{_('Invalid response')}: {response.status_code}")
|
form.add_error('url', _('Invalid response: {code}').format(code=response.status_code))
|
||||||
return
|
return
|
||||||
|
|
||||||
response.raw.decode_content = True
|
response.raw.decode_content = True
|
||||||
|
@ -56,7 +56,7 @@ class LocationAdmin(ImportExportModelAdmin):
|
|||||||
class StockItemResource(ModelResource):
|
class StockItemResource(ModelResource):
|
||||||
""" Class for managing StockItem data import/export """
|
""" Class for managing StockItem data import/export """
|
||||||
|
|
||||||
# Custom manaegrs for ForeignKey fields
|
# Custom managers for ForeignKey fields
|
||||||
part = Field(attribute='part', widget=widgets.ForeignKeyWidget(Part))
|
part = Field(attribute='part', widget=widgets.ForeignKeyWidget(Part))
|
||||||
|
|
||||||
part_name = Field(attribute='part__full_name', readonly=True)
|
part_name = Field(attribute='part__full_name', readonly=True)
|
||||||
|
@ -198,7 +198,7 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
if add_note:
|
if add_note:
|
||||||
|
|
||||||
note = f"{_('Created new stock item for')} {str(self.part)}"
|
note = _('Created new stock item for {part}').format(part=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(
|
||||||
@ -228,7 +228,7 @@ class StockItem(MPTTModel):
|
|||||||
super(StockItem, self).validate_unique(exclude)
|
super(StockItem, self).validate_unique(exclude)
|
||||||
|
|
||||||
# If the serial number is set, make sure it is not a duplicate
|
# If the serial number is set, make sure it is not a duplicate
|
||||||
if self.serial is not None:
|
if self.serial:
|
||||||
# Query to look for duplicate serial numbers
|
# Query to look for duplicate serial numbers
|
||||||
parts = PartModels.Part.objects.filter(tree_id=self.part.tree_id)
|
parts = PartModels.Part.objects.filter(tree_id=self.part.tree_id)
|
||||||
stock = StockItem.objects.filter(part__in=parts, serial=self.serial)
|
stock = StockItem.objects.filter(part__in=parts, serial=self.serial)
|
||||||
@ -281,7 +281,7 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
if self.part is not None:
|
if self.part is not None:
|
||||||
# A part with a serial number MUST have the quantity set to 1
|
# A part with a serial number MUST have the quantity set to 1
|
||||||
if self.serial is not None:
|
if self.serial:
|
||||||
if self.quantity > 1:
|
if self.quantity > 1:
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
'quantity': _('Quantity must be 1 for item with a serial number'),
|
'quantity': _('Quantity must be 1 for item with a serial number'),
|
||||||
@ -613,7 +613,7 @@ class StockItem(MPTTModel):
|
|||||||
item.addTransactionNote(
|
item.addTransactionNote(
|
||||||
_("Assigned to Customer"),
|
_("Assigned to Customer"),
|
||||||
user,
|
user,
|
||||||
notes=_("Manually assigned to customer") + " " + customer.name,
|
notes=_("Manually assigned to customer {name}").format(name=customer.name),
|
||||||
system=True
|
system=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -626,9 +626,9 @@ class StockItem(MPTTModel):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
self.addTransactionNote(
|
self.addTransactionNote(
|
||||||
_("Returned from customer") + f" {self.customer.name}",
|
_("Returned from customer {name}").format(name=self.customer.name),
|
||||||
user,
|
user,
|
||||||
notes=_("Returned to location") + f" {location.name}",
|
notes=_("Returned to location {loc}").format(loc=location.name),
|
||||||
system=True
|
system=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -789,7 +789,7 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
# Add a transaction note to the other item
|
# Add a transaction note to the other item
|
||||||
stock_item.addTransactionNote(
|
stock_item.addTransactionNote(
|
||||||
_('Installed into stock item') + ' ' + str(self.pk),
|
_('Installed into stock item {pk}').format(str(self.pk)),
|
||||||
user,
|
user,
|
||||||
notes=notes,
|
notes=notes,
|
||||||
url=self.get_absolute_url()
|
url=self.get_absolute_url()
|
||||||
@ -797,7 +797,7 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
# Add a transaction note to this item
|
# Add a transaction note to this item
|
||||||
self.addTransactionNote(
|
self.addTransactionNote(
|
||||||
_('Installed stock item') + ' ' + str(stock_item.pk),
|
_('Installed stock item {pk}').format(str(stock_item.pk)),
|
||||||
user, notes=notes,
|
user, notes=notes,
|
||||||
url=stock_item.get_absolute_url()
|
url=stock_item.get_absolute_url()
|
||||||
)
|
)
|
||||||
@ -821,7 +821,7 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
# Add a transaction note to the parent item
|
# Add a transaction note to the parent item
|
||||||
self.belongs_to.addTransactionNote(
|
self.belongs_to.addTransactionNote(
|
||||||
_("Uninstalled stock item") + ' ' + str(self.pk),
|
_("Uninstalled stock item {pk}").format(pk=str(self.pk)),
|
||||||
user,
|
user,
|
||||||
notes=notes,
|
notes=notes,
|
||||||
url=self.get_absolute_url(),
|
url=self.get_absolute_url(),
|
||||||
@ -840,7 +840,7 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
# Add a transaction note!
|
# Add a transaction note!
|
||||||
self.addTransactionNote(
|
self.addTransactionNote(
|
||||||
_('Uninstalled into location') + ' ' + str(location),
|
_('Uninstalled into location {loc}').formaT(loc=str(location)),
|
||||||
user,
|
user,
|
||||||
notes=notes,
|
notes=notes,
|
||||||
url=url
|
url=url
|
||||||
@ -966,7 +966,7 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
if len(existing) > 0:
|
if len(existing) > 0:
|
||||||
exists = ','.join([str(x) for x in existing])
|
exists = ','.join([str(x) for x in existing])
|
||||||
raise ValidationError({"serial_numbers": _("Serial numbers already exist") + ': ' + exists})
|
raise ValidationError({"serial_numbers": _("Serial numbers already exist: {exists}").format(exists=exists)})
|
||||||
|
|
||||||
# Create a new stock item for each unique serial number
|
# Create a new stock item for each unique serial number
|
||||||
for serial in serials:
|
for serial in serials:
|
||||||
@ -1074,7 +1074,7 @@ class StockItem(MPTTModel):
|
|||||||
new_stock.addTransactionNote(
|
new_stock.addTransactionNote(
|
||||||
_("Split from existing stock"),
|
_("Split from existing stock"),
|
||||||
user,
|
user,
|
||||||
f"{_('Split')} {helpers.normalize(quantity)} {_('items')}"
|
_('Split {n} items').format(n=helpers.normalize(quantity))
|
||||||
)
|
)
|
||||||
|
|
||||||
# Remove the specified quantity from THIS stock item
|
# Remove the specified quantity from THIS stock item
|
||||||
@ -1131,10 +1131,10 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
msg = f"{_('Moved to')} {str(location)}"
|
|
||||||
|
|
||||||
if self.location:
|
if self.location:
|
||||||
msg += f" ({_('from')} {str(self.location)})"
|
msg = _("Moved to {loc_new} (from {loc_old})").format(loc_new=str(location), loc_old=str(self.location))
|
||||||
|
else:
|
||||||
|
msg = _('Moved to {loc_new}').format(loc_new=str(location))
|
||||||
|
|
||||||
self.location = location
|
self.location = location
|
||||||
|
|
||||||
@ -1202,9 +1202,7 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
if self.updateQuantity(count):
|
if self.updateQuantity(count):
|
||||||
|
|
||||||
n = helpers.normalize(count)
|
text = _('Counted {n} items').format(n=helpers.normalize(count))
|
||||||
|
|
||||||
text = f"{_('Counted')} {n} {_('items')}"
|
|
||||||
|
|
||||||
self.addTransactionNote(
|
self.addTransactionNote(
|
||||||
text,
|
text,
|
||||||
@ -1236,9 +1234,8 @@ class StockItem(MPTTModel):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if self.updateQuantity(self.quantity + quantity):
|
if self.updateQuantity(self.quantity + quantity):
|
||||||
|
|
||||||
n = helpers.normalize(quantity)
|
text = _('Added {n} items').format(n=helpers.normalize(quantity))
|
||||||
text = f"{_('Added')} {n} {_('items')}"
|
|
||||||
|
|
||||||
self.addTransactionNote(
|
self.addTransactionNote(
|
||||||
text,
|
text,
|
||||||
@ -1268,8 +1265,7 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
if self.updateQuantity(self.quantity - quantity):
|
if self.updateQuantity(self.quantity - quantity):
|
||||||
|
|
||||||
q = helpers.normalize(quantity)
|
text = _('Removed {n1} items').format(n1=helpers.normalize(quantity))
|
||||||
text = f"{_('Removed')} {q} {_('items')}"
|
|
||||||
|
|
||||||
self.addTransactionNote(text,
|
self.addTransactionNote(text,
|
||||||
user,
|
user,
|
||||||
|
Loading…
Reference in New Issue
Block a user