From 246108e732f50a49b8abaed24b106cbb74df0b3e Mon Sep 17 00:00:00 2001 From: JustusRijke <53965859+JustusRijke@users.noreply.github.com> Date: Tue, 24 Feb 2026 02:58:01 +0100 Subject: [PATCH] Fix auto pricing overwriting manual purchase price #10846 (#11411) * Fix auto pricing overwriting manual purchase price #10846 * Added entry to api_version.py --------- Co-authored-by: Oliver --- src/backend/InvenTree/InvenTree/api_version.py | 7 +++++-- src/backend/InvenTree/order/serializers.py | 2 +- src/frontend/src/forms/PurchaseOrderForms.tsx | 12 ++---------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index 493f4ae5db..4d4b72abd2 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -1,13 +1,16 @@ """InvenTree API version information.""" # InvenTree API version -INVENTREE_API_VERSION = 458 +INVENTREE_API_VERSION = 459 """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" INVENTREE_API_TEXT = """ +v459 -> 2026-02-23 : https://github.com/inventree/InvenTree/pull/11411 + - Changed PurchaseOrderLine "auto_pricing" default value from true to false + v458 -> 2026-02-22 : https://github.com/inventree/InvenTree/pull/11401 - - siwtches token refresh endpoint to use POST instead of GET (upstream allauth change) + - Switches token refresh endpoint to use POST instead of GET (upstream allauth change) v457 -> 2026-02-11 : https://github.com/inventree/InvenTree/pull/10887 - Extend the "auto allocate" wizard API to include tracked items diff --git a/src/backend/InvenTree/order/serializers.py b/src/backend/InvenTree/order/serializers.py index c62ce69d90..5d0fd37d5b 100644 --- a/src/backend/InvenTree/order/serializers.py +++ b/src/backend/InvenTree/order/serializers.py @@ -639,7 +639,7 @@ class PurchaseOrderLineItemSerializer( help_text=_( 'Automatically calculate purchase price based on supplier part data' ), - default=True, + default=False, ) destination_detail = enable_filter( diff --git a/src/frontend/src/forms/PurchaseOrderForms.tsx b/src/frontend/src/forms/PurchaseOrderForms.tsx index cb22aa5c86..b83f1e8d8b 100644 --- a/src/frontend/src/forms/PurchaseOrderForms.tsx +++ b/src/frontend/src/forms/PurchaseOrderForms.tsx @@ -113,16 +113,6 @@ export function usePurchaseOrderLineItemFields({ } }, [create, part, quantity, priceBreaks]); - useEffect(() => { - if (autoPricing) { - setPurchasePrice(''); - } - }, [autoPricing]); - - useEffect(() => { - setAutoPricing(purchasePrice === ''); - }, [purchasePrice]); - const fields = useMemo(() => { const fields: ApiFormFieldSet = { order: { @@ -159,6 +149,7 @@ export function usePurchaseOrderLineItemFields({ purchase_price: { icon: , value: purchasePrice, + disabled: autoPricing, placeholder: suggestedPurchasePrice, placeholderAutofill: true, onValueChange: setPurchasePrice @@ -169,6 +160,7 @@ export function usePurchaseOrderLineItemFields({ onValueChange: setPurchasePriceCurrency }, auto_pricing: { + default: create !== false, value: autoPricing, onValueChange: setAutoPricing },