mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
stop cascade update_pricing if prices didnt change (#5606)
Co-authored-by: Oliver Lippert <oliver@lipperts-web.de>
This commit is contained in:
parent
c06047d026
commit
2f0dbf9776
@ -2350,6 +2350,8 @@ class PartPricing(common.models.MetaMixin):
|
|||||||
- Detailed pricing information is very context specific in any case
|
- Detailed pricing information is very context specific in any case
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
price_modified = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
"""Return True if the cached pricing is valid"""
|
"""Return True if the cached pricing is valid"""
|
||||||
@ -2476,7 +2478,7 @@ class PartPricing(common.models.MetaMixin):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# Update parent assemblies and templates
|
# Update parent assemblies and templates
|
||||||
if cascade:
|
if cascade and self.price_modified:
|
||||||
self.update_assemblies(counter)
|
self.update_assemblies(counter)
|
||||||
self.update_templates(counter)
|
self.update_templates(counter)
|
||||||
|
|
||||||
@ -2576,6 +2578,9 @@ class PartPricing(common.models.MetaMixin):
|
|||||||
|
|
||||||
any_max_elements = True
|
any_max_elements = True
|
||||||
|
|
||||||
|
old_bom_cost_min = self.bom_cost_min
|
||||||
|
old_bom_cost_max = self.bom_cost_max
|
||||||
|
|
||||||
if any_min_elements:
|
if any_min_elements:
|
||||||
self.bom_cost_min = cumulative_min
|
self.bom_cost_min = cumulative_min
|
||||||
else:
|
else:
|
||||||
@ -2586,6 +2591,9 @@ class PartPricing(common.models.MetaMixin):
|
|||||||
else:
|
else:
|
||||||
self.bom_cost_max = None
|
self.bom_cost_max = None
|
||||||
|
|
||||||
|
if old_bom_cost_min != self.bom_cost_min or old_bom_cost_max != self.bom_cost_max:
|
||||||
|
self.price_modified = True
|
||||||
|
|
||||||
if save:
|
if save:
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
@ -2650,6 +2658,9 @@ class PartPricing(common.models.MetaMixin):
|
|||||||
if purchase_max is None or cost > purchase_max:
|
if purchase_max is None or cost > purchase_max:
|
||||||
purchase_max = cost
|
purchase_max = cost
|
||||||
|
|
||||||
|
if self.purchase_cost_min != purchase_min or self.purchase_cost_max != purchase_max:
|
||||||
|
self.price_modified = True
|
||||||
|
|
||||||
self.purchase_cost_min = purchase_min
|
self.purchase_cost_min = purchase_min
|
||||||
self.purchase_cost_max = purchase_max
|
self.purchase_cost_max = purchase_max
|
||||||
|
|
||||||
@ -2677,6 +2688,9 @@ class PartPricing(common.models.MetaMixin):
|
|||||||
if max_int_cost is None or cost > max_int_cost:
|
if max_int_cost is None or cost > max_int_cost:
|
||||||
max_int_cost = cost
|
max_int_cost = cost
|
||||||
|
|
||||||
|
if self.internal_cost_min != min_int_cost or self.internal_cost_max != max_int_cost:
|
||||||
|
self.price_modified = True
|
||||||
|
|
||||||
self.internal_cost_min = min_int_cost
|
self.internal_cost_min = min_int_cost
|
||||||
self.internal_cost_max = max_int_cost
|
self.internal_cost_max = max_int_cost
|
||||||
|
|
||||||
@ -2716,6 +2730,9 @@ class PartPricing(common.models.MetaMixin):
|
|||||||
if max_sup_cost is None or cost > max_sup_cost:
|
if max_sup_cost is None or cost > max_sup_cost:
|
||||||
max_sup_cost = cost
|
max_sup_cost = cost
|
||||||
|
|
||||||
|
if self.supplier_price_min != min_sup_cost or self.supplier_price_max != max_sup_cost:
|
||||||
|
self.price_modified = True
|
||||||
|
|
||||||
self.supplier_price_min = min_sup_cost
|
self.supplier_price_min = min_sup_cost
|
||||||
self.supplier_price_max = max_sup_cost
|
self.supplier_price_max = max_sup_cost
|
||||||
|
|
||||||
@ -2753,6 +2770,9 @@ class PartPricing(common.models.MetaMixin):
|
|||||||
if variant_max is None or v_max > variant_max:
|
if variant_max is None or v_max > variant_max:
|
||||||
variant_max = v_max
|
variant_max = v_max
|
||||||
|
|
||||||
|
if self.variant_cost_min != variant_min or self.variant_cost_max != variant_max:
|
||||||
|
self.price_modified = True
|
||||||
|
|
||||||
self.variant_cost_min = variant_min
|
self.variant_cost_min = variant_min
|
||||||
self.variant_cost_max = variant_max
|
self.variant_cost_max = variant_max
|
||||||
|
|
||||||
@ -2877,6 +2897,9 @@ class PartPricing(common.models.MetaMixin):
|
|||||||
if max_sell_history is None or cost > max_sell_history:
|
if max_sell_history is None or cost > max_sell_history:
|
||||||
max_sell_history = cost
|
max_sell_history = cost
|
||||||
|
|
||||||
|
if self.sale_history_min != min_sell_history or self.sale_history_max != max_sell_history:
|
||||||
|
self.price_modified = True
|
||||||
|
|
||||||
self.sale_history_min = min_sell_history
|
self.sale_history_min = min_sell_history
|
||||||
self.sale_history_max = max_sell_history
|
self.sale_history_max = max_sell_history
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user