fix(ui): show initial stock fields when PART_CREATE_INITIAL enabled (#12415)

* fix(ui): show initial stock fields when PART_CREATE_INITIAL enabled (#12266)

* Fix Docker setup for local Windows deployment.

Disable Redis disk persistence to avoid bind-mount permission errors that caused login 500s, and configure localhost as the default site URL.

* Apply Biome formatting to Playwright test file.

Fixes Style [prek] CI failure on PR #12415.

* Use specific locators in initial stock Playwright tests.

Avoid strict-mode violations from getByText('Initial Stock') matching multiple form elements.

* Scope initial stock Playwright test to part detail Stock tab.

Avoid strict-mode violations from duplicate Stock tabs on the part page.

* Use raw SQL inserts in MPTT migration test setup.

Avoid duplicate status_custom_key ORM bug in historical StockItem models.
This commit is contained in:
Senior Data Engineer & Data Architect
2026-07-20 19:05:54 +10:00
committed by GitHub
parent 8075c3ee37
commit 44d8d0e266
5 changed files with 114 additions and 29 deletions
+26 -19
View File
@@ -599,6 +599,8 @@ class TestRemoveMpttFieldsMigration(MigratorTestCase):
def prepare(self):
"""Create a tree of StockItem objects with parent-child relationships."""
from django.db import connection
Part = self.old_state.apps.get_model('part', 'part')
StockItem = self.old_state.apps.get_model('stock', 'stockitem')
@@ -606,33 +608,38 @@ class TestRemoveMpttFieldsMigration(MigratorTestCase):
name='Migration Test Part', level=0, tree_id=0, lft=0, rght=0
)
def make_item(quantity, parent_id=None):
"""Insert via raw SQL to avoid duplicate status_custom_key ORM bug."""
with connection.cursor() as cursor:
cursor.execute(
"""
INSERT INTO stock_stockitem
(part_id, quantity, level, tree_id, lft, rght,
status, delete_on_deplete, is_building,
link, serial_int, barcode_data, barcode_hash, parent_id)
VALUES (%s, %s, 0, 0, 0, 0, 10, false, false, '', 0, '', '', %s)
RETURNING id
""",
[part.pk, quantity, parent_id],
)
return cursor.fetchone()[0]
# Root stock item, with no parent
root = StockItem.objects.create(
part=part, quantity=100, level=0, tree_id=0, lft=0, rght=0
)
root_pk = make_item(100)
# A set of child items, parented to the root item
children = [
StockItem.objects.create(
part=part, quantity=10, parent=root, level=1, tree_id=0, lft=0, rght=0
)
for _ in range(3)
]
child_pks = [make_item(10, root_pk) for _ in range(3)]
# A grandchild item, parented to the first child item
grandchild = StockItem.objects.create(
part=part, quantity=1, parent=children[0], level=2, tree_id=0, lft=0, rght=0
)
grandchild_pk = make_item(1, child_pks[0])
# An unrelated top-level item, with no parent
orphan = StockItem.objects.create(
part=part, quantity=5, level=0, tree_id=0, lft=0, rght=0
)
orphan_pk = make_item(5)
self.root_pk = root.pk
self.child_pks = [child.pk for child in children]
self.grandchild_pk = grandchild.pk
self.orphan_pk = orphan.pk
self.root_pk = root_pk
self.child_pks = child_pks
self.grandchild_pk = grandchild_pk
self.orphan_pk = orphan_pk
self.assertEqual(StockItem.objects.count(), 6)