From d7412715ce151290974c04ce1750044ed6d3466b Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Fri, 24 Nov 2017 13:25:49 +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/__openerp__.py | 2 +- mail_digest/models/mail_digest.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mail_digest/__openerp__.py b/mail_digest/__openerp__.py index 169b9c5d..75f6c7ad 100644 --- a/mail_digest/__openerp__.py +++ b/mail_digest/__openerp__.py @@ -5,7 +5,7 @@ { 'name': 'Mail digest', 'summary': """Basic digest mail handling.""", - 'version': '9.0.1.0.0', + 'version': '9.0.1.0.1', 'license': 'AGPL-3', 'author': 'Camptocamp,Odoo Community Association (OCA)', 'depends': [ diff --git a/mail_digest/models/mail_digest.py b/mail_digest/models/mail_digest.py index 45739bcf..095a0ac7 100644 --- a/mail_digest/models/mail_digest.py +++ b/mail_digest/models/mail_digest.py @@ -94,11 +94,16 @@ 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() except RuntimeError: - # RuntimeError: object unbound -> no website request - ws = None + # 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