2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 04:25:42 +00:00

removes all lines consisting only of spaces

this really bothers me for some reason - nothing technical
This commit is contained in:
2021-05-06 12:11:38 +02:00
parent ecc9eec084
commit f2b0717d10
91 changed files with 494 additions and 494 deletions

View File

@ -20,7 +20,7 @@ from .serializers import BuildSerializer, BuildItemSerializer
class BuildList(generics.ListCreateAPIView):
""" API endpoint for accessing a list of Build objects.
- GET: Return list of objects (with filters)
- POST: Create a new Build object
"""
@ -65,7 +65,7 @@ class BuildList(generics.ListCreateAPIView):
queryset = BuildSerializer.annotate_queryset(queryset)
return queryset
def filter_queryset(self, queryset):
queryset = super().filter_queryset(queryset)

View File

@ -118,7 +118,7 @@ class Build(MPTTModel):
def get_absolute_url(self):
return reverse('build-detail', kwargs={'pk': self.id})
reference = models.CharField(
unique=True,
max_length=64,
@ -168,7 +168,7 @@ class Build(MPTTModel):
null=True, blank=True,
help_text=_('SalesOrder to which this build is allocated')
)
take_from = models.ForeignKey(
'stock.StockLocation',
verbose_name=_('Source Location'),
@ -177,7 +177,7 @@ class Build(MPTTModel):
null=True, blank=True,
help_text=_('Select location to take stock from for this build (leave blank to take from any stock location)')
)
destination = models.ForeignKey(
'stock.StockLocation',
verbose_name=_('Destination Location'),
@ -207,7 +207,7 @@ class Build(MPTTModel):
validators=[MinValueValidator(0)],
help_text=_('Build status code')
)
batch = models.CharField(
verbose_name=_('Batch Code'),
max_length=100,
@ -215,9 +215,9 @@ class Build(MPTTModel):
null=True,
help_text=_('Batch code for this build output')
)
creation_date = models.DateField(auto_now_add=True, editable=False, verbose_name=_('Creation Date'))
target_date = models.DateField(
null=True, blank=True,
verbose_name=_('Target completion date'),
@ -251,7 +251,7 @@ class Build(MPTTModel):
help_text=_('User responsible for this build order'),
related_name='builds_responsible',
)
link = InvenTree.fields.InvenTreeURLField(
verbose_name=_('External Link'),
blank=True, help_text=_('Link to external URL')
@ -272,7 +272,7 @@ class Build(MPTTModel):
else:
descendants = self.get_descendants(include_self=True)
Build.objects.filter(parent__pk__in=[d.pk for d in descendants])
def sub_build_count(self, cascade=True):
"""
Return the number of sub builds under this one.
@ -295,7 +295,7 @@ class Build(MPTTModel):
query = query.filter(Build.OVERDUE_FILTER)
return query.exists()
@property
def active(self):
"""
@ -441,7 +441,7 @@ class Build(MPTTModel):
# Extract the "most recent" build order reference
builds = cls.objects.exclude(reference=None)
if not builds.exists():
return None
@ -543,7 +543,7 @@ class Build(MPTTModel):
- The sub_item in the BOM line must *not* be trackable
- There is only a single stock item available (which has not already been allocated to this build)
- The stock item has an availability greater than zero
Returns:
A list object containing the StockItem objects to be allocated (and the quantities).
Each item in the list is a dict as follows:
@ -648,7 +648,7 @@ class Build(MPTTModel):
"""
Deletes all stock allocations for this build.
"""
allocations = BuildItem.objects.filter(build=self)
allocations.delete()
@ -1145,7 +1145,7 @@ class BuildItem(models.Model):
"""
self.validate_unique()
super().clean()
errors = {}
@ -1159,7 +1159,7 @@ class BuildItem(models.Model):
# Allocated part must be in the BOM for the master part
if self.stock_item.part not in self.build.part.getRequiredParts(recursive=False):
errors['stock_item'] = [_("Selected stock item not found in BOM for part '{p}'").format(p=self.build.part.full_name)]
# Allocated quantity cannot exceed available stock quantity
if self.quantity > self.stock_item.quantity:
errors['quantity'] = [_("Allocated quantity ({n}) must not exceed available quantity ({q})").format(

View File

@ -30,7 +30,7 @@ class BuildAPITest(InvenTreeAPITestCase):
'build.change',
'build.add'
]
def setUp(self):
super().setUp()
@ -54,7 +54,7 @@ class BuildListTest(BuildAPITest):
builds = self.get(self.url, data={'active': True})
self.assertEqual(len(builds.data), 1)
builds = self.get(self.url, data={'status': BuildStatus.COMPLETE})
self.assertEqual(len(builds.data), 4)

View File

@ -114,7 +114,7 @@ class BuildTest(TestCase):
# Perform some basic tests before we start the ball rolling
self.assertEqual(StockItem.objects.count(), 6)
# Build is PENDING
self.assertEqual(self.build.status, status.BuildStatus.PENDING)
@ -142,7 +142,7 @@ class BuildTest(TestCase):
# Create a BuiltItem which points to an invalid StockItem
b = BuildItem(stock_item=stock, build=self.build, quantity=10)
with self.assertRaises(ValidationError):
b.save()
@ -339,7 +339,7 @@ class BuildTest(TestCase):
self.assertTrue(self.build.can_complete)
self.build.complete_build(None)
self.assertEqual(self.build.status, status.BuildStatus.COMPLETE)
# the original BuildItem objects should have been deleted!
@ -351,12 +351,12 @@ class BuildTest(TestCase):
# This stock item has been depleted!
with self.assertRaises(StockItem.DoesNotExist):
StockItem.objects.get(pk=self.stock_1_1.pk)
# This stock item has *not* been depleted
x = StockItem.objects.get(pk=self.stock_2_1.pk)
self.assertEqual(x.quantity, 4970)
# And 10 new stock items created for the build output
outputs = StockItem.objects.filter(build=self.build)

View File

@ -251,7 +251,7 @@ class TestBuildViews(TestCase):
content = str(response.content)
self.assertIn(build.title, content)
def test_build_create(self):
""" Test the build creation view (ajax form) """
@ -260,7 +260,7 @@ class TestBuildViews(TestCase):
# Create build without specifying part
response = self.client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200)
# Create build with valid part
response = self.client.get(url, {'part': 1}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200)
@ -281,7 +281,7 @@ class TestBuildViews(TestCase):
# Get the page in editing mode
response = self.client.get(url, {'edit': 1})
self.assertEqual(response.status_code, 200)
def test_build_item_create(self):
""" Test the BuildItem creation view (ajax form) """
@ -305,7 +305,7 @@ class TestBuildViews(TestCase):
def test_build_item_edit(self):
""" Test the BuildItem edit view (ajax form) """
# TODO
# url = reverse('build-item-edit')
pass
@ -323,7 +323,7 @@ class TestBuildViews(TestCase):
# Test without confirmation
response = self.client.post(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200)
data = json.loads(response.content)
self.assertFalse(data['form_valid'])
@ -353,7 +353,7 @@ class TestBuildViews(TestCase):
# Test with confirmation, invalid location
response = self.client.post(url, {'confirm': 1, 'location': 9999}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200)
data = json.loads(response.content)
self.assertFalse(data['form_valid'])
@ -365,7 +365,7 @@ class TestBuildViews(TestCase):
# Test without confirmation
response = self.client.post(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200)
data = json.loads(response.content)
self.assertFalse(data['form_valid'])
@ -393,7 +393,7 @@ class TestBuildViews(TestCase):
data = json.loads(response.content)
self.assertFalse(data['form_valid'])
# Test with confirmation
response = self.client.post(url, {'confirm': 1}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200)

View File

@ -159,7 +159,7 @@ class BuildOutputCreate(AjaxUpdateView):
if quantity:
build = self.get_object()
# Check that requested output don't exceed build remaining quantity
maximum_output = int(build.remaining - build.incomplete_count)
if quantity > maximum_output:
@ -318,7 +318,7 @@ class BuildUnallocate(AjaxUpdateView):
form_class = forms.UnallocateBuildForm
ajax_form_title = _("Unallocate Stock")
ajax_template_name = "build/unallocate.html"
def get_initial(self):
initials = super().get_initial()
@ -341,7 +341,7 @@ class BuildUnallocate(AjaxUpdateView):
build = self.get_object()
form = self.get_form()
confirm = request.POST.get('confirm', False)
output_id = request.POST.get('output_id', None)
@ -382,7 +382,7 @@ class BuildUnallocate(AjaxUpdateView):
# Unallocate "untracked" parts
else:
build.unallocateUntracked(part=part)
data = {
'form_valid': valid,
}
@ -401,7 +401,7 @@ class BuildComplete(AjaxUpdateView):
model = Build
form_class = forms.CompleteBuildForm
ajax_form_title = _('Complete Build Order')
ajax_template_name = 'build/complete.html'
@ -437,9 +437,9 @@ class BuildOutputComplete(AjaxUpdateView):
context_object_name = "build"
ajax_form_title = _("Complete Build Output")
ajax_template_name = "build/complete_output.html"
def get_form(self):
build = self.get_object()
form = super().get_form()
@ -500,7 +500,7 @@ class BuildOutputComplete(AjaxUpdateView):
- If the part being built has a default location, pre-select that location
"""
initials = super().get_initial()
build = self.get_object()
@ -585,7 +585,7 @@ class BuildOutputComplete(AjaxUpdateView):
location=location,
status=stock_status,
)
def get_data(self):
""" Provide feedback data back to the form """
return {
@ -600,7 +600,7 @@ class BuildNotes(InvenTreeRoleMixin, UpdateView):
context_object_name = 'build'
template_name = 'build/notes.html'
model = Build
# Override the default permission role for this View
role_required = 'build.view'
@ -612,7 +612,7 @@ class BuildNotes(InvenTreeRoleMixin, UpdateView):
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
ctx['editing'] = str2bool(self.request.GET.get('edit', ''))
return ctx
@ -746,7 +746,7 @@ class BuildCreate(AjaxCreateView):
class BuildUpdate(AjaxUpdateView):
""" View for editing a Build object """
model = Build
form_class = forms.EditBuildForm
context_object_name = 'build'
@ -804,7 +804,7 @@ class BuildItemDelete(AjaxDeleteView):
ajax_template_name = 'build/delete_build_item.html'
ajax_form_title = _('Unallocate Stock')
context_object_name = 'item'
def get_data(self):
return {
'danger': _('Removed parts from build allocation')
@ -826,7 +826,7 @@ class BuildItemCreate(AjaxCreateView):
# The "part" which is being allocated to the output
part = None
available_stock = None
def get_context_data(self):
@ -906,7 +906,7 @@ class BuildItemCreate(AjaxCreateView):
if part_id:
try:
self.part = Part.objects.get(pk=part_id)
except (ValueError, Part.DoesNotExist):
pass
@ -958,7 +958,7 @@ class BuildItemCreate(AjaxCreateView):
# Reference to a StockItem object
item = None
# Reference to a Build object
build = None
@ -999,7 +999,7 @@ class BuildItemCreate(AjaxCreateView):
quantity = float(quantity)
elif required_quantity is not None:
quantity = required_quantity
item_id = self.get_param('item')
# If the request specifies a particular StockItem
@ -1035,7 +1035,7 @@ class BuildItemEdit(AjaxUpdateView):
ajax_template_name = 'build/edit_build_item.html'
form_class = forms.EditBuildItemForm
ajax_form_title = _('Edit Stock Allocation')
def get_data(self):
return {
'info': _('Updated Build Item'),
@ -1068,7 +1068,7 @@ class BuildAttachmentCreate(AjaxCreateView):
model = BuildOrderAttachment
form_class = forms.EditBuildAttachmentForm
ajax_form_title = _('Add Build Order Attachment')
def save(self, form, **kwargs):
"""
Add information on the user that uploaded the attachment
@ -1105,7 +1105,7 @@ class BuildAttachmentCreate(AjaxCreateView):
form = super().get_form()
form.fields['build'].widget = HiddenInput()
return form