You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
989 B

11 years ago
11 years ago
11 years ago
11 years ago
  1. # -*- coding: utf-8 -*-
  2. import re
  3. from openerp import SUPERUSER_ID
  4. from openerp.osv import fields, osv
  5. import logging
  6. _logger = logging.getLogger(__name__)
  7. class mail_mail(osv.osv):
  8. _inherit = "mail.mail"
  9. def send(self, cr, uid, ids, context=None, **kwargs):
  10. catchall_alias = self.pool['ir.config_parameter'].get_param(cr, uid, "mail.catchall.alias_from", context=context)
  11. catchall_domain = self.pool['ir.config_parameter'].get_param(cr, uid, "mail.catchall.domain", context=context)
  12. correct_email_from = '@%s>?\s*$'%catchall_domain
  13. default_email_from = '%s@%s' % (catchall_alias, catchall_domain)
  14. for mail in self.browse(cr, SUPERUSER_ID, ids, context=context):
  15. email_from = mail.email_from
  16. if not email_from or re.search(correct_email_from, email_from) is None:
  17. mail.write({'email_from': default_email_from})
  18. return super(mail_mail, self).send(cr, uid, ids, context=context, **kwargs)