Browse Source

[REF] update email_from at mail.mail::send

pull/1/head
Ivan Yelizariev 10 years ago
parent
commit
06bc4446a5
  1. 21
      mail_fix_553.py

21
mail_fix_553.py

@ -9,25 +9,16 @@ _logger = logging.getLogger(__name__)
class mail_mail(osv.osv): class mail_mail(osv.osv):
_inherit = "mail.mail" _inherit = "mail.mail"
def _fix_email_from(cr, uid, email_from):
def send(self, cr, uid, ids, context=None, **kwargs):
catchall_alias = self.pool['ir.config_parameter'].get_param(cr, uid, "mail.catchall.alias_from", context=context) catchall_alias = self.pool['ir.config_parameter'].get_param(cr, uid, "mail.catchall.alias_from", context=context)
catchall_domain = self.pool['ir.config_parameter'].get_param(cr, uid, "mail.catchall.domain", context=context) catchall_domain = self.pool['ir.config_parameter'].get_param(cr, uid, "mail.catchall.domain", context=context)
correct_email_from = '@%s>?\s*$'%catchall_domain correct_email_from = '@%s>?\s*$'%catchall_domain
default_email_from = '%s@%s' % (catchall_alias, catchall_domain) default_email_from = '%s@%s' % (catchall_alias, catchall_domain)
if not email_from or re.search(correct_email_from, email_from) is None:
email_from = default_email_from
return email_from
def create(self, cr, uid, values, context=None):
if 'email_from' in values:
values['email_from'] = self._fix_email_from(cr, uid, values['email_from'])
return super(mail_mail, self).create(cr, uid, values, context=context)
def write(self, cr, uid, ids, values, context=None):
if 'email_from' in values:
values['email_from'] = self._fix_email_from(cr, uid, values['email_from'])
return super(mail_mail, self).write(cr, uid, ids, values, context=context)
for mail in self.browse(cr, SUPERUSER_ID, ids, context=context):
email_from = mail.email_from
if not email_from or re.search(correct_email_from, email_from) is None:
mail.email_from = default_email_from
return super(mail_mail, self).send(cr, uid, ids, context=context, **kwargs)
Loading…
Cancel
Save