Compare commits

...

16 Commits

Author SHA1 Message Date
Oliver 12da3b01fc
Merge commit from fork (#11400)
- Change one renderer from jinja to django
- Move the other to a sandboxed environment
2026-02-22 23:25:31 +11:00
Oliver 2df9eb80ca
[bug] Fix custom logo and splash (#11391) (#11399)
* Add custom logo and splash to playwright fixtures

* Render custom logo in frontend

* Add playwright tests for customization settings

* Separate playwright run for customization

* Update ci file

* Update playwright config file

* Do not call get_custom_file from withing settings.py

- django app not fully initialized yet
- can cause loops

* Disable default tests (for now)

* Re-enable normal tests

* Update qc checks

* Order of operations?

* Debug output

* Use env

* Add more debug info

* More debug

* Further debug

* Add collectstatic check

* Run normal tests too

* Remove debug prints
2026-02-22 22:46:25 +11:00
github-actions[bot] 44387f3bb4
[bug] Check for null plugin config (#11394) (#11395)
* Check for null plugin config

* Handle potential errors

(cherry picked from commit 2e675ee87a)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2026-02-22 12:56:57 +11:00
Oliver ed8331e26a
Bump InvenTree software version to 1.2.3 (#11382) 2026-02-19 22:57:39 +11:00
Oliver 228577c871
[UI] Bug fix for stock column ordering (#11376) (#11380)
- Cannot have a blank accessor
2026-02-19 22:09:58 +11:00
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
31 changed files with 279 additions and 59 deletions

View File

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

View File

@ -23,6 +23,8 @@ env:
INVENTREE_SITE_URL: http://localhost:8000
INVENTREE_DEBUG: true
use_performance: false
permissions:
contents: read
@ -78,7 +80,7 @@ jobs:
- name: Which runner to use?
id: runner-perf
# 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:
name: Style [pre-commit]
@ -692,7 +694,13 @@ jobs:
cd src/frontend && npx playwright install --with-deps
- name: Run Playwright tests
id: tests
run: cd src/frontend && npx nyc playwright test
run: |
cd src/frontend
cp ./tests/fixtures/playwright_custom_logo.png ../backend/InvenTree/InvenTree/static/img/playwright_custom_logo.png
cp ./tests/fixtures/playwright_custom_splash.png ../backend/InvenTree/InvenTree/static/img/playwright_custom_splash.png
invoke static
env INVENTREE_CUSTOM_SPLASH="img/playwright_custom_splash.png" INVENTREE_CUSTOM_LOGO="img/playwright_custom_logo.png" npx nyc playwright test --project=customization
npx nyc playwright test --project=chromium --project=firefox
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # pin@v6.0.0
if: ${{ !cancelled() && steps.tests.outcome == 'failure' }}
with:

View File

@ -85,6 +85,11 @@ jobs:
asset_name: frontend-build.zip
tag: ${{ github.ref }}
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
uses: svenstaro/upload-release-action@6b7fa9f267e90b50a19fef07b3596790bb941741 # pin@2.11.3
with:
@ -136,3 +141,98 @@ jobs:
asset_name: docs-html.zip
tag: ${{ github.ref }}
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:
- INVENTREE_DB_ENGINE=sqlite3
- INVENTREE_DB_NAME=database.sqlite3
- INVENTREE_PLUGINS_ENABLED
- INVENTREE_PLUGINS_ENABLED=true
- INVENTREE_MEDIA_ROOT=/opt/inventree/media
- INVENTREE_STATIC_ROOT=/opt/inventree/static
- INVENTREE_BACKUP_DIR=/opt/inventree/backup

View File

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

View File

@ -1,15 +1,15 @@
# 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/),
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
- [#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.
### 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)
- 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)
- Allow input controls within generated PDF reports in [#10969](https://github.com/inventree/InvenTree/pull/10969)
### Changed
-
- Improved stocktake functionality in [#11257](https://github.com/inventree/InvenTree/pull/11257)
### Removed
- 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
# - 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
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
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"
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"
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:
@ -154,13 +154,13 @@ docker compose down
### 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"
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"
@ -168,7 +168,7 @@ rm -rf ./path/to/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

View File

@ -1,2 +1,5 @@
# Files generated during unit testing
_testfolder/
# Playwright files for CI
InvenTree/static/img/playwright*.png

View File

@ -331,6 +331,11 @@ class InvenTreeConfig(AppConfig):
if MIGRATIONS_CHECK_DONE:
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():
# Detect if this an empty database - if so, start with a fresh migration
if (

View File

@ -250,7 +250,6 @@ def getBlankThumbnail():
def getLogoImage(as_file=False, custom=True):
"""Return the InvenTree logo image, or a custom logo if available."""
"""Return the path to the logo-file."""
if custom and settings.CUSTOM_LOGO:
static_storage = StaticFilesStorage()

View File

@ -26,12 +26,7 @@ from corsheaders.defaults import default_headers as default_cors_headers
import InvenTree.backup
from InvenTree.cache import get_cache_config, is_global_cache_enabled
from InvenTree.config import (
get_boolean_setting,
get_custom_file,
get_oidc_private_key,
get_setting,
)
from InvenTree.config import get_boolean_setting, get_oidc_private_key, get_setting
from InvenTree.ready import isInMainThread
from InvenTree.sentry import default_sentry_dsn, init_sentry
from InvenTree.version import checkMinPythonVersion, inventreeCommitHash
@ -1453,12 +1448,9 @@ if len(GLOBAL_SETTINGS_OVERRIDES) > 0:
logger.debug('- Override value for %s = ********', key)
# User interface customization values
CUSTOM_LOGO = get_custom_file(
'INVENTREE_CUSTOM_LOGO', 'customize.logo', 'custom logo', lookup_media=True
)
CUSTOM_SPLASH = get_custom_file(
'INVENTREE_CUSTOM_SPLASH', 'customize.splash', 'custom splash'
)
CUSTOM_LOGO = get_setting('INVENTREE_CUSTOM_LOGO', 'customize.logo', typecast=str)
CUSTOM_SPLASH = get_setting('INVENTREE_CUSTOM_SPLASH', 'customize.splash', typecast=str)
CUSTOMIZE = get_setting(
'INVENTREE_CUSTOMIZE', 'customize', default_value=None, typecast=dict

View File

@ -587,6 +587,12 @@ def update_exchange_rates(force: bool = False):
Arguments:
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:
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
# InvenTree software version
INVENTREE_SW_VERSION = '1.2.0 dev'
INVENTREE_SW_VERSION = '1.2.3'
# Minimum supported Python version
MIN_PYTHON_VERSION = (3, 11)

View File

@ -19,6 +19,11 @@ logger = structlog.get_logger('inventree')
def currency_code_default(create: bool = True):
"""Returns the default currency code (or USD if not specified)."""
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 = ''

View File

@ -1216,7 +1216,9 @@ class InvenTreeSetting(BaseInvenTreeSetting):
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
@ -1282,9 +1284,6 @@ class InvenTreeSetting(BaseInvenTreeSetting):
The keys must be upper-case
"""
from common.setting.system import SYSTEM_SETTINGS
SETTINGS = SYSTEM_SETTINGS
typ = 'inventree'
@ -1310,6 +1309,8 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
import common.setting.user
SETTINGS = common.setting.user.USER_SETTINGS
CHECK_SETTING_KEY = True
class Meta:
@ -1321,8 +1322,6 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
models.UniqueConstraint(fields=['key', 'user'], name='unique key and user')
]
SETTINGS = common.setting.user.USER_SETTINGS
typ = 'user'
extra_unique_fields = ['user']

View File

@ -11,7 +11,7 @@ from django.core.exceptions import FieldDoesNotExist, ValidationError
from django.core.validators import MaxValueValidator, MinValueValidator, URLValidator
from django.utils.translation import gettext_lazy as _
from jinja2 import Template
from jinja2.sandbox import SandboxedEnvironment
import build.validators
import common.currency
@ -52,7 +52,7 @@ def validate_part_name_format(value):
p = Part(name='test part', description='some test part')
try:
Template(value).render({'part': p})
SandboxedEnvironment().from_string(value).render({'part': p})
except Exception as exc:
raise ValidationError({'value': str(exc)})

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):
"""Set the value of a global setting using the provided key."""
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['create'] = create

View File

@ -473,12 +473,19 @@ class PluginsRegistry:
# Ensure that each loaded plugin has a valid configuration object in the database
for plugin in self.plugins.values():
config = self.get_plugin_config(plugin.slug)
if config := self.get_plugin_config(plugin.slug):
# Ensure mandatory plugins are marked as active
if config.is_mandatory() and not config.active:
config.active = True
# Ensure mandatory plugins are marked as active
if config.is_mandatory() and not config.active:
config.active = True
config.save(no_reload=True)
try:
config.save(no_reload=True)
except (OperationalError, ProgrammingError):
# Database is not ready, cannot save config
logger.warning(
"Database not ready - cannot set mandatory flag for plugin '%s'",
plugin.slug,
)
except Exception as e:
logger.exception('Unexpected error during plugin reload: %s', e)

View File

@ -68,7 +68,7 @@ class SampleValidatorPlugin(SettingsMixin, ValidationMixin, InvenTreePlugin):
if isinstance(instance, part.models.BomItem):
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({
'quantity': 'Bom item quantity must be an integer'
})

View File

@ -4,8 +4,7 @@ from inspect import signature
from typing import Optional
from django.core.exceptions import ValidationError
from jinja2 import Template
from django.template import Context, Template
import common.models
import InvenTree.exceptions
@ -76,7 +75,7 @@ def generate_batch_code(**kwargs):
'STOCK_BATCH_CODE_TEMPLATE', ''
)
return Template(batch_template).render(context)
return Template(batch_template).render(Context(context))
def generate_serial_number(part=None, quantity=1, **kwargs) -> Optional[str]:

View File

@ -10,24 +10,40 @@ def add_part_links(apps, schema_editor):
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
# No item link - skip
if item is None:
continue
part = item.part
# No part link - skip
if part is None:
continue
# Already linked to the correct part - skip
if tracking.part == part:
continue
tracking.part = part
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:
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):

View File

@ -962,7 +962,9 @@ class StockItemListTest(StockAPITestCase):
# Note: While the export is quick on pgsql, it is still quite slow on sqlite3
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:
data = self.process_csv(data_file)

View File

@ -48,13 +48,22 @@ export default defineConfig({
name: 'chromium',
use: {
...devices['Desktop Chrome']
}
},
testIgnore: /customization/ // Ignore all tests in the "customization" folder for this project
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox']
}
},
testIgnore: /customization/ // Ignore all tests in the "customization" folder for this project
},
{
name: 'customization',
use: {
...devices['Desktop Firefox']
},
testIgnore: /pui_.*\.spec\.ts/ // Ignore all "pui_*.spec.ts" tests for this project
}
],

View File

@ -36,6 +36,11 @@ export const queryClient = new QueryClient({
}
});
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 traceid = `00-${runID}-${frontendID}-01`;
api.defaults.headers['traceparent'] = traceid;

View File

@ -1,8 +1,10 @@
import { t } from '@lingui/core/macro';
import { ActionIcon } from '@mantine/core';
import { forwardRef } from 'react';
import { type ReactNode, forwardRef } from 'react';
import { NavLink } from 'react-router-dom';
import { useShallow } from 'zustand/react/shallow';
import { useServerApiState } from '../../states/ServerApiState';
import InvenTreeIcon from './inventree.svg';
export const InvenTreeLogoHomeButton = forwardRef<HTMLDivElement>(
@ -19,6 +21,21 @@ export const InvenTreeLogoHomeButton = forwardRef<HTMLDivElement>(
}
);
export const InvenTreeLogo = () => {
/*
* Render the InvenTree logo
* - Uses the custom logo if one is defined on the server
* - Otherwise, uses the default logo
*/
export function InvenTreeLogo(): ReactNode {
const [server] = useServerApiState(
useShallow((state) => [state.server, state.fetchServerApiState])
);
if (server.server && server.customize?.logo) {
return (
<img src={server.customize.logo} alt={t`InvenTree Logo`} height={28} />
);
}
return <img src={InvenTreeIcon} alt={t`InvenTree Logo`} height={28} />;
};
}

View File

@ -114,9 +114,10 @@ export type StockColumnProps = TableColumnProps & {
// Render a StockItem instance within a table
export function StockColumn(props: StockColumnProps): TableColumn {
return {
accessor: props.accessor ?? 'stock_item',
title: t`Stock Item`,
...props,
ordering: props.ordering || 'stock',
accessor: props.accessor || 'stock',
render: (record: any) => {
const stock_item =
resolveItem(record, props.accessor ?? 'stock_item_detail') ?? {};

View File

@ -486,6 +486,10 @@ export function InvenTreeTable<T extends Record<string, any>>({
tableState.setPage(1);
setSortStatus(status);
if (!status.columnAccessor) {
console.error('Invalid column accessor provided for table sorting');
}
setTableSorting(cacheKey)(status);
},
[cacheKey]

View File

@ -0,0 +1,33 @@
import test, { expect } from '@playwright/test';
import { navigate } from '../helpers';
import { doLogin } from '../login';
/**
* Tests for user interface customization functionality.
*
* Note: The correct environment variables must be set for these tests to work correctly. See "playwright.config.ts" for details.
* These tests are designed to run in CI environments where specific environment variables are set to enable custom logos and splash screens. The tests verify that these customizations are correctly applied in the user interface.
*/
test('Customization - Splash', async ({ page }) => {
await navigate(page, '/');
await page.waitForLoadState('networkidle');
// Check for the custom splash screen
await expect(
page.locator('[style*="playwright_custom_splash.png"]')
).toBeVisible();
});
test('Customization - Logo', async ({ page }) => {
await doLogin(page, {
username: 'noaccess',
password: 'youshallnotpass'
});
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2500);
return;
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB