mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add integration of django-money
- Proper currency support - Add PurchasePrice field to StockItem model - This keeps track of both the price and the currency - Display purchase price on the stockitem detail page
This commit is contained in:
parent
9d9ef5fc9c
commit
734436b02e
@ -155,6 +155,7 @@ INSTALLED_APPS = [
|
||||
'markdownify', # Markdown template rendering
|
||||
'django_tex', # LaTeX output
|
||||
'django_admin_shell', # Python shell for the admin interface
|
||||
'djmoney', # django-money integration
|
||||
]
|
||||
|
||||
LOGGING = {
|
||||
|
@ -124,6 +124,7 @@ class CreateStockItemForm(HelperForm):
|
||||
fields = [
|
||||
'part',
|
||||
'supplier_part',
|
||||
'purchase_price',
|
||||
'location',
|
||||
'quantity',
|
||||
'batch',
|
||||
@ -399,6 +400,7 @@ class EditStockItemForm(HelperForm):
|
||||
'serial',
|
||||
'batch',
|
||||
'status',
|
||||
'purchase_price',
|
||||
'link',
|
||||
'delete_on_deplete',
|
||||
]
|
||||
|
24
InvenTree/stock/migrations/0053_auto_20201110_0513.py
Normal file
24
InvenTree/stock/migrations/0053_auto_20201110_0513.py
Normal file
File diff suppressed because one or more lines are too long
@ -24,6 +24,8 @@ from markdownx.models import MarkdownxField
|
||||
|
||||
from mptt.models import MPTTModel, TreeForeignKey
|
||||
|
||||
from djmoney.models.fields import MoneyField
|
||||
|
||||
from decimal import Decimal, InvalidOperation
|
||||
from datetime import datetime
|
||||
from InvenTree import helpers
|
||||
@ -135,6 +137,7 @@ class StockItem(MPTTModel):
|
||||
infinite: If True this StockItem can never be exhausted
|
||||
sales_order: Link to a SalesOrder object (if the StockItem has been assigned to a SalesOrder)
|
||||
build_order: Link to a BuildOrder object (if the StockItem has been assigned to a BuildOrder)
|
||||
purchase_price: The unit purchase price for this StockItem - this is the unit price at time of purchase (if this item was purchased from an external supplier)
|
||||
"""
|
||||
|
||||
# A Query filter which will be re-used in multiple places to determine if a StockItem is actually "in stock"
|
||||
@ -456,6 +459,15 @@ class StockItem(MPTTModel):
|
||||
help_text=_('Stock Item Notes')
|
||||
)
|
||||
|
||||
purchase_price = MoneyField(
|
||||
max_digits=19,
|
||||
decimal_places=4,
|
||||
default_currency='USD',
|
||||
null=True,
|
||||
verbose_name=_('Purchase Price'),
|
||||
help_text=_('Single unit purchase price at time of purchase'),
|
||||
)
|
||||
|
||||
def clearAllocations(self):
|
||||
"""
|
||||
Clear all order allocations for this StockItem:
|
||||
|
@ -266,6 +266,13 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
|
||||
<td><a href="{% url 'po-detail' item.purchase_order.id %}">{{ item.purchase_order }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if item.purchase_price %}
|
||||
<tr>
|
||||
<td><span class='fas fa-dollar-sign'></span></td>
|
||||
<td>{% trans "Purchase Price" %}</td>
|
||||
<td>{{ item.purchase_price }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if item.parent %}
|
||||
<tr>
|
||||
<td><span class='fas fa-sitemap'></span></td>
|
||||
|
@ -26,5 +26,6 @@ django-tex==1.1.7 # LaTeX PDF export
|
||||
django-weasyprint==1.0.1 # HTML PDF export
|
||||
django-debug-toolbar==2.2 # Debug / profiling toolbar
|
||||
django-admin-shell==0.1.2 # Python shell for the admin interface
|
||||
django-money==1.1 # Django app for currency management
|
||||
|
||||
inventree # Install the latest version of the InvenTree API python library
|
Loading…
Reference in New Issue
Block a user