Merge remote-tracking branch 'inventree/master'

This commit is contained in:
Oliver Walters 2021-02-01 14:41:07 +11:00
commit fa76159f2f
14 changed files with 400 additions and 151 deletions

View File

@ -267,7 +267,7 @@ def WrapWithQuotes(text, quote='"'):
return text
def MakeBarcode(object_name, object_pk, object_data, **kwargs):
def MakeBarcode(object_name, object_pk, object_data={}, **kwargs):
""" Generate a string for a barcode. Adds some global InvenTree parameters.
Args:
@ -280,7 +280,7 @@ def MakeBarcode(object_name, object_pk, object_data, **kwargs):
json string of the supplied data plus some other data
"""
brief = kwargs.get('brief', False)
brief = kwargs.get('brief', True)
data = {}

View File

@ -1,4 +1,6 @@
import json
from django.test import TestCase
import django.core.exceptions as django_exceptions
from django.core.exceptions import ValidationError
@ -134,7 +136,7 @@ class TestIncrement(TestCase):
class TestMakeBarcode(TestCase):
""" Tests for barcode string creation """
def test_barcode(self):
def test_barcode_extended(self):
bc = helpers.MakeBarcode(
"part",
@ -142,13 +144,30 @@ class TestMakeBarcode(TestCase):
{
"id": 3,
"url": "www.google.com",
}
},
brief=False
)
self.assertIn('part', bc)
self.assertIn('tool', bc)
self.assertIn('"tool": "InvenTree"', bc)
data = json.loads(bc)
self.assertEqual(data['part']['id'], 3)
self.assertEqual(data['part']['url'], 'www.google.com')
def test_barcode_brief(self):
bc = helpers.MakeBarcode(
"stockitem",
7,
)
data = json.loads(bc)
self.assertEqual(len(data), 1)
self.assertEqual(data['stockitem'], 7)
class TestDownloadFile(TestCase):

View File

