2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-15 19:45:46 +00:00

Serialize BOMItem pricing information

- Account for quantity
- Prefetch required items
This commit is contained in:
Oliver Walters
2019-05-21 15:15:54 +10:00
parent 74479a7d52
commit 988a35d237
3 changed files with 35 additions and 2 deletions

View File

@ -933,3 +933,19 @@ class BomItem(models.Model):
base_quantity = self.quantity * build_quantity
return base_quantity + self.get_overage_quantity(base_quantity)
@property
def price_range(self):
""" Return the price-range for this BOM item. """
prange = self.sub_part.get_price_range(self.quantity)
if prange is None:
return prange
pmin, pmax = prange
if pmin == pmax:
return str(pmin)
return "{pmin} to {pmax}".format(pmin=pmin, pmax=pmax)