[FIX]: improvements for attachment as dictionary

bzr revid: rha@tinyerp.com-20110420095458-0w53lpa10sv7wnep
This commit is contained in:
Rifakat Haradwala (Open ERP) 2011-04-20 15:24:58 +05:30
parent 190148f759
commit 96c65e3dbe
7 changed files with 11 additions and 15 deletions

View File

@ -513,7 +513,7 @@ property or property parameter."),
sub,
body,
model='calendar.attendee',
attach=attach and [('invitation.ics', attach)] or None,
attach=attach and {'invitation.ics': attach} or None,
subtype='html',
reply_to=email_from
)

View File

@ -479,12 +479,12 @@ class crm_case(object):
body = self.format_body(body)
attach_to_send = None
attach_to_send = {}
if attach:
attach_ids = self.pool.get('ir.attachment').search(cr, uid, [('res_model', '=', self._name), ('res_id', '=', case.id)])
attach_to_send = self.pool.get('ir.attachment').read(cr, uid, attach_ids, ['datas_fname', 'datas'])
attach_to_send = map(lambda x: (x['datas_fname'], base64.decodestring(x['datas'])), attach_to_send)
attach_to_send = dict(map(lambda x: (x['datas_fname'], base64.decodestring(x['datas'])), attach_to_send))
# Send an email
subject = "Reminder: [%s] %s" % (str(case.id), case.name, )

View File

@ -548,10 +548,6 @@ class event_registration(osv.osv):
body = regestration.event_id.mail_confirm
if subject or body:
email_message_obj.schedule_with_attach(cr, uid, src, email_to, subject, body, model='event.registration', email_cc=email_cc, openobject_id=regestration.id)
self.history(cr, uid, [regestration], subject, history = True, \
email=email_to, details=body, \
subject=subject, email_from=src, \
email_cc=', '.join(email_cc))
return True

View File

@ -313,7 +313,7 @@ class email_message(osv.osv):
msg_txt['message-id'] = message_id
_logger.info('Parsing Message without message-id, generating a random one: %s', message_id)
fields = msg_txt.keys()
msg['id'] = message_id
msg['message-id'] = message_id
@ -424,7 +424,7 @@ class email_message(osv.osv):
subtype=message.sub_type,
x_headers=message.headers and eval(message.headers) or {},
priority=message.priority)
res = smtp_server_obj.send_email(cr, uid,
res = smtp_server_obj.send_email(cr, uid,
msg,
mail_server_id = message.smtp_server_id.id or None,
smtp_server=smtp_server and smtp_server.smtp_host or None,

View File

@ -208,10 +208,10 @@ class email_compose_message(osv.osv_memory):
def save_to_mailbox(self, cr, uid, ids, context=None):
email_ids = []
email_message_pool = self.pool.get('email.message')
attachment = []
attachment = {}
for mail in self.browse(cr, uid, ids, context=context):
for attach in mail.attachment_ids:
attachment.append((attach.datas_fname, attach.datas))
attachment[attach.datas_fname] = attach.datas
references = False
message_id = False
if context.get('mail',False) == 'reply' and mail.message_id:

View File

@ -402,7 +402,7 @@ class survey_question_wiz(osv.osv_memory):
response_id = surv_name_wiz.read(cr, uid, context.get('sur_name_id',False))['response']
context.update({'response_id':response_id})
report = self.create_report(cr, uid, [int(survey_id)], 'report.survey.browse.response', survey_data.title,context)
attachments = []
attachments = {}
file = open(addons.get_module_resource('survey', 'report') + survey_data.title + ".pdf")
file_data = ""
while 1:
@ -411,7 +411,7 @@ class survey_question_wiz(osv.osv_memory):
if not line:
break
attachments.append((survey_data.title + ".pdf",file_data))
attachments[survey_data.title + ".pdf"] = file_data
file.close()
os.remove(addons.get_module_resource('survey', 'report') + survey_data.title + ".pdf")
user_email = False

View File

@ -119,7 +119,7 @@ class survey_send_invitation(osv.osv_memory):
res_user = ""
user_exists = False
new_user = []
attachments = []
attachments = {}
current_sur = survey_ref.browse(cr, uid, context.get('active_id'), context=context)
exist_user = current_sur.invited_user_ids
if exist_user:
@ -134,8 +134,8 @@ class survey_send_invitation(osv.osv_memory):
file_data += line
if not line:
break
attachments.append((id.title +".pdf",file_data))
file.close()
attachments[id.title +".pdf"] = file_data
os.remove(addons.get_module_resource('survey', 'report') + id.title +".pdf")
for partner in self.pool.get('res.partner').browse(cr, uid, partner_ids):