mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 03:26:45 +00:00
Barcode validation fix (#9127)
* Fix logic for adding items to SalesOrder * Same thing for purchase orders * Update serializers.py Revert typo fix - Otherwise, we need to do an API bump and the PR can't be back-ported!
This commit is contained in:
parent
6930ae7122
commit
bc9dbf7df4
@ -11,7 +11,11 @@ import order.models
|
||||
import plugin.base.barcodes.helper
|
||||
import stock.models
|
||||
from InvenTree.serializers import UserSerializer
|
||||
from order.status_codes import PurchaseOrderStatus, SalesOrderStatus
|
||||
from order.status_codes import (
|
||||
PurchaseOrderStatus,
|
||||
PurchaseOrderStatusGroups,
|
||||
SalesOrderStatusGroups,
|
||||
)
|
||||
|
||||
|
||||
class BarcodeScanResultSerializer(serializers.ModelSerializer):
|
||||
@ -135,8 +139,8 @@ class BarcodePOAllocateSerializer(BarcodeSerializer):
|
||||
|
||||
def validate_purchase_order(self, order: order.models.PurchaseOrder):
|
||||
"""Validate the provided order."""
|
||||
if order.status != PurchaseOrderStatus.PENDING.value:
|
||||
raise ValidationError(_('Purchase order is not pending'))
|
||||
if order.status not in PurchaseOrderStatusGroups.OPEN:
|
||||
raise ValidationError(_('Purchase order is not open'))
|
||||
|
||||
return order
|
||||
|
||||
@ -213,8 +217,8 @@ class BarcodeSOAllocateSerializer(BarcodeSerializer):
|
||||
|
||||
def validate_sales_order(self, order: order.models.SalesOrder):
|
||||
"""Validate the provided order."""
|
||||
if order and order.status != SalesOrderStatus.PENDING.value:
|
||||
raise ValidationError(_('Sales order is not pending'))
|
||||
if order and order.status not in SalesOrderStatusGroups.OPEN:
|
||||
raise ValidationError(_('Sales order is not open'))
|
||||
|
||||
return order
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user