Skip to content
Permalink
Browse files

Merge PR #163 into 12.0

Signed-off-by guewen
  • Loading branch information...
OCA-git-bot committed Aug 8, 2019
2 parents 4a9425e + 3e7a00e commit 380007c10e56d0063264498a0abb2debe25d89db
@@ -18,7 +18,7 @@ Available addons
addon | version | summary
--- | --- | ---
[base_export_async](base_export_async/) | 12.0.1.0.0 | Asynchronous export with job queue
[queue_job](queue_job/) | 12.0.1.0.0 | Job Queue
[queue_job](queue_job/) | 12.0.1.0.1 | Job Queue
[queue_job_cron](queue_job_cron/) | 12.0.1.0.1 | Scheduled Actions as Queue Jobs
[test_queue_job](test_queue_job/) | 12.0.1.0.0 | Queue Job Tests

@@ -2,7 +2,7 @@


{'name': 'Job Queue',
'version': '12.0.1.0.0',
'version': '12.0.1.0.1',
'author': 'Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/queue/queue_job',
'license': 'AGPL-3',
@@ -18,6 +18,7 @@
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field name="state">code</field>
<field name="code">model.autovacuum()</field>
</record>

@@ -0,0 +1,17 @@
# Copyright 2019 Versada UAB
# License AGPL-3 or later (https://www.gnu.org/licenses/agpl).

import odoo


def migrate(cr, version):
"""Set "AutoVacuum Job Queue" cron job `state` to `code."""
if not version:
return
with odoo.api.Environment.manage():
env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})
cron_job = env.ref(
'queue_job.ir_cron_autovacuum_queue_jobs',
raise_if_not_found=False)
if cron_job and cron_job.exists() and cron_job.state != 'code':
cron_job.state = 'code'
@@ -1,3 +1,4 @@
from . import test_autovacuum
from . import test_job
from . import test_job_channels
from . import test_related_actions
@@ -0,0 +1,31 @@
# Copyright 2019 Versada UAB
# License AGPL-3 or later (https://www.gnu.org/licenses/agpl).

import datetime

from odoo.tests import common

from odoo.addons.queue_job.job import Job


class TestQueueJobAutovacuumCronJob(common.TransactionCase):

def setUp(self):
super().setUp()
self.queue_job = self.env['queue.job']
self.method = self.env['test.queue.job'].testing_method
self.cron_job = self.env.ref('queue_job.ir_cron_autovacuum_queue_jobs')

def test_old_jobs_are_deleted(self):
"""
Old jobs are deleted by the autovacuum cron job.
"""
test_job = Job(self.method)
test_job.set_done(result='ok')
test_job.date_done = datetime.datetime.now() - datetime.timedelta(
days=self.queue_job._removal_interval + 1)
test_job.store()

self.cron_job.method_direct_trigger()

self.assertFalse(test_job.db_record().exists())

0 comments on commit 380007c

Please sign in to comment.
You can’t perform that action at this time.