mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add in sale price model
This commit is contained in:
parent
5d214fc869
commit
1614c6e08a
@ -211,6 +211,7 @@ class EditSalesOrderLineItemForm(HelperForm):
|
||||
'part',
|
||||
'quantity',
|
||||
'reference',
|
||||
'sale_price',
|
||||
'notes'
|
||||
]
|
||||
|
||||
|
24
InvenTree/order/migrations/0045_auto_20210504_1946.py
Normal file
24
InvenTree/order/migrations/0045_auto_20210504_1946.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Generated by Django 3.2 on 2021-05-04 19:46
|
||||
|
||||
from django.db import migrations
|
||||
import djmoney.models.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('order', '0044_auto_20210404_2016'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='salesorderlineitem',
|
||||
name='sale_price',
|
||||
field=djmoney.models.fields.MoneyField(blank=True, decimal_places=4, default_currency='USD', help_text='Unit sale price', max_digits=19, null=True, verbose_name='Sale Price'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='salesorderlineitem',
|
||||
name='sale_price_currency',
|
||||
field=djmoney.models.fields.CurrencyField(choices=[('AUD', 'Australian Dollar'), ('GBP', 'British Pound'), ('CAD', 'Canadian Dollar'), ('EUR', 'Euro'), ('JPY', 'Japanese Yen'), ('NZD', 'New Zealand Dollar'), ('USD', 'US Dollar')], default='USD', editable=False, max_length=3),
|
||||
),
|
||||
]
|
@ -664,12 +664,22 @@ class SalesOrderLineItem(OrderLineItem):
|
||||
Attributes:
|
||||
order: Link to the SalesOrder that this line item belongs to
|
||||
part: Link to a Part object (may be null)
|
||||
sale_price: The unit sale price for this OrderLineItem
|
||||
"""
|
||||
|
||||
order = models.ForeignKey(SalesOrder, on_delete=models.CASCADE, related_name='lines', verbose_name=_('Order'), help_text=_('Sales Order'))
|
||||
|
||||
part = models.ForeignKey('part.Part', on_delete=models.SET_NULL, related_name='sales_order_line_items', null=True, verbose_name=_('Part'), help_text=_('Part'), limit_choices_to={'salable': True})
|
||||
|
||||
sale_price = MoneyField(
|
||||
max_digits=19,
|
||||
decimal_places=4,
|
||||
default_currency='USD',
|
||||
null=True, blank=True,
|
||||
verbose_name=_('Sale Price'),
|
||||
help_text=_('Unit sale price'),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
unique_together = [
|
||||
]
|
||||
|
@ -278,6 +278,7 @@ class SOLineItemSerializer(InvenTreeModelSerializer):
|
||||
quantity = serializers.FloatField()
|
||||
allocated = serializers.FloatField(source='allocated_quantity', read_only=True)
|
||||
fulfilled = serializers.FloatField(source='fulfilled_quantity', read_only=True)
|
||||
sale_price_string = serializers.CharField(source='sale_price', read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = SalesOrderLineItem
|
||||
@ -294,6 +295,9 @@ class SOLineItemSerializer(InvenTreeModelSerializer):
|
||||
'order_detail',
|
||||
'part',
|
||||
'part_detail',
|
||||
'sale_price',
|
||||
'sale_price_currency',
|
||||
'sale_price_string',
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user