summaryrefslogtreecommitdiff
path: root/addons/digest/controllers
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2020-05-28 10:38:32 +0000
committerThibault Delavallée <tde@odoo.com>2020-06-04 15:19:29 +0000
commit14abd4fdf714ce280ab07998073328eb4d76bc09 (patch)
treedc54db620e6ea76ed2ab22d420a308c082fb31cd /addons/digest/controllers
parentadd1a04a9451a684b5503d92a07f0ddf37f6921e (diff)
[IMP] digest: improve digest by adding daily sending and preferences
PURPOSE Make digest email and tips more appealing. The goals of these tips are * to encourage the adoption of other apps (Did you know ?); * to make Odoo look more fun (Fun tips and tricks, young and dynamic style); * to show social proof and increase trust (emphasis on already existing projects / customers to); SPECIFICATIONS Add a daily digest option, allowing to send digests on a daily basis. It will be the default settings to help users coming back to odoo. Add a slowdown heuristics. If not any user targeted by a daily digest logs himself within 3 days, digest is slowed down to a weekly setting to avoid spam. Add a preference section in template, to hold notably links to some configuration steps sent mainly for admin / CEOs. Improve access on models. LINKS Task ID 2197417 PR odoo/odoo#51619
Diffstat (limited to 'addons/digest/controllers')
-rw-r--r--addons/digest/controllers/portal.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/addons/digest/controllers/portal.py b/addons/digest/controllers/portal.py
index 0e7f8a5b4e5..451956a7bfa 100644
--- a/addons/digest/controllers/portal.py
+++ b/addons/digest/controllers/portal.py
@@ -1,15 +1,36 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from werkzeug.exceptions import Forbidden
+from werkzeug.urls import url_encode
+
+from odoo import _
from odoo.http import Controller, request, route
class DigestController(Controller):
@route('/digest/<int:digest_id>/unsubscribe', type='http', website=True, auth='user')
- def digest_unsubscribe(self, digest_id, **post):
- digest = request.env['digest.digest'].sudo().browse(digest_id)
+ def digest_unsubscribe(self, digest_id):
+ digest = request.env['digest.digest'].browse(digest_id).exists()
digest.action_unsubcribe()
return request.render('digest.portal_digest_unsubscribed', {
'digest': digest,
})
+
+ @route('/digest/<int:digest_id>/set_periodicity', type='http', website=True, auth='user')
+ def digest_set_periodicity(self, digest_id, periodicity='weekly'):
+ if not request.env.user.has_group('base.group_erp_manager'):
+ raise Forbidden()
+ if periodicity not in ('daily', 'weekly', 'monthly', 'quarterly'):
+ raise ValueError(_('Invalid periodicity set on digest'))
+
+ digest = request.env['digest.digest'].browse(digest_id).exists()
+ digest.action_set_periodicity(periodicity)
+
+ url_params = {
+ 'model': digest._name,
+ 'id': digest.id,
+ 'active_id': digest.id,
+ }
+ return request.redirect('/web?#%s' % url_encode(url_params))