novacode-nl / odoo-celery

Odoo & Celery integration
GNU Lesser General Public License v3.0
42 stars 45 forks source link

[ADD] A new task scheduling feature, handled by cron. #26

Closed antonioburic closed 4 years ago

antonioburic commented 4 years ago

Adding new task scheduling features, which enables the tasks to be scheduled at certain days of the week and/or certain hourly intervals of the day.

It adds a new tab to the celery.task.setting form:

image

If the Schedule? flag is enabled for a certain type of a task, those tasks will be put to the Scheduled state and will not be sent to the MQ. Instead, when the scheduled_date comes, a cron job handles them and actually sends them to the queue.

TODO: I'm testing it at the moment and plan to add unit tests for this part, mainly to check the datetime scheduling logic in the check_schedule_needed method which is a bit 'heavy' already (but the few test cases I've tried so far work correctly). I will update the PR (and port to v12 once ready).