@ -105,6 +105,7 @@ dynamic_javascript_urls = [
url(r'^label.js', DynamicJsView.as_view(template_name='js/label.js'), name='label.js'),
url(r'^report.js', DynamicJsView.as_view(template_name='js/report.js'), name='report.js'),
url(r'^stock.js', DynamicJsView.as_view(template_name='js/stock.js'), name='stock.js'),
url(r'^tables.js', DynamicJsView.as_view(template_name='js/tables.js'), name='tables.js'),
url(r'^table_filters.js', DynamicJsView.as_view(template_name='js/table_filters.js'), name='table_filters.js'),
]

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import string
import hashlib
import logging
@ -16,9 +17,20 @@ logger = logging.getLogger(__name__)
def hash_barcode(barcode_data):
"""
Calculate an MD5 hash of barcode data
Calculate an MD5 hash of barcode data.
HACK: Remove any 'non printable' characters from the hash,
as it seems browers will remove special control characters...
TODO: Work out a way around this!
"""
barcode_data = str(barcode_data).strip()
printable_chars = filter(lambda x: x in string.printable, barcode_data)
barcode_data = ''.join(list(printable_chars))
hash = hashlib.md5(str(barcode_data).encode())
return str(hash.hexdigest())

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-28 22:37+1100\n"
"POT-Creation-Date: 2021-01-29 12:04+1100\n"
"PO-Revision-Date: 2020-05-03 11:32+0200\n"
"Last-Translator: Christian Schlüter <chschlue@gmail.com>\n"
"Language-Team: C <kde-i18n-doc@kde.org>\n"
@ -355,7 +355,7 @@ msgstr ""
#: stock/templates/stock/item_base.html:51
#: stock/templates/stock/item_base.html:57
#: stock/templates/stock/item_base.html:238
#: stock/templates/stock/stock_adjust.html:18 templates/js/barcode.js:367
#: stock/templates/stock/stock_adjust.html:18 templates/js/barcode.js:364
#: templates/js/bom.js:195 templates/js/build.js:420 templates/js/stock.js:910
#: templates/js/stock.js:1149
msgid "Quantity"
@ -495,7 +495,7 @@ msgstr "Bestellung, die diesem Bau zugwiesen ist"
#: order/templates/order/receive_parts.html:19 part/models.py:320
#: part/templates/part/part_app_base.html:7 part/templates/part/related.html:26
#: part/templates/part/set_category.html:13 templates/InvenTree/search.html:133
#: templates/js/barcode.js:365 templates/js/bom.js:153 templates/js/bom.js:532
#: templates/js/barcode.js:362 templates/js/bom.js:153 templates/js/bom.js:532
#: templates/js/build.js:669 templates/js/company.js:138
#: templates/js/part.js:252 templates/js/part.js:357 templates/js/stock.js:486
#: templates/js/stock.js:1221
@ -596,7 +596,7 @@ msgstr "Link zu einer externen URL"
#: order/templates/order/so_tabs.html:23 part/models.py:838
#: part/templates/part/tabs.html:73 stock/forms.py:315 stock/forms.py:347
#: stock/forms.py:375 stock/models.py:484 stock/models.py:1554
#: stock/templates/stock/tabs.html:26 templates/js/barcode.js:34
#: stock/templates/stock/tabs.html:26 templates/js/barcode.js:37
#: templates/js/bom.js:293 templates/js/stock.js:128 templates/js/stock.js:624
msgid "Notes"
msgstr "Notizen"
@ -762,8 +762,8 @@ msgstr "Lagerobjekt dem Bau zuweisen"
#: build/templates/build/auto_allocate.html:18 stock/forms.py:345
#: stock/templates/stock/item_base.html:268
#: stock/templates/stock/stock_adjust.html:17
#: templates/InvenTree/search.html:183 templates/js/barcode.js:366
#: templates/js/barcode.js:534 templates/js/build.js:434
#: templates/InvenTree/search.html:183 templates/js/barcode.js:363
#: templates/js/barcode.js:531 templates/js/build.js:434
#: templates/js/stock.js:598
msgid "Location"
msgstr "Standort"
@ -841,7 +841,7 @@ msgstr "Bau-Status"
#: build/templates/build/detail.html:57
#: order/templates/order/receive_parts.html:24
#: stock/templates/stock/item_base.html:367 templates/InvenTree/search.html:175
#: templates/js/barcode.js:116 templates/js/build.js:697
#: templates/js/barcode.js:119 templates/js/build.js:697
#: templates/js/order.js:185 templates/js/order.js:279
#: templates/js/stock.js:585 templates/js/stock.js:1157
msgid "Status"
@ -4839,8 +4839,8 @@ msgstr ""
msgid "Stale"
msgstr ""
#: stock/templates/stock/item_base.html:132 templates/js/barcode.js:312
#: templates/js/barcode.js:317
#: stock/templates/stock/item_base.html:132 templates/js/barcode.js:309
#: templates/js/barcode.js:314
msgid "Unlink Barcode"
msgstr ""
@ -5788,120 +5788,120 @@ msgstr "Anhang löschen"
msgid "Scan barcode data here using wedge scanner"
msgstr "Keine Strichcodedaten bereitgestellt"
#: templates/js/barcode.js:12
#, fuzzy
#| msgid "Source Location"
msgid "Barcode"
msgstr "Quell-Standort"
#: templates/js/barcode.js:20
#: templates/js/barcode.js:10
#, fuzzy
#| msgid "No barcode data provided"
msgid "Enter barcode data"
msgstr "Keine Strichcodedaten bereitgestellt"
#: templates/js/barcode.js:30
#: templates/js/barcode.js:14
#, fuzzy
#| msgid "Source Location"
msgid "Barcode"
msgstr "Quell-Standort"
#: templates/js/barcode.js:32
msgid "Enter optional notes for stock transfer"
msgstr ""
#: templates/js/barcode.js:40
#: templates/js/barcode.js:33
#, fuzzy
#| msgid "Entry notes"
msgid "Enter notes"
msgstr "Eintrags-Notizen"
#: templates/js/barcode.js:68
#: templates/js/barcode.js:71
msgid "Server error"
msgstr ""
#: templates/js/barcode.js:89
#: templates/js/barcode.js:92
#, fuzzy
#| msgid "Unknown barcode format"
msgid "Unknown response from server"
msgstr "Unbekanntes Strichcode-Format"
#: templates/js/barcode.js:116 templates/js/modals.js:856
#: templates/js/barcode.js:119 templates/js/modals.js:856
msgid "Invalid server response"
msgstr ""
#: templates/js/barcode.js:215
#: templates/js/barcode.js:212
#, fuzzy
#| msgid "No barcode data provided"
msgid "Scan barcode data below"
msgstr "Keine Strichcodedaten bereitgestellt"
#: templates/js/barcode.js:273
#: templates/js/barcode.js:270
msgid "No URL in response"
msgstr ""
#: templates/js/barcode.js:291
#: templates/js/barcode.js:288
#, fuzzy
#| msgid "Parent Stock Item"
msgid "Link Barcode to Stock Item"
msgstr "Eltern-Lagerobjekt"
#: templates/js/barcode.js:314
#: templates/js/barcode.js:311
msgid ""
"This will remove the association between this stock item and the barcode"
msgstr ""
#: templates/js/barcode.js:320
#: templates/js/barcode.js:317
msgid "Unlink"
msgstr ""
#: templates/js/barcode.js:379
#: templates/js/barcode.js:376
#, fuzzy
#| msgid "Remove stock"
msgid "Remove stock item"
msgstr "Bestand entfernen"
#: templates/js/barcode.js:421
#: templates/js/barcode.js:418
#, fuzzy
#| msgid "Include stock items in sub locations"
msgid "Check Stock Items into Location"
msgstr "Lagerobjekte in untergeordneten Lagerorten einschließen"
#: templates/js/barcode.js:425 templates/js/barcode.js:550
#: templates/js/barcode.js:422 templates/js/barcode.js:547
msgid "Check In"
msgstr ""
#: templates/js/barcode.js:465 templates/js/barcode.js:589
#: templates/js/barcode.js:462 templates/js/barcode.js:586
#, fuzzy
#| msgid "Order stock"
msgid "Error transferring stock"
msgstr "Bestand bestellen"
#: templates/js/barcode.js:484
#: templates/js/barcode.js:481
#, fuzzy
#| msgid "Stock Item Details"
msgid "Stock Item already scanned"
msgstr "Lagerbestands-Details"
#: templates/js/barcode.js:488
#: templates/js/barcode.js:485
#, fuzzy
#| msgid "Include stock items in sub locations"
msgid "Stock Item already in this location"
msgstr "Lagerobjekte in untergeordneten Lagerorten einschließen"
#: templates/js/barcode.js:495
#: templates/js/barcode.js:492
#, fuzzy
#| msgid "Added stock to {n} items"
msgid "Added stock item"
msgstr "Vorrat zu {n} Lagerobjekten hinzugefügt"
#: templates/js/barcode.js:502
#: templates/js/barcode.js:499
#, fuzzy
#| msgid "Create new Stock Item"
msgid "Barcode does not match Stock Item"
msgstr "Neues Lagerobjekt hinzufügen"
#: templates/js/barcode.js:545
#: templates/js/barcode.js:542
#, fuzzy
#| msgid "Include stock items in sub locations"
msgid "Check Into Location"
msgstr "Lagerobjekte in untergeordneten Lagerorten einschließen"
#: templates/js/barcode.js:608
#: templates/js/barcode.js:605
#, fuzzy
#| msgid "Create new Stock Item"
msgid "Barcode does not match a valid location"
@ -6699,6 +6699,63 @@ msgstr "Favorit"
msgid "Purchasable"
msgstr "Käuflich"
#: templates/js/tables.js:276
msgid "Loading data"
msgstr ""
#: templates/js/tables.js:279
msgid "rows per page"
msgstr ""
#: templates/js/tables.js:282
msgid "Showing"
msgstr ""
#: templates/js/tables.js:282
msgid "to"
msgstr ""
#: templates/js/tables.js:282
msgid "of"
msgstr ""
#: templates/js/tables.js:282
msgid "rows"
msgstr ""
#: templates/js/tables.js:285 templates/search_form.html:6
#: templates/search_form.html:8
msgid "Search"
msgstr "Suche"
#: templates/js/tables.js:288
#, fuzzy
#| msgid "No matching action found"
msgid "No matching results"
msgstr "Keine passende Aktion gefunden"
#: templates/js/tables.js:291
#, fuzzy
#| msgid "Show pricing information"
msgid "Hide/Show pagination"
msgstr "Kosteninformationen ansehen"
#: templates/js/tables.js:294
msgid "Refresh"
msgstr ""
#: templates/js/tables.js:297
msgid "Toggle"
msgstr ""
#: templates/js/tables.js:300
msgid "Columns"
msgstr ""
#: templates/js/tables.js:303
msgid "All"
msgstr ""
#: templates/modals.html:13 templates/modals.html:35
msgid "Form errors exist"
msgstr ""
@ -6735,10 +6792,6 @@ msgstr "Einloggen"
msgid "About InvenTree"
msgstr "Über InvenBaum"
#: templates/search_form.html:6 templates/search_form.html:8
msgid "Search"
msgstr "Suche"
#: templates/stats.html:9
msgid "Server"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-28 22:37+1100\n"
"POT-Creation-Date: 2021-01-29 12:04+1100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -319,7 +319,7 @@ msgstr ""
#: stock/templates/stock/item_base.html:51
#: stock/templates/stock/item_base.html:57
#: stock/templates/stock/item_base.html:238
#: stock/templates/stock/stock_adjust.html:18 templates/js/barcode.js:367
#: stock/templates/stock/stock_adjust.html:18 templates/js/barcode.js:364
#: templates/js/bom.js:195 templates/js/build.js:420 templates/js/stock.js:910
#: templates/js/stock.js:1149
msgid "Quantity"
@ -435,7 +435,7 @@ msgstr ""
#: order/templates/order/receive_parts.html:19 part/models.py:320
#: part/templates/part/part_app_base.html:7 part/templates/part/related.html:26
#: part/templates/part/set_category.html:13 templates/InvenTree/search.html:133
#: templates/js/barcode.js:365 templates/js/bom.js:153 templates/js/bom.js:532
#: templates/js/barcode.js:362 templates/js/bom.js:153 templates/js/bom.js:532
#: templates/js/build.js:669 templates/js/company.js:138
#: templates/js/part.js:252 templates/js/part.js:357 templates/js/stock.js:486
#: templates/js/stock.js:1221
@ -526,7 +526,7 @@ msgstr ""
#: order/templates/order/so_tabs.html:23 part/models.py:838
#: part/templates/part/tabs.html:73 stock/forms.py:315 stock/forms.py:347
#: stock/forms.py:375 stock/models.py:484 stock/models.py:1554
#: stock/templates/stock/tabs.html:26 templates/js/barcode.js:34
#: stock/templates/stock/tabs.html:26 templates/js/barcode.js:37
#: templates/js/bom.js:293 templates/js/stock.js:128 templates/js/stock.js:624
msgid "Notes"
msgstr ""
@ -661,8 +661,8 @@ msgstr ""
#: build/templates/build/auto_allocate.html:18 stock/forms.py:345
#: stock/templates/stock/item_base.html:268
#: stock/templates/stock/stock_adjust.html:17
#: templates/InvenTree/search.html:183 templates/js/barcode.js:366
#: templates/js/barcode.js:534 templates/js/build.js:434
#: templates/InvenTree/search.html:183 templates/js/barcode.js:363
#: templates/js/barcode.js:531 templates/js/build.js:434
#: templates/js/stock.js:598
msgid "Location"
msgstr ""
@ -728,7 +728,7 @@ msgstr ""
#: build/templates/build/detail.html:57
#: order/templates/order/receive_parts.html:24
#: stock/templates/stock/item_base.html:367 templates/InvenTree/search.html:175
#: templates/js/barcode.js:116 templates/js/build.js:697
#: templates/js/barcode.js:119 templates/js/build.js:697
#: templates/js/order.js:185 templates/js/order.js:279
#: templates/js/stock.js:585 templates/js/stock.js:1157
msgid "Status"
@ -4183,8 +4183,8 @@ msgstr ""
msgid "Stale"
msgstr ""
#: stock/templates/stock/item_base.html:132 templates/js/barcode.js:312
#: templates/js/barcode.js:317
#: stock/templates/stock/item_base.html:132 templates/js/barcode.js:309
#: templates/js/barcode.js:314
msgid "Unlink Barcode"
msgstr ""
@ -4952,92 +4952,92 @@ msgstr ""
msgid "Scan barcode data here using wedge scanner"
msgstr ""
#: templates/js/barcode.js:12
msgid "Barcode"
msgstr ""
#: templates/js/barcode.js:20
#: templates/js/barcode.js:10
msgid "Enter barcode data"
msgstr ""
#: templates/js/barcode.js:30
#: templates/js/barcode.js:14
msgid "Barcode"
msgstr ""
#: templates/js/barcode.js:32
msgid "Enter optional notes for stock transfer"
msgstr ""
#: templates/js/barcode.js:40
#: templates/js/barcode.js:33
msgid "Enter notes"
msgstr ""
#: templates/js/barcode.js:68
#: templates/js/barcode.js:71
msgid "Server error"
msgstr ""
#: templates/js/barcode.js:89
#: templates/js/barcode.js:92
msgid "Unknown response from server"
msgstr ""
#: templates/js/barcode.js:116 templates/js/modals.js:856
#: templates/js/barcode.js:119 templates/js/modals.js:856
msgid "Invalid server response"
msgstr ""
#: templates/js/barcode.js:215
#: templates/js/barcode.js:212
msgid "Scan barcode data below"
msgstr ""
#: templates/js/barcode.js:273
#: templates/js/barcode.js:270
msgid "No URL in response"
msgstr ""
#: templates/js/barcode.js:291
#: templates/js/barcode.js:288
msgid "Link Barcode to Stock Item"
msgstr ""
#: templates/js/barcode.js:314
#: templates/js/barcode.js:311
msgid ""
"This will remove the association between this stock item and the barcode"
msgstr ""
#: templates/js/barcode.js:320
#: templates/js/barcode.js:317
msgid "Unlink"
msgstr ""
#: templates/js/barcode.js:379
#: templates/js/barcode.js:376
msgid "Remove stock item"
msgstr ""
#: templates/js/barcode.js:421
#: templates/js/barcode.js:418
msgid "Check Stock Items into Location"
msgstr ""
#: templates/js/barcode.js:425 templates/js/barcode.js:550
#: templates/js/barcode.js:422 templates/js/barcode.js:547
msgid "Check In"
msgstr ""
#: templates/js/barcode.js:465 templates/js/barcode.js:589
#: templates/js/barcode.js:462 templates/js/barcode.js:586
msgid "Error transferring stock"
msgstr ""
#: templates/js/barcode.js:484
#: templates/js/barcode.js:481
msgid "Stock Item already scanned"
msgstr ""
#: templates/js/barcode.js:488
#: templates/js/barcode.js:485
msgid "Stock Item already in this location"
msgstr ""
#: templates/js/barcode.js:495
#: templates/js/barcode.js:492
msgid "Added stock item"
msgstr ""
#: templates/js/barcode.js:502
#: templates/js/barcode.js:499
msgid "Barcode does not match Stock Item"
msgstr ""
#: templates/js/barcode.js:545
#: templates/js/barcode.js:542
msgid "Check Into Location"
msgstr ""
#: templates/js/barcode.js:608
#: templates/js/barcode.js:605
msgid "Barcode does not match a valid location"
msgstr ""
@ -5673,6 +5673,59 @@ msgstr ""
msgid "Purchasable"
msgstr ""
#: templates/js/tables.js:276
msgid "Loading data"
msgstr ""
#: templates/js/tables.js:279
msgid "rows per page"
msgstr ""
#: templates/js/tables.js:282
msgid "Showing"
msgstr ""
#: templates/js/tables.js:282
msgid "to"
msgstr ""
#: templates/js/tables.js:282
msgid "of"
msgstr ""
#: templates/js/tables.js:282
msgid "rows"
msgstr ""
#: templates/js/tables.js:285 templates/search_form.html:6
#: templates/search_form.html:8
msgid "Search"
msgstr ""
#: templates/js/tables.js:288
msgid "No matching results"
msgstr ""
#: templates/js/tables.js:291
msgid "Hide/Show pagination"
msgstr ""
#: templates/js/tables.js:294
msgid "Refresh"
msgstr ""
#: templates/js/tables.js:297
msgid "Toggle"
msgstr ""
#: templates/js/tables.js:300
msgid "Columns"
msgstr ""
#: templates/js/tables.js:303
msgid "All"
msgstr ""
#: templates/modals.html:13 templates/modals.html:35
msgid "Form errors exist"
msgstr ""
@ -5709,10 +5762,6 @@ msgstr ""
msgid "About InvenTree"
msgstr ""
#: templates/search_form.html:6 templates/search_form.html:8
msgid "Search"
msgstr ""
#: templates/stats.html:9
msgid "Server"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-28 22:37+1100\n"
"POT-Creation-Date: 2021-01-29 12:04+1100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -319,7 +319,7 @@ msgstr ""
#: stock/templates/stock/item_base.html:51
#: stock/templates/stock/item_base.html:57
#: stock/templates/stock/item_base.html:238
#: stock/templates/stock/stock_adjust.html:18 templates/js/barcode.js:367
#: stock/templates/stock/stock_adjust.html:18 templates/js/barcode.js:364
#: templates/js/bom.js:195 templates/js/build.js:420 templates/js/stock.js:910
#: templates/js/stock.js:1149
msgid "Quantity"
@ -435,7 +435,7 @@ msgstr ""
#: order/templates/order/receive_parts.html:19 part/models.py:320
#: part/templates/part/part_app_base.html:7 part/templates/part/related.html:26
#: part/templates/part/set_category.html:13 templates/InvenTree/search.html:133
#: templates/js/barcode.js:365 templates/js/bom.js:153 templates/js/bom.js:532
#: templates/js/barcode.js:362 templates/js/bom.js:153 templates/js/bom.js:532
#: templates/js/build.js:669 templates/js/company.js:138
#: templates/js/part.js:252 templates/js/part.js:357 templates/js/stock.js:486
#: templates/js/stock.js:1221
@ -526,7 +526,7 @@ msgstr ""
#: order/templates/order/so_tabs.html:23 part/models.py:838
#: part/templates/part/tabs.html:73 stock/forms.py:315 stock/forms.py:347
#: stock/forms.py:375 stock/models.py:484 stock/models.py:1554
#: stock/templates/stock/tabs.html:26 templates/js/barcode.js:34
#: stock/templates/stock/tabs.html:26 templates/js/barcode.js:37
#: templates/js/bom.js:293 templates/js/stock.js:128 templates/js/stock.js:624
msgid "Notes"
msgstr ""
@ -661,8 +661,8 @@ msgstr ""
#: build/templates/build/auto_allocate.html:18 stock/forms.py:345
#: stock/templates/stock/item_base.html:268
#: stock/templates/stock/stock_adjust.html:17
#: templates/InvenTree/search.html:183 templates/js/barcode.js:366
#: templates/js/barcode.js:534 templates/js/build.js:434
#: templates/InvenTree/search.html:183 templates/js/barcode.js:363
#: templates/js/barcode.js:531 templates/js/build.js:434
#: templates/js/stock.js:598
msgid "Location"
msgstr ""
@ -728,7 +728,7 @@ msgstr ""
#: build/templates/build/detail.html:57
#: order/templates/order/receive_parts.html:24
#: stock/templates/stock/item_base.html:367 templates/InvenTree/search.html:175
#: templates/js/barcode.js:116 templates/js/build.js:697
#: templates/js/barcode.js:119 templates/js/build.js:697
#: templates/js/order.js:185 templates/js/order.js:279
#: templates/js/stock.js:585 templates/js/stock.js:1157
msgid "Status"
@ -4183,8 +4183,8 @@ msgstr ""
msgid "Stale"
msgstr ""
#: stock/templates/stock/item_base.html:132 templates/js/barcode.js:312
#: templates/js/barcode.js:317
#: stock/templates/stock/item_base.html:132 templates/js/barcode.js:309
#: templates/js/barcode.js:314
msgid "Unlink Barcode"
msgstr ""
@ -4952,92 +4952,92 @@ msgstr ""
msgid "Scan barcode data here using wedge scanner"
msgstr ""
#: templates/js/barcode.js:12
msgid "Barcode"
msgstr ""
#: templates/js/barcode.js:20
#: templates/js/barcode.js:10
msgid "Enter barcode data"
msgstr ""
#: templates/js/barcode.js:30
#: templates/js/barcode.js:14
msgid "Barcode"
msgstr ""
#: templates/js/barcode.js:32
msgid "Enter optional notes for stock transfer"
msgstr ""
#: templates/js/barcode.js:40
#: templates/js/barcode.js:33
msgid "Enter notes"
msgstr ""
#: templates/js/barcode.js:68
#: templates/js/barcode.js:71
msgid "Server error"
msgstr ""
#: templates/js/barcode.js:89
#: templates/js/barcode.js:92
msgid "Unknown response from server"
msgstr ""
#: templates/js/barcode.js:116 templates/js/modals.js:856
#: templates/js/barcode.js:119 templates/js/modals.js:856
msgid "Invalid server response"
msgstr ""
#: templates/js/barcode.js:215
#: templates/js/barcode.js:212
msgid "Scan barcode data below"
msgstr ""
#: templates/js/barcode.js:273
#: templates/js/barcode.js:270
msgid "No URL in response"
msgstr ""
#: templates/js/barcode.js:291
#: templates/js/barcode.js:288
msgid "Link Barcode to Stock Item"
msgstr ""
#: templates/js/barcode.js:314
#: templates/js/barcode.js:311
msgid ""
"This will remove the association between this stock item and the barcode"
msgstr ""
#: templates/js/barcode.js:320
#: templates/js/barcode.js:317
msgid "Unlink"
msgstr ""
#: templates/js/barcode.js:379
#: templates/js/barcode.js:376
msgid "Remove stock item"
msgstr ""
#: templates/js/barcode.js:421
#: templates/js/barcode.js:418
msgid "Check Stock Items into Location"
msgstr ""
#: templates/js/barcode.js:425 templates/js/barcode.js:550
#: templates/js/barcode.js:422 templates/js/barcode.js:547
msgid "Check In"
msgstr ""
#: templates/js/barcode.js:465 templates/js/barcode.js:589
#: templates/js/barcode.js:462 templates/js/barcode.js:586
msgid "Error transferring stock"
msgstr ""
#: templates/js/barcode.js:484
#: templates/js/barcode.js:481
msgid "Stock Item already scanned"
msgstr ""
#: templates/js/barcode.js:488
#: templates/js/barcode.js:485
msgid "Stock Item already in this location"
msgstr ""
#: templates/js/barcode.js:495
#: templates/js/barcode.js:492
msgid "Added stock item"
msgstr ""
#: templates/js/barcode.js:502
#: templates/js/barcode.js:499
msgid "Barcode does not match Stock Item"
msgstr ""
#: templates/js/barcode.js:545
#: templates/js/barcode.js:542
msgid "Check Into Location"
msgstr ""
#: templates/js/barcode.js:608
#: templates/js/barcode.js:605
msgid "Barcode does not match a valid location"
msgstr ""
@ -5673,6 +5673,59 @@ msgstr ""
msgid "Purchasable"
msgstr ""
#: templates/js/tables.js:276
msgid "Loading data"
msgstr ""
#: templates/js/tables.js:279
msgid "rows per page"
msgstr ""
#: templates/js/tables.js:282
msgid "Showing"
msgstr ""
#: templates/js/tables.js:282
msgid "to"
msgstr ""
#: templates/js/tables.js:282
msgid "of"
msgstr ""
#: templates/js/tables.js:282
msgid "rows"
msgstr ""
#: templates/js/tables.js:285 templates/search_form.html:6
#: templates/search_form.html:8
msgid "Search"
msgstr ""
#: templates/js/tables.js:288
msgid "No matching results"
msgstr ""
#: templates/js/tables.js:291
msgid "Hide/Show pagination"
msgstr ""
#: templates/js/tables.js:294
msgid "Refresh"
msgstr ""
#: templates/js/tables.js:297
msgid "Toggle"
msgstr ""
#: templates/js/tables.js:300
msgid "Columns"
msgstr ""
#: templates/js/tables.js:303
msgid "All"
msgstr ""
#: templates/modals.html:13 templates/modals.html:35
msgid "Form errors exist"
msgstr ""
@ -5709,10 +5762,6 @@ msgstr ""
msgid "About InvenTree"
msgstr ""
#: templates/search_form.html:6 templates/search_form.html:8
msgid "Search"
msgstr ""
#: templates/stats.html:9
msgid "Server"
msgstr ""

