Skip to content
Snippets Groups Projects
Commit 26488406 authored by Thibault Delavallée's avatar Thibault Delavallée
Browse files

[REF] website: allow to configure delay before archiving visitors


RATIONALE

Event will soon gain a major update called Event Online, allowing to better
support full-online events. In order to prepare its merge, preparatory merge
are done to lessen the final diff and have a smooth integration in a stable
version (13.3).

PURPOSE

Purpose of this merge is to clean visitor synchronization and tests. It
prepares further improvements to visitor model linked to Event Online.

SPECIFICATIONS

Introduce a new configuration parameter in website allowing to set number of
days before de-activating visitors: ``website.visitor.live.days`` . It is
set to 30 days instead of 7 as before.

Purpose of extending delay is to be able to use visitor information a bit
longer in business flows. For example one could contact visitors 2 weeks
after an event to get their feedback. Adding a bit of delay allow to keep
those visitors alive a bit longer by default. Allowing to configure it gives
more flexibility to admins and deployment.

LINKS

Task ID 2290016 (improve visitor synchronization and tests)
Prepares Task ID 2252655 (main Online Event task)
Prepares Task ID 2284043 (Visitor-based track wishlist)
PR #54036

X-original-commit: f83af1d53716499dcad94f363aff609a2f8e55d9
Co-authored-by: default avatarAurélien Warnon <awa@odoo.com>
Co-authored-by: default avatarDavid Beguin <dbe@odoo.com>
Co-authored-by: default avatarThibault Delavallée <tde@odoo.com>
parent 17d83775
Branches
Tags
No related merge requests found
......@@ -241,8 +241,9 @@ class WebsiteVisitor(models.Model):
return self.sudo().create(vals)
def _cron_archive_visitors(self):
one_week_ago = datetime.now() - timedelta(days=7)
visitors_to_archive = self.env['website.visitor'].sudo().search([('last_connection_datetime', '<', one_week_ago)])
delay_days = int(self.env['ir.config_parameter'].sudo().get_param('website.visitor.live.days', 30))
deadline = datetime.now() - timedelta(days=delay_days)
visitors_to_archive = self.env['website.visitor'].sudo().search([('last_connection_datetime', '<', deadline)])
visitors_to_archive.write({'active': False})
def _update_visitor_last_visit(self):
......
......@@ -273,6 +273,8 @@ class WebsiteVisitorTests(MockVisitor, HttpCaseWithUserDemo):
def test_visitor_archive(self):
""" Test cron archiving inactive visitors and their re-activation when
authenticating an user. """
self.env['ir.config_parameter'].sudo().set_param('website.visitor.live.days', 7)
partner_demo = self.partner_demo
old_visitor = self.env['website.visitor'].create({
'lang_id': self.env.ref('base.lang_en').id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment