mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +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
|
'markdownify', # Markdown template rendering
|
||||||
'django_tex', # LaTeX output
|
'django_tex', # LaTeX output
|
||||||
'django_admin_shell', # Python shell for the admin interface
|
'django_admin_shell', # Python shell for the admin interface
|
||||||
|
'djmoney', # django-money integration
|
||||||
]
|
]
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
|
@ -124,6 +124,7 @@ class CreateStockItemForm(HelperForm):
|
|||||||
fields = [
|
fields = [
|
||||||
'part',
|
'part',
|
||||||
'supplier_part',
|
'supplier_part',
|
||||||
|
'purchase_price',
|
||||||
'location',
|
'location',
|
||||||
'quantity',
|
'quantity',
|
||||||
'batch',
|
'batch',
|
||||||
@ -399,6 +400,7 @@ class EditStockItemForm(HelperForm):
|
|||||||
'serial',
|
'serial',
|
||||||
'batch',
|
'batch',
|
||||||
'status',
|
'status',
|
||||||
|
'purchase_price',
|
||||||
'link',
|
'link',
|
||||||
'delete_on_deplete',
|
'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 mptt.models import MPTTModel, TreeForeignKey
|
||||||
|
|
||||||
|
from djmoney.models.fields import MoneyField
|
||||||
|
|
||||||
from decimal import Decimal, InvalidOperation
|
from decimal import Decimal, InvalidOperation
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from InvenTree import helpers
|
from InvenTree import helpers
|
||||||
@ -135,6 +137,7 @@ class StockItem(MPTTModel):
|
|||||||
infinite: If True this StockItem can never be exhausted
|
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)
|
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)
|
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"
|
# 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')
|
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):
|
def clearAllocations(self):
|
||||||
"""
|
"""
|
||||||
Clear all order allocations for this StockItem:
|
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>
|
<td><a href="{% url 'po-detail' item.purchase_order.id %}">{{ item.purchase_order }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% 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 %}
|
{% if item.parent %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class='fas fa-sitemap'></span></td>
|
<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-weasyprint==1.0.1 # HTML PDF export
|
||||||
django-debug-toolbar==2.2 # Debug / profiling toolbar
|
django-debug-toolbar==2.2 # Debug / profiling toolbar
|
||||||
django-admin-shell==0.1.2 # Python shell for the admin interface
|
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
|
inventree # Install the latest version of the InvenTree API python library
|
Loading…
x
Reference in New Issue
Block a user