Compare commits

...

11 Commits

Author SHA1 Message Date
github-actions[bot] fd7d0bda0f
Batch update of records during migration (#11371) (#11373)
* Batch update of records during migration

Reduce issues with very large datasets

* Add short-circuit logic

* Filter and prefetch

(cherry picked from commit a4a399022f)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2026-02-19 12:07:16 +11:00
Oliver 90e5169283
Bump software version to 1.2.2 (#11360) 2026-02-18 10:51:42 +11:00
github-actions[bot] 198594d7d3
Prevent migration check if performing DB update operations (#11356) (#11358)
* Prevent migration check if performing DB update operations

* Prevent settings write during data imports

* Prevent exchange rate update during migration processes

* Allow exchange rate updates during tests or shell session

(cherry picked from commit 951586a698)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2026-02-18 00:27:32 +11:00
github-actions[bot] dededb0aa1
refactor(backend): switch release pipeline to new pkgr version (#11336) (#11355)
* refactor(backend): switch release pipeline to new pkgr version

* fix wrong assign

* fix warnings

* also publish to release artifacts

(cherry picked from commit 1cc1f059c8)

Co-authored-by: Matthias Mair <code@mjmair.com>
2026-02-17 21:48:48 +11:00
github-actions[bot] eb413bcc57
disable traceid gen in unsecure context (#11349) (#11350)
(cherry picked from commit b8cf2db68e)

Co-authored-by: Matthias Mair <code@mjmair.com>
2026-02-17 10:47:32 +11:00
Oliver 9b11cd294e
Bump software version to 1.2.1 (#11313)
* Bump software version to 1.2.1

* Fix style issues

* [CI] Allow more test time

* Disable performance testing

---------

Co-authored-by: Matthias Mair <code@mjmair.com>
2026-02-16 12:46:45 +11:00
github-actions[bot] ccf5b39bf1
[bug] FIx for data migration (#11329) (#11330)
* [bug] FIx for data migration

Prevent writing of default currency to database during migration or backup

* Ignore error

(cherry picked from commit 7a646946c3)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2026-02-15 22:44:21 +11:00
github-actions[bot] eceaa68c32
Tweak docs for database migration (#11327) (#11328)
(cherry picked from commit 867f5a6cd5)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2026-02-15 10:50:34 +11:00
github-actions[bot] ccb4ea248b
Update base image in Dockerfile (#11309) (#11322)
* Bump version number to 1.2.0 (#11299)

* Bump version number to 1.2.0

* Update CHANGELOG.md

* Update base image in Dockerfile

Updated base image to the latest version as of 2026-02-12.

* Fix for devcontainer build (#11311) (#11312)

- Install yarn a different way

(cherry picked from commit 2a613809ec)



---------



(cherry picked from commit 723a4be24a)

Co-authored-by: Matthias Mair <code@mjmair.com>
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-02-14 12:55:47 +11:00
github-actions[bot] 9b3b68c8d8
Fix for devcontainer build (#11311) (#11312)
- Install yarn a different way

(cherry picked from commit 2a613809ec)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2026-02-13 11:17:52 +11:00
Oliver 3752b610c8
Bump version number to 1.2.0 (#11299)
* Bump version number to 1.2.0

* Update CHANGELOG.md
2026-02-12 19:53:08 +11:00
18 changed files with 179 additions and 29 deletions

View File

@ -37,9 +37,10 @@ RUN apt install -y nodejs npm
# Update to the latest stable node version # Update to the latest stable node version
RUN npm install -g n --ignore-scripts && n lts RUN npm install -g n --ignore-scripts && n lts
# Enable yarn # Install yarn
RUN corepack enable && corepack prepare yarn@stable --activate RUN npm install -g yarn
# Ensure node and yarn are available at the command line
RUN node --version && yarn --version RUN node --version && yarn --version
RUN yarn config set httpTimeout 600000 --home RUN yarn config set httpTimeout 600000 --home

View File

@ -23,6 +23,8 @@ env:
INVENTREE_SITE_URL: http://localhost:8000 INVENTREE_SITE_URL: http://localhost:8000
INVENTREE_DEBUG: true INVENTREE_DEBUG: true
use_performance: false
permissions: permissions:
contents: read contents: read
@ -78,7 +80,7 @@ jobs:
- name: Which runner to use? - name: Which runner to use?
id: runner-perf id: runner-perf
# decide if we are running in inventree/inventree -> use codspeed-macro runner else ubuntu-24.04 # decide if we are running in inventree/inventree -> use codspeed-macro runner else ubuntu-24.04
run: echo "runner=$([[ '${{ github.repository }}' == 'inventree/InvenTree' ]] && echo 'codspeed-macro' || echo 'ubuntu-24.04')" >> $GITHUB_OUTPUT run: echo "runner=$([[ '${{ github.repository }}' == 'inventree/InvenTree' ]] && '${{ env.use_performance }}' == 'true' ]] && echo 'codspeed-macro' || echo 'ubuntu-24.04')" >> $GITHUB_OUTPUT
pre-commit: pre-commit:
name: Style [pre-commit] name: Style [pre-commit]

View File

@ -85,6 +85,11 @@ jobs:
asset_name: frontend-build.zip asset_name: frontend-build.zip
tag: ${{ github.ref }} tag: ${{ github.ref }}
overwrite: true overwrite: true
- name: Upload frontend to artifacts
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # pin@v6.0.0
with:
name: frontend-build
path: src/backend/InvenTree/web/static/frontend-build.zip
- name: Upload Attestation - name: Upload Attestation
uses: svenstaro/upload-release-action@6b7fa9f267e90b50a19fef07b3596790bb941741 # pin@2.11.3 uses: svenstaro/upload-release-action@6b7fa9f267e90b50a19fef07b3596790bb941741 # pin@2.11.3
with: with:
@ -136,3 +141,98 @@ jobs:
asset_name: docs-html.zip asset_name: docs-html.zip
tag: ${{ github.ref }} tag: ${{ github.ref }}
overwrite: true overwrite: true
build-pkgr:
if: github.repository == 'inventree/InvenTree'
name: ${{ matrix.target }}
runs-on: ubuntu-latest
needs: [build, docs]
strategy:
fail-fast: false
matrix:
target:
- ubuntu:22.04
- ubuntu:24.04
- debian:12
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pin@v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Get frontend artifact
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # pin@v7.0.0
with:
name: frontend-build
- name: Setup
id: setup
env:
NODE_ID: ${{ github.event.release.node_id }}
BRANCH: ${{ github.event.release.target_commitish }}
TARGET: ${{github.event.release.target_commitish}}
REPO: ${{ github.repository }}
run: |
# Get info
gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/$REPO/commits/$TARGET > commit.json
# Extract info
echo "INFO extract | Extracting info from github"
DATE=$(jq -r '.commit.committer.date' commit.json)
SIGNATURE=$(jq -r '.commit.verification.signature' commit.json)
FULL_SHA=$(jq -r '.sha' commit.json)
SHA=$(echo "$FULL_SHA" | cut -c1-7)
echo "INFO write | Write VERSION information"
echo "$VERSION" > VERSION
echo "INVENTREE_COMMIT_HASH='$SHA'" >> VERSION
echo "INVENTREE_COMMIT_SHA='$FULL_SHA'" >> VERSION
echo "INVENTREE_COMMIT_DATE='$DATE'" >> VERSION
echo "INVENTREE_PKG_INSTALLER='PKG'" >> VERSION
echo "INVENTREE_PKG_BRANCH='$BRANCH'" >> VERSION
echo "INVENTREE_PKG_TARGET='$TARGET'" >> VERSION
echo "NODE_ID='$NODE_ID'" >> VERSION
echo "SIGNATURE='$SIGNATURE'" >> VERSION
echo "INFO write | Written VERSION information"
echo "### VERSION ###"
cat VERSION
echo "### VERSION ###"
# Move frontend build into place
mkdir -p src/backend/InvenTree/web/static
unzip -qq frontend-build.zip -d src/backend/InvenTree/web/static/web
- name: Package
uses: pkgr/action/package@c5666febcd31750da6428042193fc5b2fb765435 # pin@main
id: package
with:
target: ${{ matrix.target }}
version: ${{ steps.setup.outputs.version }}
debug: true
cache_prefix: ${{ github.ref_name }}
env: |
INVENTREE_DB_ENGINE=sqlite3
INVENTREE_DB_NAME=database.sqlite3
INVENTREE_PLUGINS_ENABLED=true
INVENTREE_MEDIA_ROOT=/opt/inventree/media
INVENTREE_STATIC_ROOT=/opt/inventree/static
INVENTREE_BACKUP_DIR=/opt/inventree/backup
INVENTREE_PLUGIN_FILE=/opt/inventree/plugins.txt
INVENTREE_CONFIG_FILE=/opt/inventree/config.yaml
APP_REPO=inventree/InvenTree
- name: Publish to go.packager.io
uses: pkgr/action/publish@3bce081ae512c5020856e237d37b3f5479d4aa71 # pin@main
with:
target: ${{ matrix.target }}
token: ${{ secrets.PACKAGER_RELEASE_TOKEN }}
repository: inventree/inventree
channel: ${{ github.ref_name }}
file: ${{ steps.package.outputs.package_path }}
- name: Publish to artifact
uses: svenstaro/upload-release-action@6b7fa9f267e90b50a19fef07b3596790bb941741 # pin@2.11.3
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.package.outputs.package_path }}
asset_name: ${{ matrix.target }}-{{ steps.setup.outputs.version }}.tar.gz
tag: ${{ github.ref }}
overwrite: true

View File

@ -6,7 +6,7 @@ buildpack: https://github.com/matmair/null-buildpack#master
env: env:
- INVENTREE_DB_ENGINE=sqlite3 - INVENTREE_DB_ENGINE=sqlite3
- INVENTREE_DB_NAME=database.sqlite3 - INVENTREE_DB_NAME=database.sqlite3
- INVENTREE_PLUGINS_ENABLED - INVENTREE_PLUGINS_ENABLED=true
- INVENTREE_MEDIA_ROOT=/opt/inventree/media - INVENTREE_MEDIA_ROOT=/opt/inventree/media
- INVENTREE_STATIC_ROOT=/opt/inventree/static - INVENTREE_STATIC_ROOT=/opt/inventree/static
- INVENTREE_BACKUP_DIR=/opt/inventree/backup - INVENTREE_BACKUP_DIR=/opt/inventree/backup

View File

@ -18,7 +18,7 @@ repos:
exclude: mkdocs.yml exclude: mkdocs.yml
- id: mixed-line-ending - id: mixed-line-ending
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.10 rev: v0.15.1
hooks: hooks:
- id: ruff-format - id: ruff-format
args: [--preview] args: [--preview]
@ -29,7 +29,7 @@ repos:
--preview --preview
] ]
- repo: https://github.com/astral-sh/uv-pre-commit - repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.9.22 rev: 0.10.2
hooks: hooks:
- id: pip-compile - id: pip-compile
name: pip-compile requirements-dev.in name: pip-compile requirements-dev.in
@ -79,7 +79,7 @@ repos:
src/frontend/vite.config.ts | src/frontend/vite.config.ts |
)$ )$
- repo: https://github.com/biomejs/pre-commit - repo: https://github.com/biomejs/pre-commit
rev: v2.3.10 rev: v2.3.15
hooks: hooks:
- id: biome-check - id: biome-check
additional_dependencies: ["@biomejs/biome@1.9.4"] additional_dependencies: ["@biomejs/biome@1.9.4"]

View File

@ -1,15 +1,15 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file (starting with 1.0.0). All major notable changes to this project will be documented in this file (starting with 1.0.0).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased - YYYY-MM-DD ## 1.2.0 - 2026-02-12
### Breaking Changes ### Breaking Changes
- [#10699](https://github.com/inventree/InvenTree/pull/10699) removes the `PartParameter` and `PartParameterTempalate` models (and associated API endpoints). These have been replaced with generic `Parameter` and `ParameterTemplate` models (and API endpoints). Any external client applications which made use of the old endpoints will need to be updated. - [#10699](https://github.com/inventree/InvenTree/pull/10699) removes the `PartParameter` and `PartParameterTemplate` models (and associated API endpoints). These have been replaced with generic `Parameter` and `ParameterTemplate` models (and API endpoints). Any external client applications which made use of the old endpoints will need to be updated.
- [#11035](https://github.com/inventree/InvenTree/pull/11035) moves to a single endpoint for all metadata operations. The previous endpoints for PartMetadata, SupplierPartMetadata, etc have been removed. Any external client applications which made use of the old endpoints will need to be updated. - [#11035](https://github.com/inventree/InvenTree/pull/11035) moves to a single endpoint for all metadata operations. The previous endpoints for PartMetadata, SupplierPartMetadata, etc have been removed. Any external client applications which made use of the old endpoints will need to be updated.
### Added ### Added
@ -19,10 +19,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Adds parameter support for multiple new model types in [#10699](https://github.com/inventree/InvenTree/pull/10699) - Adds parameter support for multiple new model types in [#10699](https://github.com/inventree/InvenTree/pull/10699)
- Allows report generator to produce PDF input controls in [#10969](https://github.com/inventree/InvenTree/pull/10969) - Allows report generator to produce PDF input controls in [#10969](https://github.com/inventree/InvenTree/pull/10969)
- UI overhaul of parameter management in [#10699](https://github.com/inventree/InvenTree/pull/10699) - UI overhaul of parameter management in [#10699](https://github.com/inventree/InvenTree/pull/10699)
- Allow input controls within generated PDF reports in [#10969](https://github.com/inventree/InvenTree/pull/10969)
### Changed ### Changed
- - Improved stocktake functionality in [#11257](https://github.com/inventree/InvenTree/pull/11257)
### Removed ### Removed
- Removed python 3.9 / 3.10 support as part of Django 5.2 upgrade in [#10730](https://github.com/inventree/InvenTree/pull/10730) - Removed python 3.9 / 3.10 support as part of Django 5.2 upgrade in [#10730](https://github.com/inventree/InvenTree/pull/10730)

View File

@ -9,7 +9,8 @@
# - Runs InvenTree web server under django development server # - Runs InvenTree web server under django development server
# - Monitors source files for any changes, and live-reloads server # - Monitors source files for any changes, and live-reloads server
FROM python:3.11-slim-trixie@sha256:1d6131b5d479888b43200645e03a78443c7157efbdb730e6b48129740727c312 AS inventree_base # Base image last bumped 2026-02-12
FROM python:3.11-slim-trixie@sha256:0b23cfb7425d065008b778022a17b1551c82f8b4866ee5a7a200084b7e2eafbf AS inventree_base
# Build arguments for this image # Build arguments for this image
ARG commit_tag="" ARG commit_tag=""

View File

@ -117,7 +117,7 @@ Once the migration process completes, the database records are now updated! Rest
## Migrating Between Incompatible Database Versions ## Migrating Between Incompatible Database Versions
There may be occasions when InvenTree data needs to be migrated between two database installations running *incompatible* versions of the database software. For example, InvenTree may be running on a Postgres database running on version 12, and the administrator wishes to migrate the data to a Postgres version 17 database. There may be occasions when InvenTree data needs to be migrated between two database installations running *incompatible* versions of the database software. For example, InvenTree may be running on a Postgres database running on version 12, and the administrator wishes to migrate the data to a Postgres version {{ config.extra.docker_postgres_version }} database.
!!! warning "Advanced Procedure" !!! warning "Advanced Procedure"
The following procedure is *advanced*, and should only be attempted by experienced database administrators. Always ensure that database backups are made before attempting any migration procedure. The following procedure is *advanced*, and should only be attempted by experienced database administrators. Always ensure that database backups are made before attempting any migration procedure.
@ -127,7 +127,7 @@ Due to inherit incompatibilities between different major versions of database so
!!! warning "InvenTree Version" !!! warning "InvenTree Version"
It is *crucial* that both InvenTree database installations are running the same version of InvenTree software! If this is not the case, data migration may fail, and there is a possibility that data corruption can occur. Ensure that the original database is up to date, by running `invoke update`. It is *crucial* that both InvenTree database installations are running the same version of InvenTree software! If this is not the case, data migration may fail, and there is a possibility that data corruption can occur. Ensure that the original database is up to date, by running `invoke update`.
The following instructions assume that the source (old) database is Postgres version 15, and the target (new) database is Postgres version 17. Additionally, it assumes that the InvenTree installation is running under [docker / docker compose](./docker.md), for simplicity. Adjust commands as required for other InvenTree configurations or database software. The following instructions assume that the source (old) database is Postgres version 15, and the target (new) database is Postgres version {{ config.extra.docker_postgres_version }}. Additionally, it assumes that the InvenTree installation is running under [docker / docker compose](./docker.md), for simplicity. Adjust commands as required for other InvenTree configurations or database software.
The overall procedure is as follows: The overall procedure is as follows:
@ -154,13 +154,13 @@ docker compose down
### Remove Old Database Files ### Remove Old Database Files
The raw database files are incompatible between different major versions of Postgres. Thus, the old database files must be removed before starting the new database. The raw database files are incompatible between different major versions of Postgres. Thus, the old database files must be removed before starting the new database. Rather than removing the database directory, we will move the database files to a temporary location, just in case we need to revert back to the old database.
!!! warning "Data Loss" !!! warning "Data Loss"
Ensure that a complete backup of the old database has been made before proceeding! Removing the database files will result in data loss if a backup does not exist. Ensure that a complete backup of the old database has been made before proceeding! Removing the database files will result in data loss if a backup does not exist.
``` ```
rm -rf ./path/to/database/* mv ./path/to/database ./path/to/database_backup
``` ```
!!! info "Database Location" !!! info "Database Location"
@ -168,7 +168,7 @@ rm -rf ./path/to/database/*
### Start New Database ### Start New Database
Update the InvenTree docker configuration to use the new version of Postgres (e.g. `postgres:17`), and then start the InvenTree installation: Update the InvenTree docker configuration to use the new version of Postgres (e.g. `postgres:{{ config.extra.docker_postgres_version }}`), and then start the InvenTree installation:
``` ```
docker compose up -d docker compose up -d

View File

@ -331,6 +331,11 @@ class InvenTreeConfig(AppConfig):
if MIGRATIONS_CHECK_DONE: if MIGRATIONS_CHECK_DONE:
return return
# Exit early if we are not in a state where we can access the database,
# otherwise we might end up in a deadlock situation
if not InvenTree.ready.canAppAccessDatabase():
return
if not InvenTree.tasks.check_for_migrations(): if not InvenTree.tasks.check_for_migrations():
# Detect if this an empty database - if so, start with a fresh migration # Detect if this an empty database - if so, start with a fresh migration
if ( if (

View File

@ -587,6 +587,12 @@ def update_exchange_rates(force: bool = False):
Arguments: Arguments:
force: If True, force the update to run regardless of the last update time force: If True, force the update to run regardless of the last update time
""" """
from InvenTree.ready import canAppAccessDatabase
# Do not update exchange rates if we cannot access the database
if not canAppAccessDatabase(allow_test=True, allow_shell=True):
return
try: try:
from djmoney.contrib.exchange.models import Rate from djmoney.contrib.exchange.models import Rate

View File

@ -17,7 +17,7 @@ from django.conf import settings
from .api_version import INVENTREE_API_TEXT, INVENTREE_API_VERSION from .api_version import INVENTREE_API_TEXT, INVENTREE_API_VERSION
# InvenTree software version # InvenTree software version
INVENTREE_SW_VERSION = '1.2.0 dev' INVENTREE_SW_VERSION = '1.2.2'
# Minimum supported Python version # Minimum supported Python version
MIN_PYTHON_VERSION = (3, 11) MIN_PYTHON_VERSION = (3, 11)

View File

@ -19,6 +19,11 @@ logger = structlog.get_logger('inventree')
def currency_code_default(create: bool = True): def currency_code_default(create: bool = True):
"""Returns the default currency code (or USD if not specified).""" """Returns the default currency code (or USD if not specified)."""
from common.settings import get_global_setting from common.settings import get_global_setting
from InvenTree.ready import isRunningBackup, isRunningMigrations
if isRunningMigrations() or isRunningBackup():
# Prevent database writes during migration or backup operations
create = False
code = '' code = ''

View File

@ -1216,7 +1216,9 @@ class InvenTreeSetting(BaseInvenTreeSetting):
even if that key does not exist. even if that key does not exist.
""" """
SETTINGS: dict[str, InvenTreeSettingsKeyType] from common.setting.system import SYSTEM_SETTINGS
SETTINGS: dict[str, InvenTreeSettingsKeyType] = SYSTEM_SETTINGS
CHECK_SETTING_KEY = True CHECK_SETTING_KEY = True
@ -1282,9 +1284,6 @@ class InvenTreeSetting(BaseInvenTreeSetting):
The keys must be upper-case The keys must be upper-case
""" """
from common.setting.system import SYSTEM_SETTINGS
SETTINGS = SYSTEM_SETTINGS
typ = 'inventree' typ = 'inventree'
@ -1310,6 +1309,8 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
import common.setting.user import common.setting.user
SETTINGS = common.setting.user.USER_SETTINGS
CHECK_SETTING_KEY = True CHECK_SETTING_KEY = True
class Meta: class Meta:
@ -1321,8 +1322,6 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
models.UniqueConstraint(fields=['key', 'user'], name='unique key and user') models.UniqueConstraint(fields=['key', 'user'], name='unique key and user')
] ]
SETTINGS = common.setting.user.USER_SETTINGS
typ = 'user' typ = 'user'
extra_unique_fields = ['user'] extra_unique_fields = ['user']

View File

@ -44,6 +44,13 @@ def get_global_setting(key, backup_value=None, environment_key=None, **kwargs):
def set_global_setting(key, value, change_user=None, create=True, **kwargs): def set_global_setting(key, value, change_user=None, create=True, **kwargs):
"""Set the value of a global setting using the provided key.""" """Set the value of a global setting using the provided key."""
from common.models import InvenTreeSetting from common.models import InvenTreeSetting
from InvenTree.ready import canAppAccessDatabase
if not canAppAccessDatabase(allow_shell=True, allow_test=True):
logger.warning(
f'Cannot set global setting "{key}" - database is not accessible'
)
return False
kwargs['change_user'] = change_user kwargs['change_user'] = change_user
kwargs['create'] = create kwargs['create'] = create

View File

@ -68,7 +68,7 @@ class SampleValidatorPlugin(SettingsMixin, ValidationMixin, InvenTreePlugin):
if isinstance(instance, part.models.BomItem): if isinstance(instance, part.models.BomItem):
if self.get_setting('BOM_ITEM_INTEGER'): if self.get_setting('BOM_ITEM_INTEGER'):
if float(instance.quantity) != int(instance.quantity): if float(instance.quantity) != int(instance.quantity): # noqa: RUF069
self.raise_error({ self.raise_error({
'quantity': 'Bom item quantity must be an integer' 'quantity': 'Bom item quantity must be an integer'
}) })

View File

@ -10,24 +10,40 @@ def add_part_links(apps, schema_editor):
history_entries = [] history_entries = []
for tracking in StockItemTracking.objects.all(): N = StockItemTracking.objects.count()
if N > 0:
print(f"\nUpdating {N} StockItemTracking entries with part links...")
for tracking in StockItemTracking.objects.filter(part__isnull=True).select_related('item__part'):
item = tracking.item item = tracking.item
# No item link - skip
if item is None: if item is None:
continue continue
part = item.part part = item.part
# No part link - skip
if part is None: if part is None:
continue continue
# Already linked to the correct part - skip
if tracking.part == part:
continue
tracking.part = part tracking.part = part
history_entries.append(tracking) history_entries.append(tracking)
# Process in batches to avoid issues with very large datasets
if len(history_entries) >= 100:
StockItemTracking.objects.bulk_update(history_entries, ['part'])
history_entries = []
print(".", end='', flush=True)
if len(history_entries) > 0: if len(history_entries) > 0:
StockItemTracking.objects.bulk_update(history_entries, ['part']) StockItemTracking.objects.bulk_update(history_entries, ['part'])
print(f"\nUpdated {len(history_entries)} StockItemTracking entries with part links")
def remove_null_items(apps, schema_editor): def remove_null_items(apps, schema_editor):

View File

@ -962,7 +962,9 @@ class StockItemListTest(StockAPITestCase):
# Note: While the export is quick on pgsql, it is still quite slow on sqlite3 # Note: While the export is quick on pgsql, it is still quite slow on sqlite3
with self.export_data( with self.export_data(
self.list_url, max_query_count=50, max_query_time=9.0 self.list_url,
max_query_count=50,
max_query_time=12.0, # Test time increased due to worker variability
) as data_file: ) as data_file:
data = self.process_csv(data_file) data = self.process_csv(data_file)

View File

@ -36,6 +36,11 @@ export const queryClient = new QueryClient({
} }
}); });
export function setTraceId() { export function setTraceId() {
// check if we are in a secure context (https) - if not use of crypto is not allowed
if (!window.isSecureContext) {
return '';
}
const runID = crypto.randomUUID().replace(/-/g, ''); const runID = crypto.randomUUID().replace(/-/g, '');
const traceid = `00-${runID}-${frontendID}-01`; const traceid = `00-${runID}-${frontendID}-01`;
api.defaults.headers['traceparent'] = traceid; api.defaults.headers['traceparent'] = traceid;