Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions inventree/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import inventree.base
import inventree.report
import inventree.stock


class Build(
Expand Down Expand Up @@ -48,3 +49,41 @@ def complete(
def finish(self, *args, **kwargs):
"""Alias for complete"""
return self.complete(*args, **kwargs)

def getLines(self, **kwargs):
""" Return the build line items associated with this build order """
return BuildLine.list(self._api, build=self.pk, **kwargs)


class BuildLine(
inventree.base.InventreeObject,
):
""" Class representing the BuildLine database model """

URL = 'build/line/'
MODEL_TYPE = 'buildline'

def getBuild(self):
"""Return the Build object associated with this line item"""
return Build(self._api, self.build)


class BuildItem(
inventree.base.InventreeObject,
):
""" Class representing the BuildItem database model """

URL = 'build/item/'
MODEL_TYPE = 'builditem'

def getBuild(self):
"""Return the Build object associated with this build item"""
return Build(self._api, self.build)

def getBuildLine(self):
"""Return the BuildLine object associated with this build item"""
return BuildLine(self._api, self.build_line)

def getStockItem(self):
"""Return the StockItem object associated with this build item"""
return inventree.stock.StockItem(self._api, self.stock_item)
8 changes: 4 additions & 4 deletions test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def get_build(self):
self.api,
{
"title": "Automated test build",
"part": 25,
"part": 100,
"quantity": 100,
"reference": f"BO-{n+1:04d}",
"reference": f"BO-{n + 1:04d}",
}
)
else:
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_build_cancel(self):
"title": "Automated test build",
"part": 25,
"quantity": 100,
"reference": f"BO-{n+1:04d}"
"reference": f"BO-{n + 1:04d}"
}
)

Expand All @@ -118,7 +118,7 @@ def test_build_complete(self):
"title": "Automated test build",
"part": 25,
"quantity": 100,
"reference": f"BO-{n+1:04d}"
"reference": f"BO-{n + 1:04d}"
}
)

Expand Down