Browse Source

[imp] mail_digest: fallback to default website

Depending on the request  might fail
nevertheless the website should be there to be found.
Fallback to search and use it if possible for digest' site name
pull/187/head
Simone Orsi 7 years ago
parent
commit
406c450a8a
  1. 11
      mail_digest/models/mail_digest.py

11
mail_digest/models/mail_digest.py

@ -131,12 +131,19 @@ class MailDigest(models.Model):
# default to company
name = self.env.user.company_id.name
if 'website' in self.env:
# TODO: shall we make this configurable at digest or global level?
# Maybe you have a website but
# your digest msgs are not related to it at all or partially.
ws = None
try:
ws = self.env['website'].get_current_website()
name = ws.name
except RuntimeError:
# RuntimeError: object unbound -> no website request
pass
# RuntimeError: object unbound -> no website request.
# Fallback to default website if any.
ws = self.env['website'].search([], limit=1)
if ws:
name = ws.name
return name
@api.multi

Loading…
Cancel
Save