mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-14 07:31:10 +00:00
Merge branch 'master' of https://github.com/inventree/InvenTree into sn-append
This commit is contained in:
.github/workflows
InvenTree
InvenTree
company
templates
company
locale
de
LC_MESSAGES
el
LC_MESSAGES
es
LC_MESSAGES
fr
LC_MESSAGES
he
LC_MESSAGES
id
LC_MESSAGES
it
LC_MESSAGES
ja
LC_MESSAGES
ko
LC_MESSAGES
nl
LC_MESSAGES
no
LC_MESSAGES
pl
LC_MESSAGES
pt
LC_MESSAGES
ru
LC_MESSAGES
sv
LC_MESSAGES
th
LC_MESSAGES
tr
LC_MESSAGES
vi
LC_MESSAGES
zh
LC_MESSAGES
order
part
script
stock
templates
docker
Dockerfiledev-config.envdocker-compose.dev.ymldocker-compose.sqlite.ymlinit.shprod-config.envrequirements.txtsqlite-config.env
requirements.txt@@ -628,28 +628,30 @@ class SalesOrder(Order):
|
||||
Throws a ValidationError if cannot be completed.
|
||||
"""
|
||||
|
||||
# Order without line items cannot be completed
|
||||
if self.lines.count() == 0:
|
||||
if raise_error:
|
||||
try:
|
||||
|
||||
# Order without line items cannot be completed
|
||||
if self.lines.count() == 0:
|
||||
raise ValidationError(_('Order cannot be completed as no parts have been assigned'))
|
||||
|
||||
# Only a PENDING order can be marked as SHIPPED
|
||||
elif self.status != SalesOrderStatus.PENDING:
|
||||
if raise_error:
|
||||
# Only a PENDING order can be marked as SHIPPED
|
||||
elif self.status != SalesOrderStatus.PENDING:
|
||||
raise ValidationError(_('Only a pending order can be marked as complete'))
|
||||
|
||||
elif self.pending_shipment_count > 0:
|
||||
if raise_error:
|
||||
elif self.pending_shipment_count > 0:
|
||||
raise ValidationError(_("Order cannot be completed as there are incomplete shipments"))
|
||||
|
||||
elif self.pending_line_count > 0:
|
||||
if raise_error:
|
||||
elif self.pending_line_count > 0:
|
||||
raise ValidationError(_("Order cannot be completed as there are incomplete line items"))
|
||||
|
||||
else:
|
||||
return True
|
||||
except ValidationError as e:
|
||||
|
||||
return False
|
||||
if raise_error:
|
||||
raise e
|
||||
else:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def complete_order(self, user):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user