diff --git a/apps/establishment/management/commands/update_employee.py b/apps/establishment/management/commands/update_employee.py index 41831f0d..888c121e 100644 --- a/apps/establishment/management/commands/update_employee.py +++ b/apps/establishment/management/commands/update_employee.py @@ -1,9 +1,12 @@ from django.core.management.base import BaseCommand from django.db import connections from establishment.management.commands.add_position import namedtuplefetchall -from establishment.models import Employee +from establishment.models import Employee, EstablishmentEmployee +from django.utils import timezone +from django.db.models import Q from tqdm import tqdm + class Command(BaseCommand): help = 'Add employee from old db to new db.' @@ -30,4 +33,7 @@ class Command(BaseCommand): for e in tqdm(self.employees_sql()): empl = Employee.objects.filter(old_id=e.profile_id).update(name=e.name) + EstablishmentEmployee.objects.filter(from_date__isnull=True, old_id__isnull=True)\ + .update(from_date=timezone.now()-timezone.timedelta(days=1)) + self.stdout.write(self.style.WARNING(f'Update employee name objects.'))