Unit test fixes

This commit is contained in:
Oliver Walters 2021-05-11 22:26:03 +10:00
parent a1203aa1e5
commit 93e6eb6dc7
4 changed files with 28 additions and 17 deletions

View File

@ -370,13 +370,13 @@ class PurchaseOrder(Order):
tracking_info = {
'status': status,
'purchaseorder': self.pk,
}
stock.add_tracking_entry(
StockHistoryCode.RECEIVED_AGAINST_PURCHASE_ORDER,
user,
notes=notes,
url=self.get_absolute_url(),
deltas=tracking_info,
location=location,
purchaseorder=self,

View File

@ -136,7 +136,6 @@ def update_history(apps, schema_editor):
location = list(matches)[0]
deltas['location'] = location.pk
deltas['location_path'] = location._path
else:
print(f"No location match: '{text}'")

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2 on 2021-05-11 11:51
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('stock', '0061_auto_20210511_0911'),
]
operations = [
migrations.AlterField(
model_name='stockitemtracking',
name='notes',
field=models.CharField(blank=True, help_text='Entry notes', max_length=512, null=True, verbose_name='Notes'),
),
migrations.AlterField(
model_name='stockitemtracking',
name='title',
field=models.CharField(blank=True, help_text='Tracking entry title', max_length=250, null=True, verbose_name='Title'),
),
]

View File

@ -805,9 +805,8 @@ class StockItem(MPTTModel):
StockHistoryCode.INSTALLED_INTO_ASSEMBLY,
user,
notes=notes,
url=self.get_absolute_url(),
deltas={
'assembly': self.pk,
'stockitem': self.pk,
}
)
@ -816,7 +815,6 @@ class StockItem(MPTTModel):
StockHistoryCode.INSTALLED_CHILD_ITEM,
user,
notes=notes,
url=stock_item.get_absolute_url(),
deltas={
'stockitem': stock_item.pk,
}
@ -847,7 +845,6 @@ class StockItem(MPTTModel):
'stockitem': self.pk,
},
notes=notes,
url=self.get_absolute_url(),
)
tracking_info = {
@ -923,7 +920,7 @@ class StockItem(MPTTModel):
def has_tracking_info(self):
return self.tracking_info_count > 0
def add_tracking_entry(self, entry_type, user, deltas={}, notes='', url='', **kwargs):
def add_tracking_entry(self, entry_type, user, deltas={}, notes='', **kwargs):
"""
Add a history tracking entry for this StockItem
@ -940,13 +937,6 @@ class StockItem(MPTTModel):
if location:
deltas['location'] = location.id
deltas['location_path'] = location.pathstring
# Has a PurchaseOrder been specified?
po = kwargs.get('purchaseorder', None)
if po:
deltas['purchaseorder'] = po.id
# Quantity specified?
quantity = kwargs.get('quantity', None)
@ -961,7 +951,6 @@ class StockItem(MPTTModel):
date=datetime.now(),
notes=notes,
deltas=deltas,
link=url,
system=True
)
@ -1639,14 +1628,14 @@ class StockItemTracking(models.Model):
date = models.DateTimeField(auto_now_add=True, editable=False)
title = models.CharField(
blank=True,
blank=True, null=True,
max_length=250,
verbose_name=_('Title'),
help_text=_('Tracking entry title')
)
notes = models.CharField(
blank=True,
blank=True, null=True,
max_length=512,
verbose_name=_('Notes'),
help_text=_('Entry notes')