diff --git a/inventree/base.py b/inventree/base.py index be380fa..9a1a3f6 100644 --- a/inventree/base.py +++ b/inventree/base.py @@ -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') diff --git a/inventree/build.py b/inventree/build.py index de5cbe0..9b05d82 100644 --- a/inventree/build.py +++ b/inventree/build.py @@ -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', diff --git a/inventree/purchase_order.py b/inventree/purchase_order.py index 98907c5..ff59f4e 100644 --- a/inventree/purchase_order.py +++ b/inventree/purchase_order.py @@ -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. diff --git a/inventree/return_order.py b/inventree/return_order.py index 0da6226..c5cf324 100644 --- a/inventree/return_order.py +++ b/inventree/return_order.py @@ -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) diff --git a/inventree/sales_order.py b/inventree/sales_order.py index 2d88bdf..e96fadc 100644 --- a/inventree/sales_order.py +++ b/inventree/sales_order.py @@ -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, diff --git a/test/test_build.py b/test/test_build.py index 8b36109..45929bb 100644 --- a/test/test_build.py +++ b/test/test_build.py @@ -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)