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.

28 lines
1.1 KiB

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