Skip to content

Commit

Permalink
Order Hold (#236)
Browse files Browse the repository at this point in the history
* Update unit tests for build order

* Add order status update functions
  • Loading branch information
SchrodingersGat authored Aug 7, 2024
1 parent 27a1638 commit 504fcef
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inventree/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from . import api as inventree_api

INVENTREE_PYTHON_VERSION = "0.16.0"
INVENTREE_PYTHON_VERSION = "0.16.1"


logger = logging.getLogger('inventree')
Expand Down
8 changes: 8 additions & 0 deletions inventree/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ class Build(
URL = 'build'
MODEL_TYPE = 'build'

def issue(self):
"""Mark this build as 'issued'."""
return self._statusupdate(status='issue')

def hold(self):
"""Mark this build as 'on hold'."""
return self._statusupdate(status='hold')

def complete(
self,
accept_overallocated='reject',
Expand Down
8 changes: 8 additions & 0 deletions inventree/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ def issue(self, **kwargs):
# Return
return self._statusupdate(status='issue', **kwargs)

def hold(self, **kwargs):
"""
Hold the purchase order
"""

# Return
return self._statusupdate(status='hold', **kwargs)

def receiveAll(self, location, status=10):
"""
Receive all of the purchase order items, into the given location.
Expand Down
4 changes: 4 additions & 0 deletions inventree/return_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def issue(self, **kwargs):
"""Issue (send) this order"""
return self._statusupdate(status='issue', **kwargs)

def hold(self, **kwargs):
"""Place this order on hold"""
return self._statusupdate(status='hold', **kwargs)

def cancel(self, **kwargs):
"""Cancel this order"""
return self._statusupdate(status='cancel', **kwargs)
Expand Down
12 changes: 12 additions & 0 deletions inventree/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ def addShipment(self, reference, **kwargs):

return SalesOrderShipment.create(self._api, data=kwargs)

def issue(self, **kwargs):
"""Issue (send) this order"""
return self._statusupdate(status='issue', **kwargs)

def hold(self, **kwargs):
"""Place this order on hold"""
return self._statusupdate(status='hold', **kwargs)

def cancel(self, **kwargs):
"""Cancel this order"""
return self._statusupdate(status='cancel', **kwargs)


class SalesOrderLineItem(
inventree.base.InventreeObject,
Expand Down
16 changes: 16 additions & 0 deletions test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ def test_build_complete(self):
}
)

# Check that build status is pending
self.assertEqual(build.status, 10)

if self.api.api_version >= 233:
# Issue the build order
build.issue()
self.assertEqual(build.status, 20)

# Mark build order as "on hold" again
build.hold()
self.assertEqual(build.status, 25)

# Issue again
build.issue()
self.assertEqual(build.status, 20)

# Complete the build, even though it is not completed
build.complete(accept_unallocated=True, accept_incomplete=True)

Expand Down

0 comments on commit 504fcef

Please sign in to comment.