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.

23 lines
927 B

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