[FIX] website_event_meet: autovacuum method
Convert the override of method `power_on()` to an `@autovacuum` method. closes odoo/odoo#67178 X-original-commit: f212223305a4d1da0f01f008c3874a72945fcae0 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
committed by
Julien Castiaux
parent
b6762a0b41
commit
08d4707fe3
@@ -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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# -*- 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
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
# -*- 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)
|
||||
Reference in New Issue
Block a user