[IMP] event: add a cron that clean the event pipeline
The cron will move every ended events in the next "ended stage" We inherit from `ir.autovacuum`, so the method `power_on` is called one time per day. Task #2088538
This commit is contained in:
committed by
Thibault Delavallée
parent
bd61b6cd38
commit
a321963d19
@@ -6,3 +6,4 @@ from . import event_mail
|
||||
from . import event_stage
|
||||
from . import res_config_settings
|
||||
from . import res_partner
|
||||
from . import ir_autovacuum
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, models, fields
|
||||
|
||||
|
||||
class AutoVacuum(models.AbstractModel):
|
||||
_inherit = 'ir.autovacuum'
|
||||
|
||||
@api.model
|
||||
def power_on(self, *args, **kwargs):
|
||||
"""
|
||||
Cron which drags all events which end date is < now (= passed)
|
||||
into the first next (by sequence) stage defined as "Ended"
|
||||
(if they are not already in an ended stage)
|
||||
"""
|
||||
ended_events = self.env['event.event'].search([('date_end', '<', fields.Datetime.now()), ('stage_id.pipe_end', '=', False)])
|
||||
|
||||
if ended_events:
|
||||
ended_events.action_set_done()
|
||||
|
||||
return super(AutoVacuum, self).power_on(*args, **kwargs)
|
||||
Reference in New Issue
Block a user