From 858e2044b8ea51a47a863e1f316db24f7d57a648 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Thu, 19 Nov 2015 22:56:06 +0200 Subject: Added clean orders --- servo/management/commands/cleanorders.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 servo/management/commands/cleanorders.py 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) -- cgit v1.2.3