From 406c450a8ab6874851c79fd59e2028edf17c5bc7 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Fri, 12 Jan 2018 15:46:57 +0100 Subject: [PATCH] [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 --- mail_digest/models/mail_digest.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mail_digest/models/mail_digest.py b/mail_digest/models/mail_digest.py index 66474396..6d670e67 100644 --- a/mail_digest/models/mail_digest.py +++ b/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