From e3a273eee4698f23234f1d0a0d7bd2fb443360ba Mon Sep 17 00:00:00 2001
From: Joe Rogers <1337joe@gmail.com>
Date: Tue, 27 Oct 2026 08:51:28 -0600
Subject: [PATCH] Update to schema 566 (#363)
Audit log API (/api/audit/) is available to all authenticated users (entries are filtered by model permissions)
Adds "event_type", "event_label", "notes" and "deltas" fields to the audit log API
Adds "event_type" filter to the audit log API
Stock item history is recorded in the audit log (StockItem events, with event_type values from StockHistoryCode)
Breaking: Removes the stock tracking API endpoints (/api/stock/track/, /api/stock/track//, /api/stock/track/status/) - use /api/audit/ instead
Breaking: Removes the "tracking_items" field from the StockItem API
Breaking: Removes the "copy_history" option when duplicating a StockItem
---
.github/demo-dataset_hash.txt | 2 +-
.github/inventree_test_hash.txt | 2 +-
pom.xml | 2 +-
src/main/resources/api.yaml | 261 +-
.../inventree/InventreeDemoDataset.java | 4 +-
.../w3asel/inventree/api/TestAuditApi.java | 274 +-
.../w3asel/inventree/api/TestStockApi.java | 138 -
src/test/resources/inventree_data.json | 88142 ++++++++++++----
8 files changed, 65923 insertions(+), 22902 deletions(-)
diff --git a/.github/demo-dataset_hash.txt b/.github/demo-dataset_hash.txt
index a6d0db0..1bd4dc0 100644
--- a/.github/demo-dataset_hash.txt
+++ b/.github/demo-dataset_hash.txt
@@ -1 +1 @@
-32e83c63a444d1c850ef78e7feab1af95dcd862c
+256f9c78195e123864de1985b69240f5357af282
diff --git a/.github/inventree_test_hash.txt b/.github/inventree_test_hash.txt
index a1c6442..286a8ef 100644
--- a/.github/inventree_test_hash.txt
+++ b/.github/inventree_test_hash.txt
@@ -1 +1 @@
-c475e9bfcfa8e0f7e8ac1022477968cacfd84fce
+c4280c2a03dec87afda9478957dba328f82ae4b6
diff --git a/pom.xml b/pom.xml
index c74e503..e9c62f3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.w3asel
inventree-sdk-java
jar
- 1.6.565-SNAPSHOT
+ 1.6.566-SNAPSHOT
InvenTree SDK (Java)
A Java implementation of the OpenAPI spec published by InvenTree.
diff --git a/src/main/resources/api.yaml b/src/main/resources/api.yaml
index 2209fc6..3e0f65a 100644
--- a/src/main/resources/api.yaml
+++ b/src/main/resources/api.yaml
@@ -1,7 +1,7 @@
openapi: 3.0.3
info:
title: InvenTree API
- version: '565'
+ version: '566'
description: API for InvenTree - the intuitive open source inventory management
system
license:
@@ -1063,6 +1063,10 @@ paths:
name: cid
schema:
type: string
+ - in: query
+ name: event_type
+ schema:
+ type: integer
- in: query
name: include_children
schema:
@@ -1127,7 +1131,7 @@ paths:
- basicAuth: []
- cookieAuth: []
- oauth2:
- - a:staff
+ - g:read
responses:
'200':
content:
@@ -1157,7 +1161,7 @@ paths:
- basicAuth: []
- cookieAuth: []
- oauth2:
- - a:staff
+ - g:read
responses:
'200':
content:
@@ -22488,146 +22492,6 @@ paths:
responses:
'204':
description: No response body
- /api/stock/track/:
- get:
- operationId: stock_track_list
- description: |-
- API endpoint for list view of StockItemTracking objects.
-
- StockItemTracking objects are read-only
- (they are created by internal model functionality)
-
- - GET: Return list of StockItemTracking objects
- parameters:
- - in: query
- name: include_variants
- schema:
- type: boolean
- description: Include Part Variants
- - in: query
- name: item
- schema:
- type: integer
- - in: query
- name: item_detail
- schema:
- type: boolean
- default: false
- description: Include detailed information about the item in the response
- - name: limit
- required: true
- in: query
- description: Number of results to return per page.
- schema:
- type: integer
- - in: query
- name: max_date
- schema:
- type: string
- format: date
- description: Date before
- - in: query
- name: min_date
- schema:
- type: string
- format: date
- description: Date after
- - name: offset
- required: false
- in: query
- description: The initial index from which to return the results.
- schema:
- type: integer
- - name: ordering
- required: false
- in: query
- description: Which field to use when ordering the results.
- schema:
- type: string
- enum:
- - date
- - -date
- - in: query
- name: part
- schema:
- type: integer
- description: Part
- - name: search
- required: false
- in: query
- description: 'A search term. Searched fields: notes.'
- schema:
- type: string
- - in: query
- name: user
- schema:
- type: integer
- - in: query
- name: user_detail
- schema:
- type: boolean
- default: false
- tags:
- - stock
- security:
- - tokenAuth: []
- - basicAuth: []
- - cookieAuth: []
- - oauth2:
- - r:view:stock
- responses:
- '200':
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/PaginatedStockTrackingList'
- description: ''
- /api/stock/track/{id}/:
- get:
- operationId: stock_track_retrieve
- description: Detail API endpoint for StockItemTracking model.
- parameters:
- - in: path
- name: id
- schema:
- type: integer
- required: true
- tags:
- - stock
- security:
- - tokenAuth: []
- - basicAuth: []
- - cookieAuth: []
- - oauth2:
- - r:view:stock
- responses:
- '200':
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/StockTracking'
- description: ''
- /api/stock/track/status/:
- get:
- operationId: stock_track_status_retrieve
- description: Retrieve information about a specific status code
- tags:
- - stock
- security:
- - tokenAuth: []
- - basicAuth: []
- - cookieAuth: []
- - oauth2:
- - g:read
- responses:
- '200':
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/GenericStateClass'
- description: ''
- '400':
- description: Invalid request
/api/stock/transfer/:
post:
operationId: stock_transfer_create
@@ -27600,6 +27464,23 @@ components:
type: string
readOnly: true
nullable: true
+ event_type:
+ type: integer
+ readOnly: true
+ nullable: true
+ event_label:
+ type: string
+ readOnly: true
+ nullable: true
+ title: Event
+ notes:
+ type: string
+ readOnly: true
+ nullable: true
+ description: Notes associated with this entry
+ deltas:
+ nullable: true
+ readOnly: true
model_type:
type: string
readOnly: true
@@ -29799,7 +29680,6 @@ components:
- stockitemtestresult
- stockitem
- stocklocation
- - stockitemtracking
- purchaseorder
- purchaseorderlineitem
- purchaseorderextraline
@@ -29836,7 +29716,6 @@ components:
* `stockitemtestresult` - Stock Item Test Result
* `stockitem` - Stock Item
* `stocklocation` - Stock Location
- * `stockitemtracking` - Stock Item Tracking
* `purchaseorder` - Purchase Order
* `purchaseorderlineitem` - Purchase Order Line Item
* `purchaseorderextraline` - Purchase Order Extra Line
@@ -33918,29 +33797,6 @@ components:
type: array
items:
$ref: '#/components/schemas/StockLocationType'
- PaginatedStockTrackingList:
- type: object
- required:
- - count
- - results
- properties:
- count:
- type: integer
- example: 123
- next:
- type: string
- nullable: true
- format: uri
- example: http://api.example.org/accounts/?offset=400&limit=100
- previous:
- type: string
- nullable: true
- format: uri
- example: http://api.example.org/accounts/?offset=200&limit=100
- results:
- type: array
- items:
- $ref: '#/components/schemas/StockTracking'
PaginatedSupplierPartList:
type: object
required:
@@ -40209,10 +40065,6 @@ components:
$ref: '#/components/schemas/StockItemTestResult'
readOnly: true
nullable: true
- tracking_items:
- type: integer
- readOnly: true
- nullable: true
PatchedStockItemTestResult:
type: object
description: Serializer for the StockItemTestResult model.
@@ -44467,10 +44319,6 @@ components:
$ref: '#/components/schemas/StockItemTestResult'
readOnly: true
nullable: true
- tracking_items:
- type: integer
- readOnly: true
- nullable: true
required:
- barcode_hash
- in_stock
@@ -44493,10 +44341,6 @@ components:
default: false
title: Copy Test Results
description: Copy test results from the original stock item
- copy_history:
- type: boolean
- default: false
- description: Copy stock history from the original stock item
copy_notes:
type: boolean
default: true
@@ -44703,63 +44547,6 @@ components:
* `quantity` - Smallest quantity first
* `-quantity` - Largest quantity first
* `expiry_date` - Soonest expiry date first
- StockTracking:
- type: object
- description: Serializer for StockItemTracking model.
- properties:
- pk:
- type: integer
- readOnly: true
- title: ID
- item:
- type: integer
- nullable: true
- item_detail:
- allOf:
- - $ref: '#/components/schemas/StockItem'
- readOnly: true
- nullable: true
- part:
- type: integer
- readOnly: true
- nullable: true
- part_detail:
- allOf:
- - $ref: '#/components/schemas/PartBrief'
- readOnly: true
- nullable: true
- date:
- type: string
- format: date-time
- readOnly: true
- deltas:
- readOnly: true
- label:
- type: string
- readOnly: true
- notes:
- type: string
- nullable: true
- description: Entry notes
- maxLength: 512
- tracking_type:
- type: integer
- readOnly: true
- user:
- type: integer
- readOnly: true
- nullable: true
- user_detail:
- allOf:
- - $ref: '#/components/schemas/User'
- readOnly: true
- nullable: true
- required:
- - date
- - deltas
- - label
- - pk
- - tracking_type
StockTransfer:
type: object
description: Serializer for transferring (moving) stock item(s).
diff --git a/src/test/java/com/w3asel/inventree/InventreeDemoDataset.java b/src/test/java/com/w3asel/inventree/InventreeDemoDataset.java
index 7f27a37..897d2dc 100644
--- a/src/test/java/com/w3asel/inventree/InventreeDemoDataset.java
+++ b/src/test/java/com/w3asel/inventree/InventreeDemoDataset.java
@@ -193,6 +193,7 @@ void verifyModels() {
public enum Model {
GROUP("auth.group"),
USER("auth.user"),
+ AUDIT_LOGENTRY("audit.auditlogentry"),
BUILD("build.build"),
BUILD_ITEM("build.builditem"),
BUILD_LINE("build.buildline"),
@@ -230,7 +231,7 @@ public enum Model {
PART_PRICING("part.partpricing"),
PART_RELATED("part.partrelated"),
PART_SELL_PRICE_BREAK("part.partsellpricebreak"),
- PART_START("part.partstar"),
+ PART_STAR("part.partstar"),
PART_STOCKTAKE("part.partstocktake"),
PART_TEST_TEMPLATE("part.parttesttemplate"),
PRICING_INTERNAL_PRICE_BREAK("pricing.partinternalpricebreak"),
@@ -240,7 +241,6 @@ public enum Model {
SELECTION_LIST_ENTRY("common.selectionlistentry"),
STOCK_ITEM("stock.stockitem"),
STOCK_TEST_RESULT("stock.stockitemtestresult"),
- STOCK_TRACKING("stock.stockitemtracking"),
STOCK_LOCATION("stock.stocklocation"),
STOCK_LOCATION_TYPE("stock.stocklocationtype"),
TAG("taggit.tag"),
diff --git a/src/test/java/com/w3asel/inventree/api/TestAuditApi.java b/src/test/java/com/w3asel/inventree/api/TestAuditApi.java
index 15fb890..6264cc5 100644
--- a/src/test/java/com/w3asel/inventree/api/TestAuditApi.java
+++ b/src/test/java/com/w3asel/inventree/api/TestAuditApi.java
@@ -1,9 +1,29 @@
package com.w3asel.inventree.api;
+import static com.w3asel.inventree.InventreeDemoDataset.assertFieldEquals;
+import static com.w3asel.inventree.InventreeDemoDataset.assertNullableFieldEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertIterableEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.w3asel.inventree.InventreeDemoDataset;
+import com.w3asel.inventree.InventreeDemoDataset.Model;
import com.w3asel.inventree.invoker.ApiException;
+import com.w3asel.inventree.model.AuditLogEntry;
+import com.w3asel.inventree.model.PaginatedAuditLogEntryList;
+import java.time.LocalDate;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
public class TestAuditApi extends TestApi {
private AuditApi api;
@@ -13,17 +33,253 @@ void setup() {
api = new AuditApi(apiClient);
}
- @Disabled
- @Test
- void todo() throws ApiException {
- api.auditList(null, null, null, null, null, null, null, null, null, null, null, null);
- api.auditRetrieve(null);
+ private static String mergeContentType(JsonElement element) {
+ if (element.isJsonNull()) {
+ return null;
+ }
+ JsonArray array = element.getAsJsonArray();
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < array.size(); i++) {
+ if (i > 0) {
+ sb.append(".");
+ }
+ sb.append(array.get(i).getAsString());
+ }
+ return sb.toString();
+ }
+
+ private static void assertArrayEquals(String field, JsonArray expectedArray, List