Compare commits

...

8 Commits

Author SHA1 Message Date
github-actions[bot]
28726db86f Bug fix for receiving line item event (#9071) (#9072)
- Use StockItem ID correctly
- Provide line ID

(cherry picked from commit f27a84a7e5)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2025-02-13 14:46:55 +11:00
Oliver
eef1aad464 Update version.py (#9067)
Bump version number to 0.17.7
2025-02-12 17:14:45 +11:00
github-actions[bot]
3b6b41976f Fix for data import (#9060) (#9065)
- Prevent shadow overwrite of default_values dict
- Remove dead code

(cherry picked from commit 7049e84ac3)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2025-02-12 07:31:16 +11:00
Oliver
407ccb7bd2 [Backport] Update supported postgres-cli version to 15 (#9042)
* Update supported postgres-cli version to 15

* Update docs
2025-02-07 13:58:40 +11:00
Oliver
d7ed114e2c Adjust playwright testing (#9043)
* Adjust playwright testing

- Backporting critical playwright changes

* Fix for test

* Remove problematic test
2025-02-07 12:49:00 +11:00
Matthias Mair
c7a0265794 feat(backend): Improve error with missing manifest (#8957) (#9036)
* package tag results better

* Add docs for missing frontend

* better error indication
Fixes #8875

* fix test assertations

* fix test exception

* group setup admin stuff

* add operations supgourp

* add basic structure

* move error code

* fix link

* fix grammar issues

(cherry picked from commit bbeaf0e791)

# Conflicts:
#	docs/docs/faq.md

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2025-02-05 13:55:04 +11:00
Oliver
5bc56c826a Update version.py (#9019)
Bump version number

Co-authored-by: Matthias Mair <code@mjmair.com>
2025-02-05 12:52:56 +11:00
github-actions[bot]
1b42c00747 Enhance creation of default settings (#9028) (#9029)
- Remove cache requirement
- Replaces https://github.com/inventree/InvenTree/pull/9021

(cherry picked from commit 445fa45394)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2025-02-04 23:04:01 +11:00
15 changed files with 89 additions and 101 deletions

View File

@@ -70,7 +70,7 @@ RUN apk add --no-cache \
# Weasyprint requirements : https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#alpine-3-12
py3-pip py3-pillow py3-cffi py3-brotli pango poppler-utils openldap \
# Postgres client
postgresql13-client \
postgresql15-client \
# MySQL / MariaDB client
mariadb-client mariadb-connector-c \
&& \

View File

@@ -8,5 +8,5 @@ apk add gcc g++ musl-dev openssl-dev libffi-dev cargo python3-dev openldap-dev \
jpeg-dev openjpeg-dev libwebp-dev zlib-dev \
sqlite sqlite-dev \
mariadb-connector-c-dev mariadb-client mariadb-dev \
postgresql13-dev postgresql-libs \
postgresql15-dev postgresql-libs \
$@

View File

@@ -26,7 +26,12 @@ Refer to the [invoke guide](./start/invoke.md#cant-find-any-collection-named-tas
If the installed version of invoke is too old, users may see error messages during the installation procedure. Refer to the [invoke guide](./start/invoke.md#minimum-version) for more information.
### No module named 'django'
### INVE-E1 - No frontend included
Make sure you are running a stable or production release of InvenTree. The frontend panel is not included in development releases.
More Information: [Error Codes - INVE-E1](./settings/error_codes.md#inve-e1)
### No module named <xxx>
During the install or update process, you may be presented with an error like:

View File

@@ -0,0 +1,26 @@
## Error Codes
InvenTree is starting to use error codes to help identify and diagnose issues. These are increasingly being added to the codebase. Error messages missing an error code should be reported on GitHub.
Error codes are prefixed with `INVE-` and are followed by a letter to indicate the type of error and a number to indicate the specific error. Once a code is used it might not be reassigned to a different error, it can be marked as stricken from the list.
### INVE-E (InvenTree Error)
Errors - These are critical errors which should be addressed as soon as possible.
#### INVE-E1
**No frontend included - Backend/web**
Only stable / production releases of InvenTree include the frontend panel. This is both a measure of resource-saving and attack surface reduction. If you want to use the frontend panel, you can either:″
- use a docker image that is version-tagged or the stable version
- use a package version that is from the stable or version stream
- install node and yarn on the server to build the frontend with the [invoke](../start/invoke.md) task `int.frontend-build`
Raise an issue if none of these options work.
### INVE-W (InvenTree Warning)
Warnings - These are non-critical errors which should be addressed when possible.
### INVE-I (InvenTree Information)
Information — These are not errors but information messages. They might point out potential issues or just provide information.
### INVE-M (InvenTree Miscellaneous)
Miscellaneous — These are information messages that might be used to mark debug information or other messages helpful for the InvenTree team to understand behaviour.

View File

@@ -46,7 +46,7 @@ InvenTree run-time configuration options described in the [configuration documen
As docker containers are ephemeral, any *persistent* data must be stored in an external [volume](https://docs.docker.com/storage/volumes/). To simplify installation / implementation, all external data are stored in a single volume, arranged as follows:
#### Media FIles
#### Media Files
Uploaded media files are stored in the `media/` subdirectory of the external data volume.
@@ -112,6 +112,13 @@ InvenTree stores any persistent data (e.g. uploaded media files, database data,
!!! info "Data Directory"
Make sure you change the path to the local directory where you want persistent data to be stored.
#### Database Connection
The `inventree-db` container is configured to use the `postgres:13` docker image. The `inventree-server` and `inventree-worker` containers support connection to a postgres database up to (and including) version 15.
!!! warning "Newer Postgres Versions"
The InvenTree docker image supports connection to a postgres database up to version 15. Connecting to a database using a newer version of postgres is not possible.
## Common Issues
### Volume Mapping

View File

@@ -153,15 +153,18 @@ nav:
- User Settings: settings/user.md
- Reference Patterns: settings/reference.md
- Admin Interface: settings/admin.md
- User Permissions: settings/permissions.md
- Single Sign on: settings/SSO.md
- Multi Factor Authentication: settings/MFA.md
- Setup:
- User Permissions: settings/permissions.md
- Single Sign on: settings/SSO.md
- Multi Factor Authentication: settings/MFA.md
- Email: settings/email.md
- Currency Support: settings/currency.md
- Export Data: settings/export.md
- Import Data: settings/import.md
- Error Logs: settings/logs.md
- Email: settings/email.md
- Background Tasks: settings/tasks.md
- Currency Support: settings/currency.md
- Operations:
- Background Tasks: settings/tasks.md
- Error Logs: settings/logs.md
- Error Codes: settings/error_codes.md
- App:
- InvenTree App: app/app.md
- Connect: app/connect.md

View File

@@ -18,7 +18,7 @@ from django.conf import settings
from .api_version import INVENTREE_API_TEXT, INVENTREE_API_VERSION
# InvenTree software version
INVENTREE_SW_VERSION = '0.17.5'
INVENTREE_SW_VERSION = '0.17.7'
logger = logging.getLogger('inventree')

View File

@@ -165,15 +165,6 @@ class BaseInvenTreeSetting(models.Model):
If a particular setting is not present, create it with the default value
"""
cache_key = f'BUILD_DEFAULT_VALUES:{cls.__name__!s}'
try:
if InvenTree.helpers.str2bool(cache.get(cache_key, False)):
# Already built default values
return
except Exception:
pass
try:
existing_keys = cls.objects.filter(**kwargs).values_list('key', flat=True)
settings_keys = cls.SETTINGS.keys()
@@ -194,11 +185,6 @@ class BaseInvenTreeSetting(models.Model):
'Failed to build default values for %s (%s)', str(cls), str(type(exc))
)
try:
cache.set(cache_key, True, timeout=3600)
except Exception:
pass
def _call_settings_function(self, reference: str, args, kwargs):
"""Call a function associated with a particular setting.

View File

@@ -111,17 +111,13 @@ class DataImportSession(models.Model):
)
@property
def field_mapping(self):
def field_mapping(self) -> dict:
"""Construct a dict of field mappings for this import session.
Returns: A dict of field: column mappings
Returns:
A dict of field -> column mappings
"""
mapping = {}
for i in self.column_mappings.all():
mapping[i.field] = i.column
return mapping
return {mapping.field: mapping.column for mapping in self.column_mappings.all()}
@property
def model_class(self):
@@ -138,7 +134,7 @@ class DataImportSession(models.Model):
return supported_models().get(self.model_type, None)
def extract_columns(self):
def extract_columns(self) -> None:
"""Run initial column extraction and mapping.
This method is called when the import session is first created.
@@ -204,7 +200,7 @@ class DataImportSession(models.Model):
self.status = DataImportStatusCode.MAPPING.value
self.save()
def accept_mapping(self):
def accept_mapping(self) -> None:
"""Accept current mapping configuration.
- Validate that the current column mapping is correct
@@ -243,7 +239,7 @@ class DataImportSession(models.Model):
# No errors, so trigger the data import process
self.trigger_data_import()
def trigger_data_import(self):
def trigger_data_import(self) -> None:
"""Trigger the data import process for this session.
Offloads the task to the background worker process.
@@ -256,7 +252,7 @@ class DataImportSession(models.Model):
offload_task(importer.tasks.import_data, self.pk)
def import_data(self):
def import_data(self) -> None:
"""Perform the data import process for this session."""
# Clear any existing data rows
self.rows.all().delete()
@@ -316,12 +312,12 @@ class DataImportSession(models.Model):
return True
@property
def row_count(self):
def row_count(self) -> int:
"""Return the number of rows in the import session."""
return self.rows.count()
@property
def completed_row_count(self):
def completed_row_count(self) -> int:
"""Return the number of completed rows for this session."""
return self.rows.filter(complete=True).count()
@@ -349,7 +345,7 @@ class DataImportSession(models.Model):
self._available_fields = fields
return fields
def required_fields(self):
def required_fields(self) -> dict:
"""Returns information on which fields are *required* for import."""
fields = self.available_fields()
@@ -591,7 +587,7 @@ class DataImportRow(models.Model):
value = value or None
# Use the default value, if provided
if value in [None, ''] and field in default_values:
if value is None and field in default_values:
value = default_values[field]
data[field] = value
@@ -607,7 +603,9 @@ class DataImportRow(models.Model):
- If available, we use the "default" values provided by the import session
- If available, we use the "override" values provided by the import session
"""
data = self.default_values
data = {}
data.update(self.default_values)
if self.data:
data.update(self.data)

View File

@@ -81,23 +81,6 @@ def extract_column_names(data_file) -> list:
return headers
def extract_rows(data_file) -> list:
"""Extract rows from the data file.
Each returned row is a dictionary of column_name: value pairs.
"""
data = load_data_file(data_file)
headers = data.headers
rows = []
for row in data:
rows.append(dict(zip(headers, row)))
return rows
def get_field_label(field) -> str:
"""Return the label for a field in a serializer class.

View File

@@ -887,7 +887,10 @@ class PurchaseOrder(TotalPriceMixin, Order):
)
trigger_event(
PurchaseOrderEvents.ITEM_RECEIVED, order_id=self.pk, item_id=self.pk
PurchaseOrderEvents.ITEM_RECEIVED,
order_id=self.pk,
item_id=item.pk,
line_id=line.pk,
)
# Update the number of parts received against the particular line item

View File

@@ -1,5 +1,6 @@
{% load spa_helper %}
{% load inventree_extras %}
{% spa_bundle as bundle %}
<!DOCTYPE html>
<html lang="en">
@@ -12,8 +13,17 @@
<body>
<div id="root"></div>
{% spa_settings %}
{% spa_bundle %}
<div id="spa_settings">{% spa_settings %}</div>
{% if bundle == "NOT_FOUND" %}
<div id="spa_bundle_error">
<div>
<h1>INVE-E1 - No frontend included</h1>
<p>The frontend bundle could not be found. Please check that your deployment method includes the bundle or check the <a href="https://docs.inventree.org/en/stable/faq/">FAQ</a>.<br/>
<span>Install method: <code>{% inventree_installer %}</code></span></p>
</div>
{% else %}
<div id="spa_bundle">{{ bundle }}</div>
{% endif %}
</body>
</html>

View File

@@ -37,13 +37,13 @@ def spa_bundle(manifest_path: Union[str, Path] = '', app: str = 'web'):
# Final check - fail if manifest file not found
if not manifest.exists():
logger.error('Manifest file not found')
return
return 'NOT_FOUND'
try:
manifest_data = json.load(manifest.open())
except (TypeError, json.decoder.JSONDecodeError):
logger.exception('Failed to parse manifest file')
return
return ''
return_string = ''
# JS (based on index.html file as entrypoint)

View File

@@ -26,9 +26,8 @@ class TemplateTagTest(InvenTreeTestCase):
def test_spa_bundle(self):
"""Test the 'spa_bundle' template tag."""
resp = spa_helper.spa_bundle()
if not resp:
if resp == 'NOT_FOUND':
# No Vite, no test
# TODO: Add a test for the non-Vite case (docker)
return # pragma: no cover
shipped_js = resp.split('<script type="module" src="')[1:]
@@ -41,7 +40,7 @@ class TemplateTagTest(InvenTreeTestCase):
manifest_file.with_suffix('.json.bak')
) # Rename
resp = spa_helper.spa_bundle()
self.assertIsNone(resp)
self.assertEqual(resp, 'NOT_FOUND')
# Try with differing name
resp = spa_helper.spa_bundle(new_name)
@@ -50,7 +49,7 @@ class TemplateTagTest(InvenTreeTestCase):
# Broken manifest file
manifest_file.write_text('broken')
resp = spa_helper.spa_bundle(manifest_file)
self.assertIsNone(resp)
self.assertEqual(resp, '')
new_name.rename(manifest_file.with_suffix('.json')) # Name back

View File

@@ -149,35 +149,3 @@ test('Purchase Orders', async ({ page }) => {
await page.getByRole('button', { name: 'Issue Order' }).waitFor();
});
test('Purchase Orders - Barcodes', async ({ page }) => {
await doQuickLogin(page);
await page.goto(`${baseUrl}/purchasing/purchase-order/13/detail`);
await page.getByRole('button', { name: 'Issue Order' }).waitFor();
// Display QR code
await page.getByLabel('action-menu-barcode-actions').click();
await page.getByLabel('action-menu-barcode-actions-view').click();
await page.getByRole('img', { name: 'QR Code' }).waitFor();
await page.getByRole('banner').getByRole('button').click();
// Link to barcode
await page.getByLabel('action-menu-barcode-actions').click();
await page.getByLabel('action-menu-barcode-actions-link-barcode').click();
await page.getByRole('heading', { name: 'Link Barcode' }).waitFor();
await page
.getByPlaceholder('Scan barcode data here using')
.fill('1234567890');
await page.getByRole('button', { name: 'Link' }).click();
await page.getByRole('button', { name: 'Issue Order' }).waitFor();
// Unlink barcode
await page.getByLabel('action-menu-barcode-actions').click();
await page.getByLabel('action-menu-barcode-actions-unlink-barcode').click();
await page.getByRole('heading', { name: 'Unlink Barcode' }).waitFor();
await page.getByText('This will remove the link to').waitFor();
await page.getByRole('button', { name: 'Unlink Barcode' }).click();
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'Issue Order' }).waitFor();
});