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/228/head
Simone Orsi 7 years ago
committed by Holger Brunn
parent
commit
6a76103814
  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 # default to company
name = self.env.user.company_id.name name = self.env.user.company_id.name
if 'website' in self.env: 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: try:
ws = self.env['website'].get_current_website() ws = self.env['website'].get_current_website()
name = ws.name name = ws.name
except RuntimeError: 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 return name
@api.multi @api.multi

Loading…
Cancel
Save