Add 'shipment' foreign-key field to SalesOrderAllocation model

This commit is contained in:
Oliver 2021-10-25 17:42:56 +11:00
parent f00ec26efd
commit 2f7e0974b7
3 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 3.2.5 on 2021-10-25 06:42
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('order', '0053_salesordershipment'),
]
operations = [
migrations.AddField(
model_name='salesorderallocation',
name='shipment',
field=models.ForeignKey(blank=True, help_text='Sales order shipment reference', null=True, on_delete=django.db.models.deletion.CASCADE, to='order.salesordershipment', verbose_name='Shipment'),
),
]

View File

@ -973,6 +973,7 @@ class SalesOrderAllocation(models.Model):
Attributes: Attributes:
line: SalesOrderLineItem reference line: SalesOrderLineItem reference
shipment: SalesOrderShipment reference
item: StockItem reference item: StockItem reference
quantity: Quantity to take from the StockItem quantity: Quantity to take from the StockItem
@ -1028,6 +1029,11 @@ class SalesOrderAllocation(models.Model):
if self.item.serial and not self.quantity == 1: if self.item.serial and not self.quantity == 1:
errors['quantity'] = _('Quantity must be 1 for serialized stock item') errors['quantity'] = _('Quantity must be 1 for serialized stock item')
# TODO: Ensure that the "shipment" points to the same "order"!
if len(errors) > 0: if len(errors) > 0:
raise ValidationError(errors) raise ValidationError(errors)
@ -1037,6 +1043,14 @@ class SalesOrderAllocation(models.Model):
verbose_name=_('Line'), verbose_name=_('Line'),
related_name='allocations') related_name='allocations')
shipment = models.ForeignKey(
SalesOrderShipment,
on_delete=models.CASCADE,
null=True, blank=True,
verbose_name=_('Shipment'),
help_text=_('Sales order shipment reference'),
)
item = models.ForeignKey( item = models.ForeignKey(
'stock.StockItem', 'stock.StockItem',
on_delete=models.CASCADE, on_delete=models.CASCADE,

View File

@ -132,9 +132,10 @@ class RuleSet(models.Model):
'sales_order': [ 'sales_order': [
'company_company', 'company_company',
'order_salesorder', 'order_salesorder',
'order_salesorderallocation',
'order_salesorderattachment', 'order_salesorderattachment',
'order_salesorderlineitem', 'order_salesorderlineitem',
'order_salesorderallocation', 'order_salesordershipment',
] ]
} }