mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1722 from matmair/internal-price-op
full Internal price coverage
This commit is contained in:
commit
76ec51a93b
@ -1479,16 +1479,17 @@ class Part(MPTTModel):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_price_info(self, quantity=1, buy=True, bom=True):
|
def get_price_info(self, quantity=1, buy=True, bom=True, internal=False):
|
||||||
""" Return a simplified pricing string for this part
|
""" Return a simplified pricing string for this part
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
quantity: Number of units to calculate price for
|
quantity: Number of units to calculate price for
|
||||||
buy: Include supplier pricing (default = True)
|
buy: Include supplier pricing (default = True)
|
||||||
bom: Include BOM pricing (default = True)
|
bom: Include BOM pricing (default = True)
|
||||||
|
internal: Include internal pricing (default = False)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
price_range = self.get_price_range(quantity, buy, bom)
|
price_range = self.get_price_range(quantity, buy, bom, internal)
|
||||||
|
|
||||||
if price_range is None:
|
if price_range is None:
|
||||||
return None
|
return None
|
||||||
@ -1576,9 +1577,10 @@ class Part(MPTTModel):
|
|||||||
|
|
||||||
- Supplier price (if purchased from suppliers)
|
- Supplier price (if purchased from suppliers)
|
||||||
- BOM price (if built from other parts)
|
- BOM price (if built from other parts)
|
||||||
|
- Internal price (if set for the part)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Minimum of the supplier price or BOM price. If no pricing available, returns None
|
Minimum of the supplier, BOM or internal price. If no pricing available, returns None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# only get internal price if set and should be used
|
# only get internal price if set and should be used
|
||||||
@ -2499,7 +2501,9 @@ class BomItem(models.Model):
|
|||||||
def price_range(self):
|
def price_range(self):
|
||||||
""" Return the price-range for this BOM item. """
|
""" Return the price-range for this BOM item. """
|
||||||
|
|
||||||
prange = self.sub_part.get_price_range(self.quantity)
|
# get internal price setting
|
||||||
|
use_internal = common.models.InvenTreeSetting.get_setting('PART_BOM_USE_INTERNAL_PRICE', False)
|
||||||
|
prange = self.sub_part.get_price_range(self.quantity, intenal=use_internal)
|
||||||
|
|
||||||
if prange is None:
|
if prange is None:
|
||||||
return prange
|
return prange
|
||||||
|
@ -847,11 +847,13 @@ class PartPricingView(PartDetail):
|
|||||||
|
|
||||||
# BOM Information for Pie-Chart
|
# BOM Information for Pie-Chart
|
||||||
if part.has_bom:
|
if part.has_bom:
|
||||||
|
# get internal price setting
|
||||||
|
use_internal = InvenTreeSetting.get_setting('PART_BOM_USE_INTERNAL_PRICE', False)
|
||||||
ctx_bom_parts = []
|
ctx_bom_parts = []
|
||||||
# iterate over all bom-items
|
# iterate over all bom-items
|
||||||
for item in part.bom_items.all():
|
for item in part.bom_items.all():
|
||||||
ctx_item = {'name': str(item.sub_part)}
|
ctx_item = {'name': str(item.sub_part)}
|
||||||
price, qty = item.sub_part.get_price_range(quantity), item.quantity
|
price, qty = item.sub_part.get_price_range(quantity, internal=use_internal), item.quantity
|
||||||
|
|
||||||
price_min, price_max = 0, 0
|
price_min, price_max = 0, 0
|
||||||
if price: # check if price available
|
if price: # check if price available
|
||||||
|
Loading…
Reference in New Issue
Block a user