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
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
# -*- 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):
|
|
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))
|