View File

@ -343,11 +343,11 @@ class PurchaseOrder(Order):
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
stock.addTransactionNote("Received items", user, "Received {q} items against order '{po}'".format(
q=quantity,
po=str(self))
)
stock.addTransactionNote(text, user, note)
# Update the number of parts received against the particular line item
line.received += quantity

View File

@ -100,7 +100,7 @@ class PartTest(TestCase):
self.assertEqual(r.available_stock, 0)
def test_barcode(self):
barcode = self.r1.format_barcode()
barcode = self.r1.format_barcode(brief=False)
self.assertIn('InvenTree', barcode)
self.assertIn(self.r1.name, barcode)

View File

@ -195,11 +195,14 @@ class StockItem(MPTTModel):
super(StockItem, self).save(*args, **kwargs)
if add_note:
note = f"{_('Created new stock item for')} {str(self.part)}"
# This StockItem is being saved for the first time
self.addTransactionNote(
_('Created stock item'),
user,
notes="Created new stock item for part '{p}'".format(p=str(self.part)),
note,
system=True
)
@ -611,9 +614,9 @@ class StockItem(MPTTModel):
"""
self.addTransactionNote(
_("Returned from customer") + " " + self.customer.name,
_("Returned from customer") + f" {self.customer.name}",
user,
notes=_("Returned to location") + " " + location.name,
notes=_("Returned to location") + f" {location.name}",
system=True
)
@ -1000,12 +1003,17 @@ class StockItem(MPTTModel):
# Add a new tracking item for the new stock item
new_stock.addTransactionNote(
"Split from existing stock",
_("Split from existing stock"),
user,
"Split {n} from existing stock item".format(n=quantity))
f"{_('Split')} {helpers.normalize(quantity)} {_('items')}"
)
# 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,
f"{_('Split')} {quantity} {_('items into new stock item')}"
)
# Return a copy of the "new" stock item
return new_stock
@ -1054,10 +1062,10 @@ class StockItem(MPTTModel):
return True
msg = "Moved to {loc}".format(loc=str(location))
msg = f"{_('Moved to')} {str(location)}"
if self.location:
msg += " (from {loc})".format(loc=str(self.location))
msg += f" ({_('from')} {str(self.location)})"
self.location = location
@ -1125,10 +1133,16 @@ class StockItem(MPTTModel):
if self.updateQuantity(count):
self.addTransactionNote('Stocktake - counted {n} items'.format(n=helpers.normalize(count)),
user,
notes=notes,
system=True)
n = helpers.normalize(count)
text = f"{_('Counted')} {n} {_('items')}"
self.addTransactionNote(
text,
user,
notes=notes,
system=True
)
return True
@ -1154,10 +1168,15 @@ class StockItem(MPTTModel):
if self.updateQuantity(self.quantity + quantity):
self.addTransactionNote('Added {n} items to stock'.format(n=helpers.normalize(quantity)),
user,
notes=notes,
system=True)
n = helpers.normalize(quantity)
text = f"{_('Added')} {n} {_('items')}"
self.addTransactionNote(
text,
user,
notes=notes,
system=True
)
return True
@ -1180,7 +1199,10 @@ class StockItem(MPTTModel):
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,
notes=notes,
system=True)

View File

@ -122,7 +122,7 @@ class StockTest(TestCase):
self.assertEqual(self.home.get_absolute_url(), '/stock/location/1/')
def test_barcode(self):
barcode = self.office.format_barcode()
barcode = self.office.format_barcode(brief=False)
self.assertIn('"name": "Office"', barcode)
@ -284,7 +284,8 @@ class StockTest(TestCase):
# Check that a tracking item was added
track = StockItemTracking.objects.filter(item=it).latest('id')
self.assertIn('Stocktake', track.title)
self.assertIn('Counted', track.title)
self.assertIn('items', track.title)
self.assertIn('Counted items', track.notes)
n = it.tracking_info.count()

View File

@ -1114,7 +1114,7 @@ class StockAdjust(AjaxView, FormMixin):
return self.do_delete()
else:
return 'No action performed'
return _('No action performed')
def do_add(self):
@ -1129,7 +1129,7 @@ class StockAdjust(AjaxView, FormMixin):
count += 1
return _("Added stock to {n} items".format(n=count))
return f"{_('Added stock to ')} {count} {_('items')}"
def do_take(self):
@ -1144,7 +1144,7 @@ class StockAdjust(AjaxView, FormMixin):
count += 1
return _("Removed stock from {n} items".format(n=count))
return f"{_('Removed stock from ')} {count} {_('items')}"
def do_count(self):

View File

@ -113,7 +113,6 @@ InvenTree
<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script>
<script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script>
<script type='text/javascript' src="{% static 'script/inventree/filters.js' %}"></script>
<script type='text/javascript' src="{% static 'script/inventree/tables.js' %}"></script>
<script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script>
<script type='text/javascript' src="{% static 'script/inventree/sidenav.js' %}"></script>
@ -128,6 +127,7 @@ InvenTree
<script type='text/javascript' src="{% url 'build.js' %}"></script>
<script type='text/javascript' src="{% url 'order.js' %}"></script>
<script type='text/javascript' src="{% url 'calendar.js' %}"></script>
<script type='text/javascript' src="{% url 'tables.js' %}"></script>
<script type='text/javascript' src="{% url 'table_filters.js' %}"></script>
<script type='text/javascript' src="{% static 'fontawesome/js/solid.js' %}"></script>

View File

@ -1,3 +1,5 @@
{% load i18n %}
function editButton(url, text='Edit') {
return "<button class='btn btn-success edit-button btn-sm' type='button' url='" + url + "'>" + text + "</button>";
}
@ -263,4 +265,45 @@ function customGroupSorter(sortName, sortOrder, sortData) {
return 0;
}
});
}
}
// Expose default bootstrap table string literals to translation layer
(function ($) {
'use strict';
$.fn.bootstrapTable.locales['en-US-custom'] = {
formatLoadingMessage: function () {
return '{% trans "Loading data" %}';
},
formatRecordsPerPage: function (pageNumber) {
return `${pageNumber} {% trans "rows per page" %}`;
},
formatShowingRows: function (pageFrom, pageTo, totalRows) {
return `{% trans "Showing" %} ${pageFrom} {% trans "to" %} ${pageTo} {% trans "of" %} ${totalRows} {% trans "rows" %}`;
},
formatSearch: function () {
return '{% trans "Search" %}';
},
formatNoMatches: function () {
return '{% trans "No matching results" %}';
},
formatPaginationSwitch: function () {
return '{% trans "Hide/Show pagination" %}';
},
formatRefresh: function () {
return '{% trans "Refresh" %}';
},
formatToggle: function () {
return '{% trans "Toggle" %}';
},
formatColumns: function () {
return '{% trans "Columns" %}';
},
formatAllRows: function () {
return '{% trans "All" %}';
}
};
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['en-US-custom']);
})(jQuery);