Add in sale price model

This commit is contained in:
Matthias 2021-05-04 21:51:42 +02:00
parent 5d214fc869
commit 1614c6e08a
5 changed files with 40 additions and 1 deletions

View File

@ -211,6 +211,7 @@ class EditSalesOrderLineItemForm(HelperForm):
'part',
'quantity',
'reference',
'sale_price',
'notes'
]

View 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),
),
]

View File

@ -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 = [
]

View File

@ -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',
]

View File

@ -65,7 +65,7 @@ def manage(c, cmd, pty=False):
cmd - django command to run
"""
c.run('cd {path} && python3 manage.py {cmd}'.format(
c.run('cd "{path}" && python3 manage.py {cmd}'.format(
path=managePyDir(),
cmd=cmd
), pty=pty)