Browse Source

[RFR] Override hook

pull/1317/merge
Stefan Rijnhart 9 years ago
committed by Holger Brunn
parent
commit
f5305df14b
  1. 15
      fetchmail_attach_from_folder/wizard/attach_mail_manually.py

15
fetchmail_attach_from_folder/wizard/attach_mail_manually.py

@ -17,6 +17,14 @@ class AttachMailManually(models.TransientModel):
mail_ids = fields.One2many(
'fetchmail.attach.mail.manually.mail', 'wizard_id', 'Emails')
@api.model
def _prepare_mail(self, folder, msgid, mail_message):
return {
'msgid': msgid,
'subject': mail_message.get('subject', ''),
'date': mail_message.get('date', ''),
'object_id': '%s,-1' % folder.model_id.model}
@api.model
def default_get(self, fields_list):
defaults = super(AttachMailManually, self).default_get(fields_list)
@ -31,11 +39,8 @@ class AttachMailManually(models.TransientModel):
msgids = folder.get_msgids(connection, criteria)
for msgid in msgids[0].split():
mail_message, message_org = folder.fetch_msg(connection, msgid)
defaults['mail_ids'].append((0, 0, {
'msgid': msgid,
'subject': mail_message.get('subject', ''),
'date': mail_message.get('date', ''),
'object_id': '%s,-1' % folder.model_id.model}))
defaults['mail_ids'].append(
(0, 0, self._prepare_mail(folder, msgid, mail_message)))
connection.close()
return defaults

Loading…
Cancel
Save