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/221/merge
Simone Orsi 7 years ago
committed by Jairo Llopis
parent
commit
d7412715ce
  1. 2
      mail_digest/__openerp__.py
  2. 9
      mail_digest/models/mail_digest.py

2
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': [

9
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

Loading…
Cancel
Save