Skip to content

[pull] master from inventree:master - #147

Merged
pull[bot] merged 3 commits into
Latitudes-Dev:masterfrom
inventree:master
Apr 26, 2026
Merged

pull[bot] merged 3 commits into
Latitudes-Dev:masterfrom
inventree:master

Conversation

@pull

@pull pull Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

Greptile Summary

This PR syncs upstream InvenTree changes across three areas: a backend fix deduplicating category parameter templates during part creation, a frontend OrderPartsWizard enhancement tracking raw vs. pack-adjusted quantities, and a UI cleanup that hides the Details tab (and its top-level placeholder text) when browsing the root category or stock location.

  • OrderPartsWizard: quantity_raw is only initialised once in selectQuantity (guarded by === undefined), so if a user manually edits the quantity after a supplier part has been selected, the change is not reflected in quantity_raw. A subsequent supplier-part switch re-derives quantity from the stale quantity_raw, silently discarding the user's edit.
  • The same callback uses a falsy check (!quantity_raw) rather than a nullish check, which would incorrectly overwrite a legitimate quantity_raw = 0.

Confidence Score: 4/5

Safe to merge with minor quantity-tracking edge cases in the OrderPartsWizard.

No P0/P1 issues found. Two P2 findings in OrderPartsWizard around quantity_raw update logic; all other changes are clean refactors with matching test updates.

src/frontend/src/components/wizards/OrderPartsWizard.tsx — quantity_raw update logic needs review.

Important Files Changed

Filename Overview
src/backend/InvenTree/part/models.py Adds deduplication of parameter templates when copying from category hierarchy; removes the now-redundant empty-list guard before bulk_create (safe in Django).
src/frontend/src/components/wizards/OrderPartsWizard.tsx Introduces quantity_raw to track pre-pack-size quantities; has a subtle bug where manually editing quantity after supplier selection doesn't update quantity_raw, causing stale recalculations on supplier change.
src/frontend/src/pages/part/CategoryDetail.tsx Removes 'Top level part category' text and hides the Details panel tab when no category pk is present; also removes unused Text import.
src/frontend/src/pages/stock/LocationDetail.tsx Removes top-level location text, hides Details tab when no location pk is present, and suppresses location action buttons for virtual top-level location.
src/frontend/tests/pages/pui_stock.spec.ts Updates tests to match removal of top-level Details tab navigation; randomises sub-location names for test isolation.
src/frontend/tests/pui_permissions.spec.ts Removes navigation to Category Details tab for the top-level category, consistent with the CategoryDetail.tsx change.

Sequence Diagram

sequenceDiagram
    participant U as User
    participant W as OrderPartsWizard
    participant R as PartOrderRecord

    U->>W: Open wizard (parts initialised)
    W->>R: quantity=to_order, quantity_raw=undefined

    U->>W: selectQuantity(partId, qty)
    W->>R: quantity = qty
    Note over R: quantity_raw set only if undefined

    U->>W: selectSupplierPart(partId, supplierPart)
    W->>R: If quantity_raw falsy: quantity_raw = quantity
    W->>R: If pack_quantity_native present: quantity = quantity_raw / pack_quantity_native

    U->>W: selectQuantity(partId, newQty) [manual edit]
    W->>R: quantity = newQty
    Note over R: quantity_raw NOT updated (already set)

    U->>W: selectSupplierPart(partId, newSupplierPart)
    W->>R: quantity = quantity_raw / new_pack_quantity_native
    Note over R: Manual quantity edit lost — recalculates from stale quantity_raw
Loading

Comments Outside Diff (2)

  1. src/frontend/src/components/wizards/OrderPartsWizard.tsx, line 515-517 (link)

    quantity_raw not updated on manual quantity change

    After a supplier part is selected, quantity is divided by pack_quantity_native and quantity_raw is frozen. If the user then manually edits quantity in the UI, selectQuantity is called — but since quantity_raw !== undefined, the guard on line 495 prevents it from updating. When the user subsequently switches supplier parts, quantity is recalculated from the stale quantity_raw instead of the manually-entered value, silently discarding the user's edit.

    Consider also updating quantity_raw inside selectQuantity when a supplier part is already selected, or resetting it proportionally based on the new pack count.

  2. src/frontend/src/components/wizards/OrderPartsWizard.tsx, line 515 (link)

    Falsy check misses quantity_raw = 0

    The condition !records[index].quantity_raw treats 0 as falsy, so if quantity_raw was explicitly set to 0 (valid for a part with no required stock), this branch will overwrite it with the current quantity. Using == null would be safer.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/frontend/src/components/wizards/OrderPartsWizard.tsx
Line: 515-517

Comment:
**`quantity_raw` not updated on manual quantity change**

After a supplier part is selected, `quantity` is divided by `pack_quantity_native` and `quantity_raw` is frozen. If the user then manually edits `quantity` in the UI, `selectQuantity` is called — but since `quantity_raw !== undefined`, the guard on line 495 prevents it from updating. When the user subsequently switches supplier parts, `quantity` is recalculated from the stale `quantity_raw` instead of the manually-entered value, silently discarding the user's edit.

Consider also updating `quantity_raw` inside `selectQuantity` when a supplier part is already selected, or resetting it proportionally based on the new pack count.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/frontend/src/components/wizards/OrderPartsWizard.tsx
Line: 515

Comment:
**Falsy check misses `quantity_raw = 0`**

The condition `!records[index].quantity_raw` treats `0` as falsy, so if `quantity_raw` was explicitly set to `0` (valid for a part with no required stock), this branch will overwrite it with the current `quantity`. Using `== null` would be safer.

```suggestion
          if (records[index].quantity_raw == null && !!records[index].quantity) {
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Adjust order quantity based on pack size..." | Re-trigger Greptile

SchrodingersGat and others added 3 commits April 26, 2026 07:16
* Hide "top level stock location" panel

Co-authored-by: Copilot <copilot@github.com>

* Hide "top level part category"

Co-authored-by: Copilot <copilot@github.com>

* Adjust playwright tests

* Improve robustness of test

Co-authored-by: Copilot <copilot@github.com>

---------

Co-authored-by: Copilot <copilot@github.com>
- Prevent duplicate parameters
- Closes #11798

Co-authored-by: Copilot <copilot@github.com>
- Closes #10946

Co-authored-by: Copilot <copilot@github.com>
@pull pull Bot locked and limited conversation to collaborators Apr 26, 2026
@pull pull Bot added the ⤵️ pull label Apr 26, 2026
@pull
pull Bot merged commit f9cda95 into Latitudes-Dev:master Apr 26, 2026
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant