From 2d412e2be10ffb3bb1bacac44dddbf7de99572b4 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 21 Jan 2021 20:55:13 +1100 Subject: [PATCH 1/9] Default to using "simple" QR codes --- InvenTree/InvenTree/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py index 6b76c7d41b..61172cfc62 100644 --- a/InvenTree/InvenTree/helpers.py +++ b/InvenTree/InvenTree/helpers.py @@ -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 = {} From 03f7baf87f34a31be5a2b07be918abbd3c68eb4f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 22 Jan 2021 09:50:30 +1100 Subject: [PATCH 2/9] Unit test fixes --- InvenTree/InvenTree/helpers.py | 2 +- InvenTree/InvenTree/tests.py | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py index 61172cfc62..99dc255dac 100644 --- a/InvenTree/InvenTree/helpers.py +++ b/InvenTree/InvenTree/helpers.py @@ -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: diff --git a/InvenTree/InvenTree/tests.py b/InvenTree/InvenTree/tests.py index 6630c0b0af..96f32e7f57 100644 --- a/InvenTree/InvenTree/tests.py +++ b/InvenTree/InvenTree/tests.py @@ -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): From 5c9dd93ff1faaa883ef7353165619cc82a46280d Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 22 Jan 2021 12:22:29 +1100 Subject: [PATCH 3/9] More unit test fix --- InvenTree/stock/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/stock/tests.py b/InvenTree/stock/tests.py index b0b05b6326..d232d3ab3d 100644 --- a/InvenTree/stock/tests.py +++ b/InvenTree/stock/tests.py @@ -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) From c1a54ddffddb12349a7301d1fe775d4596626afb Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 29 Jan 2021 12:04:36 +1100 Subject: [PATCH 4/9] Expose bootstrap table strings to translation layer --- InvenTree/InvenTree/urls.py | 1 + InvenTree/templates/base.html | 2 +- .../inventree => templates/js}/tables.js | 45 ++++++++++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) rename InvenTree/{InvenTree/static/script/inventree => templates/js}/tables.js (83%) diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 9ad7780122..2c56b8eeb1 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -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'), ] diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index f7ee1b2f19..1e6de2fb21 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -111,7 +111,6 @@ InvenTree - @@ -126,6 +125,7 @@ InvenTree + diff --git a/InvenTree/InvenTree/static/script/inventree/tables.js b/InvenTree/templates/js/tables.js similarity index 83% rename from InvenTree/InvenTree/static/script/inventree/tables.js rename to InvenTree/templates/js/tables.js index 21f9160758..9bb10552bf 100644 --- a/InvenTree/InvenTree/static/script/inventree/tables.js +++ b/InvenTree/templates/js/tables.js @@ -1,3 +1,5 @@ +{% load i18n %} + function editButton(url, text='Edit') { return ""; } @@ -263,4 +265,45 @@ function customGroupSorter(sortName, sortOrder, sortData) { return 0; } }); -} \ No newline at end of file +} + +// 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); \ No newline at end of file From 282ed0c63712dbebe9cf9f62d7f9060040bb344e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 29 Jan 2021 12:05:47 +1100 Subject: [PATCH 5/9] Recompile translations --- InvenTree/locale/de/LC_MESSAGES/django.po | 133 +++++++++++++++------- InvenTree/locale/en/LC_MESSAGES/django.po | 125 +++++++++++++------- InvenTree/locale/es/LC_MESSAGES/django.po | 125 +++++++++++++------- 3 files changed, 267 insertions(+), 116 deletions(-) diff --git a/InvenTree/locale/de/LC_MESSAGES/django.po b/InvenTree/locale/de/LC_MESSAGES/django.po index bc63af0b69..68126b7966 100644 --- a/InvenTree/locale/de/LC_MESSAGES/django.po +++ b/InvenTree/locale/de/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: C \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 "" diff --git a/InvenTree/locale/en/LC_MESSAGES/django.po b/InvenTree/locale/en/LC_MESSAGES/django.po index b12c0597d8..4236df6f39 100644 --- a/InvenTree/locale/en/LC_MESSAGES/django.po +++ b/InvenTree/locale/en/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/InvenTree/locale/es/LC_MESSAGES/django.po b/InvenTree/locale/es/LC_MESSAGES/django.po index b12c0597d8..4236df6f39 100644 --- a/InvenTree/locale/es/LC_MESSAGES/django.po +++ b/InvenTree/locale/es/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \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 "" From 4ef6a6dc624cb84b4ecf7366c804867f571fa1ce Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 29 Jan 2021 12:23:22 +1100 Subject: [PATCH 6/9] Translations for stock transaction notes --- InvenTree/order/models.py | 8 +++--- InvenTree/stock/models.py | 52 ++++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 32f25a78cc..d4d90b4d93 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -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 diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 78895b54e3..51c7bdc39f 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -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,9 +1003,10 @@ 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)) + _("Split") + f" {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)) @@ -1054,10 +1058,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 +1129,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 +1164,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 +1195,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) From 8fda2cf745eb12818b9631c6ff5104c65c563814 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 29 Jan 2021 12:47:46 +1100 Subject: [PATCH 7/9] Fixes for unit tests --- InvenTree/stock/models.py | 8 ++++++-- InvenTree/stock/tests.py | 3 ++- InvenTree/stock/views.py | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 51c7bdc39f..57faf2627e 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -1005,11 +1005,15 @@ class StockItem(MPTTModel): new_stock.addTransactionNote( _("Split from existing stock"), user, - _("Split") + f" {helpers.normalize(quantity)} " + _("items") + 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 diff --git a/InvenTree/stock/tests.py b/InvenTree/stock/tests.py index b0b05b6326..1461fe8e1a 100644 --- a/InvenTree/stock/tests.py +++ b/InvenTree/stock/tests.py @@ -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() diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index 11fc76b6e0..0129332d1d 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -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): From 97140b19ba5f39867d6a5deae3aa61dfac6dc7bc Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 31 Jan 2021 21:45:34 +1100 Subject: [PATCH 8/9] Limit barcode hash to printable characters. This is a dirty filthy hack, as the web-input strips non printable chars when they are typed in (but will accept them if they are copy-pasted) --- InvenTree/barcode/barcode.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/InvenTree/barcode/barcode.py b/InvenTree/barcode/barcode.py index 87235db190..3837fef599 100644 --- a/InvenTree/barcode/barcode.py +++ b/InvenTree/barcode/barcode.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import string import hashlib import logging @@ -16,9 +17,18 @@ 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! """ + 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()) From 43e03ed02306c7e29420a372223411dfbb39d9ea Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 1 Feb 2021 12:26:58 +1100 Subject: [PATCH 9/9] Update unit tests --- InvenTree/barcode/barcode.py | 2 ++ InvenTree/part/test_part.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/InvenTree/barcode/barcode.py b/InvenTree/barcode/barcode.py index 3837fef599..004182e0be 100644 --- a/InvenTree/barcode/barcode.py +++ b/InvenTree/barcode/barcode.py @@ -25,6 +25,8 @@ def hash_barcode(barcode_data): 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)) diff --git a/InvenTree/part/test_part.py b/InvenTree/part/test_part.py index 4c08911122..030d7faf4e 100644 --- a/InvenTree/part/test_part.py +++ b/InvenTree/part/test_part.py @@ -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)