mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 21:15:41 +00:00
Add settings for controlling variant pricing (#3987)
* Add settings for controlling variant pricing * Select whether to use variant pricing * Add setting to ignore inactive variants * Update variant pricing table
This commit is contained in:
@ -2571,10 +2571,17 @@ class PartPricing(models.Model):
|
||||
variant_min = None
|
||||
variant_max = None
|
||||
|
||||
active_only = InvenTreeSetting.get_setting('PRICING_ACTIVE_VARIANTS', False)
|
||||
|
||||
if self.part.is_template:
|
||||
variants = self.part.get_descendants(include_self=False)
|
||||
|
||||
for v in variants:
|
||||
|
||||
if active_only and not v.active:
|
||||
# Ignore inactive variant parts
|
||||
continue
|
||||
|
||||
v_min = self.convert(v.pricing.overall_min)
|
||||
v_max = self.convert(v.pricing.overall_max)
|
||||
|
||||
@ -2605,20 +2612,22 @@ class PartPricing(models.Model):
|
||||
self.bom_cost_min,
|
||||
self.purchase_cost_min,
|
||||
self.internal_cost_min,
|
||||
self.variant_cost_min
|
||||
]
|
||||
|
||||
max_costs = [
|
||||
self.bom_cost_max,
|
||||
self.purchase_cost_max,
|
||||
self.internal_cost_max,
|
||||
self.variant_cost_max
|
||||
]
|
||||
|
||||
if InvenTreeSetting.get_setting('PRICING_USE_SUPPLIER_PRICING', True):
|
||||
min_costs.append(self.supplier_price_min)
|
||||
max_costs.append(self.supplier_price_max)
|
||||
|
||||
if InvenTreeSetting.get_setting('PRICING_USE_VARIANT_PRICING', True):
|
||||
min_costs.append(self.variant_cost_min)
|
||||
max_costs.append(self.variant_cost_max)
|
||||
|
||||
# Calculate overall minimum cost
|
||||
for cost in min_costs:
|
||||
if cost is None:
|
||||
|
Reference in New Issue
Block a user