Skip to content

Commit 504fcef

Browse files
Order Hold (#236)
* Update unit tests for build order * Add order status update functions
1 parent 27a1638 commit 504fcef

File tree

6 files changed

+49
-1
lines changed

6 files changed

+49
-1
lines changed

inventree/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from . import api as inventree_api
88

9-
INVENTREE_PYTHON_VERSION = "0.16.0"
9+
INVENTREE_PYTHON_VERSION = "0.16.1"
1010

1111

1212
logger = logging.getLogger('inventree')

inventree/build.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ class Build(
1616
URL = 'build'
1717
MODEL_TYPE = 'build'
1818

19+
def issue(self):
20+
"""Mark this build as 'issued'."""
21+
return self._statusupdate(status='issue')
22+
23+
def hold(self):
24+
"""Mark this build as 'on hold'."""
25+
return self._statusupdate(status='hold')
26+
1927
def complete(
2028
self,
2129
accept_overallocated='reject',

inventree/purchase_order.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ def issue(self, **kwargs):
6565
# Return
6666
return self._statusupdate(status='issue', **kwargs)
6767

68+
def hold(self, **kwargs):
69+
"""
70+
Hold the purchase order
71+
"""
72+
73+
# Return
74+
return self._statusupdate(status='hold', **kwargs)
75+
6876
def receiveAll(self, location, status=10):
6977
"""
7078
Receive all of the purchase order items, into the given location.

inventree/return_order.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def issue(self, **kwargs):
5555
"""Issue (send) this order"""
5656
return self._statusupdate(status='issue', **kwargs)
5757

58+
def hold(self, **kwargs):
59+
"""Place this order on hold"""
60+
return self._statusupdate(status='hold', **kwargs)
61+
5862
def cancel(self, **kwargs):
5963
"""Cancel this order"""
6064
return self._statusupdate(status='cancel', **kwargs)

inventree/sales_order.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ def addShipment(self, reference, **kwargs):
7171

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

74+
def issue(self, **kwargs):
75+
"""Issue (send) this order"""
76+
return self._statusupdate(status='issue', **kwargs)
77+
78+
def hold(self, **kwargs):
79+
"""Place this order on hold"""
80+
return self._statusupdate(status='hold', **kwargs)
81+
82+
def cancel(self, **kwargs):
83+
"""Cancel this order"""
84+
return self._statusupdate(status='cancel', **kwargs)
85+
7486

7587
class SalesOrderLineItem(
7688
inventree.base.InventreeObject,

test/test_build.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,22 @@ def test_build_complete(self):
122122
}
123123
)
124124

125+
# Check that build status is pending
126+
self.assertEqual(build.status, 10)
127+
128+
if self.api.api_version >= 233:
129+
# Issue the build order
130+
build.issue()
131+
self.assertEqual(build.status, 20)
132+
133+
# Mark build order as "on hold" again
134+
build.hold()
135+
self.assertEqual(build.status, 25)
136+
137+
# Issue again
138+
build.issue()
139+
self.assertEqual(build.status, 20)
140+
125141
# Complete the build, even though it is not completed
126142
build.complete(accept_unallocated=True, accept_incomplete=True)
127143

0 commit comments

Comments
 (0)