mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-01 03:00:54 +00:00
Code style improvements (#4683)
* fix list comps * mopre comp fixes * reduce computing cost on any() calls * add bugbear * check for clean imports * only allow limited relative imports * fix notification method lookup * fix notification method assigement * rewrite assigment * fix upstream changes to new style * fix upstream change to new coding style
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
from django.contrib import admin
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
import import_export.widgets as widgets
|
||||
from import_export import widgets
|
||||
from import_export.admin import ImportExportModelAdmin
|
||||
from import_export.fields import Field
|
||||
|
||||
|
@ -1118,7 +1118,7 @@ class StockItemTestResultList(ListCreateDestroyAPIView):
|
||||
# Note that this function is recursive!
|
||||
installed_items = item.get_installed_items(cascade=True)
|
||||
|
||||
items += [it for it in installed_items]
|
||||
items += list(installed_items)
|
||||
|
||||
queryset = queryset.filter(stock_item__in=items)
|
||||
|
||||
|
@ -71,14 +71,15 @@ class StockLocation(InvenTreeBarcodeMixin, MetadataMixin, InvenTreeTree):
|
||||
|
||||
for child_location in self.children.all():
|
||||
if kwargs.get('delete_sub_locations', False):
|
||||
child_location.delete_recursive(**dict(delete_sub_locations=True,
|
||||
delete_stock_items=delete_stock_items,
|
||||
parent_location=parent_location))
|
||||
child_location.delete_recursive(**{
|
||||
"delete_sub_locations": True,
|
||||
"delete_stock_items": delete_stock_items,
|
||||
"parent_location": parent_location})
|
||||
else:
|
||||
child_location.parent = parent_location
|
||||
child_location.save()
|
||||
|
||||
super().delete(*args, **dict())
|
||||
super().delete(*args, **{})
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""Custom model deletion routine, which updates any child locations or items.
|
||||
@ -87,9 +88,10 @@ class StockLocation(InvenTreeBarcodeMixin, MetadataMixin, InvenTreeTree):
|
||||
"""
|
||||
with transaction.atomic():
|
||||
|
||||
self.delete_recursive(**dict(delete_stock_items=kwargs.get('delete_stock_items', False),
|
||||
delete_sub_locations=kwargs.get('delete_sub_locations', False),
|
||||
parent_category=self.parent))
|
||||
self.delete_recursive(**{
|
||||
"delete_stock_items": kwargs.get('delete_stock_items', False),
|
||||
"delete_sub_locations": kwargs.get('delete_sub_locations', False),
|
||||
"parent_category": self.parent})
|
||||
|
||||
if self.parent is not None:
|
||||
# Partially rebuild the tree (cheaper than a complete rebuild)
|
||||
|
@ -110,7 +110,7 @@ class TestScheduledForDeletionMigration(MigratorTestCase):
|
||||
scheduled_for_deletion=True,
|
||||
)
|
||||
|
||||
for ii in range(3):
|
||||
for _ in range(3):
|
||||
StockItem.objects.create(
|
||||
part=part,
|
||||
quantity=200,
|
||||
|
Reference in New Issue
Block a user