diff options
Diffstat (limited to 'servo')
-rw-r--r-- | servo/management/commands/cleanorders.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/servo/management/commands/cleanorders.py b/servo/management/commands/cleanorders.py new file mode 100644 index 0000000..118b708 --- /dev/null +++ b/servo/management/commands/cleanorders.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from django.core.management.base import BaseCommand + +from servo.models import Order + + +class Command(BaseCommand): + + help = "Deletes empty service orders" + + def handle(self, *args, **options): + orders = Order.objects.filter(customer=None, + devices=None, + note=None, + serviceorderitem=None) + count = orders.count() + orders.delete() + print('%d orders deleted' % count) |