2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-02 11:40:58 +00:00

Include stock item purchase price in pricing cache (#4292)

* Add setting to control pricing calculation from stock items

* Bug fix for displaying a "null" setting

* Add new fields to PartPricing model

* Add code for calculation of min/max stock item costs

* Update pricing display to use stock item pricing

* Add unit testing for new pricing features

* Automatically update pricing when stock item is created or edited

* Increment API version

* Improvements for price rendering

* Update based on feedback:

- Roll stock item pricing into purchase pricing
- Simplify models
- Update unit tests
This commit is contained in:
Oliver
2023-02-02 21:23:16 +11:00
committed by GitHub
parent df4209801a
commit 9a289948e5
10 changed files with 126 additions and 42 deletions

View File

@ -390,9 +390,12 @@ class BaseInvenTreeSetting(models.Model):
if create:
# Attempt to create a new settings object
default_value = cls.get_setting_default(key, **kwargs)
setting = cls(
key=key,
value=cls.get_setting_default(key, **kwargs),
value=default_value,
**kwargs
)
@ -1173,6 +1176,24 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'validator': bool,
},
'PRICING_USE_STOCK_PRICING': {
'name': _('Use Stock Item Pricing'),
'description': _('Use pricing from manually entered stock data for pricing calculations'),
'default': True,
'validator': bool,
},
'PRICING_STOCK_ITEM_AGE_DAYS': {
'name': _('Stock Item Pricing Age'),
'description': _('Exclude stock items older than this number of days from pricing calculations'),
'default': 0,
'units': 'days',
'validator': [
int,
MinValueValidator(0),
]
},
'PRICING_USE_VARIANT_PRICING': {
'name': _('Use Variant Pricing'),
'description': _('Include variant pricing in overall pricing calculations'),