diff --git a/apps/tasks/migrations/0012_alter_tasklog_expense_group.py b/apps/tasks/migrations/0012_alter_tasklog_expense_group.py deleted file mode 100644 index 2f60f426..00000000 --- a/apps/tasks/migrations/0012_alter_tasklog_expense_group.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 3.2.14 on 2024-11-14 10:33 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('fyle', '0038_expensegroup_export_url'), - ('tasks', '0011_error_repetition_count'), - ] - - operations = [ - migrations.AlterField( - model_name='tasklog', - name='expense_group', - field=models.ForeignKey(help_text='Reference to Expense group', null=True, on_delete=django.db.models.deletion.PROTECT, to='fyle.expensegroup', unique=True), - ), - ] diff --git a/apps/tasks/models.py b/apps/tasks/models.py index 7e312d0c..8ed9087e 100644 --- a/apps/tasks/models.py +++ b/apps/tasks/models.py @@ -20,7 +20,7 @@ class TaskLog(models.Model): workspace = models.ForeignKey(Workspace, on_delete=models.PROTECT, help_text='Reference to Workspace model') type = models.CharField(max_length=50, help_text='Task type (FETCH_EXPENSES / CREATE_BILL / CREATE_CHECK)') task_id = models.CharField(max_length=255, null=True, help_text='Django Q task reference') - expense_group = models.ForeignKey(ExpenseGroup, on_delete=models.PROTECT, null=True, help_text='Reference to Expense group', unique=True) + expense_group = models.ForeignKey(ExpenseGroup, on_delete=models.PROTECT, null=True, help_text='Reference to Expense group') bill = models.ForeignKey(Bill, on_delete=models.PROTECT, help_text='Reference to Bill', null=True) cheque = models.ForeignKey(Cheque, on_delete=models.PROTECT, help_text='Reference to Cheque', null=True) journal_entry = models.ForeignKey(JournalEntry, on_delete=models.PROTECT, help_text='Reference to journal_entry', null=True) diff --git a/apps/workspaces/tasks.py b/apps/workspaces/tasks.py index 29ecfbfa..9fd6d230 100644 --- a/apps/workspaces/tasks.py +++ b/apps/workspaces/tasks.py @@ -1,5 +1,5 @@ import logging -from datetime import date, datetime, timedelta +from datetime import date, datetime from typing import List from django.conf import settings @@ -65,15 +65,7 @@ def schedule_sync(workspace_id: int, schedule_enabled: bool, hours: int, email_a if email_added: ws_schedule.additional_email_options.append(email_added) - schedule, _ = Schedule.objects.update_or_create( - func='apps.workspaces.tasks.run_sync_schedule', - args='{}'.format(workspace_id), - defaults={ - 'schedule_type': Schedule.MINUTES, - 'minutes': hours * 60, - 'next_run': datetime.now() + timedelta(hours=hours), - } - ) + schedule, _ = Schedule.objects.update_or_create(func='apps.workspaces.tasks.run_sync_schedule', args='{}'.format(workspace_id), defaults={'schedule_type': Schedule.MINUTES, 'minutes': hours * 60, 'next_run': datetime.now()}) ws_schedule.schedule = schedule