You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.1 KiB

  1. # Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
  2. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
  3. from odoo.addons.website_mass_mailing.controllers import main
  4. from odoo.http import request, route
  5. class MassMailController(main.MassMailController):
  6. @route()
  7. def is_subscriber(self, *args, **kwargs):
  8. """Get user name too."""
  9. result = super(MassMailController, self).is_subscriber(*args, **kwargs)
  10. if request.website.user_id != request.env.user:
  11. name = request.env.user.name
  12. else:
  13. name = request.session.get("mass_mailing_name", "")
  14. return dict(result, name=name)
  15. @route()
  16. def subscribe(self, list_id, email, **post):
  17. """Store email with name in session."""
  18. result = super(MassMailController, self).subscribe(
  19. list_id, email, **post)
  20. name, email = request.env['mail.mass_mailing.contact'].sudo() \
  21. .get_name_email(email)
  22. request.session["mass_mailing_name"] = name if name != email else ""
  23. return result