|
2 | 2 |
|
3 | 3 | import inventree.base |
4 | 4 | import inventree.report |
| 5 | +import inventree.stock |
5 | 6 |
|
6 | 7 |
|
7 | 8 | class Build( |
@@ -48,3 +49,40 @@ def complete( |
48 | 49 | def finish(self, *args, **kwargs): |
49 | 50 | """Alias for complete""" |
50 | 51 | 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