Skip to content
Snippets Groups Projects
Commit f2122233 authored by Raphael Collet's avatar Raphael Collet Committed by Julien Castiaux
Browse files

[FIX] website_event_meet: autovacuum method


Convert the override of method `power_on()` to an `@autovacuum` method.

closes odoo/odoo#67145

Signed-off-by: default avatarRaphael Collet (rco) <rco@openerp.com>
parent d4210430
Branches
Tags
No related merge requests found
......@@ -4,5 +4,4 @@
from . import event_event
from . import event_type
from . import event_meeting_room
from . import ir_autovacuum
from . import website_event_menu
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import datetime
from odoo import api, fields, models
from odoo.addons.http_routing.models.ir_http import slug
......@@ -14,6 +16,8 @@ class EventMeetingRoom(models.Model):
'website.published.mixin',
]
_DELAY_CLEAN = datetime.timedelta(hours=4)
name = fields.Char("Topic", required=True, translate=True)
active = fields.Boolean('Active', default=True)
is_published = fields.Boolean(copy=True) # make the inherited field copyable
......@@ -37,3 +41,13 @@ class EventMeetingRoom(models.Model):
if not values.get("chat_room_id") and not values.get('room_name'):
values['room_name'] = 'odoo-room-%s' % (values['name'])
return super(EventMeetingRoom, self).create(values_list)
@api.autovacuum
def _archive_meeting_rooms(self):
"""Archive all non-pinned room with 0 participant if nobody has joined it for a moment."""
self.sudo().search([
("is_pinned", "=", False),
("active", "=", True),
("room_participant_count", "=", 0),
("room_last_activity", "<", fields.Datetime.now() - self._DELAY_CLEAN),
]).active = False
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import datetime
from odoo import api, models, fields
class AutoVacuum(models.AbstractModel):
_inherit = 'ir.autovacuum'
_DELAY_CLEAN = datetime.timedelta(hours=4)
@api.model
def power_on(self, *args, **kwargs):
"""Archive all non-pinned room with 0 participant if nobody has joined it for a moment."""
self.env["event.meeting.room"].sudo().search([
("is_pinned", "=", False),
("active", "=", True),
("room_participant_count", "=", 0),
("room_last_activity", "<", fields.Datetime.now() - self._DELAY_CLEAN),
]).active = False
return super(AutoVacuum, self).power_on(*args, **kwargs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment