2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-05 05:00:58 +00:00

Barcode logging (#8150)

* Add model for recording barcode scan results

* Add "admin" interface for new model

* Add API endpoints for barcode scan history

* Add global setting to control barcode result save

* Add frontend API endpoint

* Add PUI table in "admin center"

* Add API filter class

* Enable table filtering

* Update model definition

* Allow more characters for barcode log

* Log results to server

* Add setting to control how long results are stored

* Table updates

* Add background task to delete old barcode scans

* Add detail drawer for barcode scan

* Log messages for BarcodePOReceive

* Add warning message if barcode logging is not enabled

* Add "context" data to BarcodeScanResult

* Display context data (if available)

* Add context data when scanning

* Simplify / refactor BarcodeSOAllocate

* Refactor BarcodePOAllocate

* Limit the number of saved scans

* Improve error message display in PUI

* Simplify barcode logging

* Improve table

* Updates

* Settings page fix

* Fix panel tooltips

* Adjust table

* Add "result" field

* Refactor calls to "log_scan"

* Display result in PUI table

* Updates

* Fix typo

* Update unit test

* Improve exception handling

* Unit test updates

* Enhanced unit test

* Ensure all database key config values are upper case

* Refactor some playwright helpers

* Adds playwright test for barcode scan history table

* Requires some timeout

* Add docs
This commit is contained in:
Oliver
2024-09-23 23:30:50 +10:00
committed by GitHub
parent f7e0edb7a6
commit 6002103129
28 changed files with 929 additions and 168 deletions

View File

@ -1,6 +1,7 @@
import { expect, test } from './baseFixtures.js';
import { baseUrl } from './defaults.js';
import { apiUrl, baseUrl } from './defaults.js';
import { doQuickLogin } from './login.js';
import { setSettingState } from './settings.js';
test('PUI - Admin', async ({ page }) => {
// Note here we login with admin access
@ -85,6 +86,43 @@ test('PUI - Admin', async ({ page }) => {
await page.getByRole('button', { name: 'Submit' }).click();
});
test('PUI - Admin - Barcode History', async ({ page, request }) => {
// Login with admin credentials
await doQuickLogin(page, 'admin', 'inventree');
// Ensure that the "save scans" setting is enabled
await setSettingState({
request: request,
setting: 'BARCODE_STORE_RESULTS',
value: true
});
// Scan some barcodes (via API calls)
const barcodes = ['ABC1234', 'XYZ5678', 'QRS9012'];
barcodes.forEach(async (barcode) => {
await request.post(`${apiUrl}/barcode/`, {
data: {
barcode: barcode
},
headers: {
Authorization: `Basic ${btoa('admin:inventree')}`
}
});
});
await page.getByRole('button', { name: 'admin' }).click();
await page.getByRole('menuitem', { name: 'Admin Center' }).click();
await page.getByRole('tab', { name: 'Barcode Scans' }).click();
await page.waitForTimeout(2000);
// Barcode history is displayed in table
barcodes.forEach(async (barcode) => {
await page.getByText(barcode).first().waitFor();
});
});
test('PUI - Admin - Unauthorized', async ({ page }) => {
// Try to access "admin" page with a non-staff user
await doQuickLogin(page, 'allaccess', 'nolimits');