Skip to content

Commit c005ef8

Browse files
Enhanced build models support
- Add BuildLine - Add BuildItem
1 parent 4712249 commit c005ef8

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

inventree/build.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import inventree.base
44
import inventree.report
5+
import inventree.stock
56

67

78
class Build(
@@ -48,3 +49,40 @@ def complete(
4849
def finish(self, *args, **kwargs):
4950
"""Alias for complete"""
5051
return self.complete(*args, **kwargs)
52+
53+
def getLines(self, **kwargs):
54+
""" Return the build line items associated with this build order """
55+
return BuildLine.list(self._api, build=self.pk, **kwargs)
56+
57+
class BuildLine(
58+
inventree.base.InventreeObject,
59+
):
60+
""" Class representing the BuildLine database model """
61+
62+
URL = 'build/line/'
63+
MODEL_TYPE = 'buildline'
64+
65+
def getBuild(self):
66+
"""Return the Build object associated with this line item"""
67+
return Build(self._api, self.build)
68+
69+
70+
class BuildItem(
71+
inventree.base.InventreeObject,
72+
):
73+
""" Class representing the BuildItem database model """
74+
75+
URL = 'build/item/'
76+
MODEL_TYPE = 'builditem'
77+
78+
def getBuild(self):
79+
"""Return the Build object associated with this build item"""
80+
return Build(self._api, self.build)
81+
82+
def getBuildLine(self):
83+
"""Return the BuildLine object associated with this build item"""
84+
return BuildLine(self._api, self.build_line)
85+
86+
def getStockItem(self):
87+
"""Return the StockItem object associated with this build item"""
88+
return inventree.stock.StockItem(self._api, self.stock_item)

0 commit comments

Comments
 (0)