#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
#   Author  :   zhangxiaolin
#   E-mail  :   petelin1120@gmail.com
#   Date    :   17/3/14 14:42
#   Desc    :   转移 serviceregister.add_num 到 serviceregisteritem.stock_add_num 中

from api.models.service import *
from django.core.management import BaseCommand


class Command(BaseCommand):

    def handle(self, *args, **options):
        registeritems = ServiceRegisterItem.objects.filter(is_delete=False,
                                                           stock_add_num=0).exclude(service_register__add_num=0)

        for ritem in registeritems:
            ritem.stock_add_num = ritem.service_register.add_num
            ritem.save()

