[FIX] mail.compose.message: files can be attach to a document and send by mail

bzr revid: chm@openerp.com-20121116111226-0xvb262et94k7omh
This commit is contained in:
Christophe Matthieu 2012-11-16 12:12:26 +01:00
parent 3c8626efbb
commit c1192ec3a0
2 changed files with 12 additions and 4 deletions

View File

@ -95,6 +95,14 @@ class mail_compose_message(osv.TransientModel):
# transform attachments into attachment_ids
values['attachment_ids'] = []
ir_attach_obj = self.pool.get('ir.attachment')
# filter context values
context_attach = dict({
'tz': context.get('tz'),
'lang': context.get('lang'),
'bin_raw': context.get('bin_raw'),
})
for attach_fname, attach_datas in values.pop('attachments', []):
data_attach = {
'name': attach_fname,
@ -103,7 +111,7 @@ class mail_compose_message(osv.TransientModel):
'res_model': model,
'res_id': res_id,
}
values['attachment_ids'].append(ir_attach_obj.create(cr, uid, data_attach, context=context))
values['attachment_ids'].append(ir_attach_obj.create(cr, uid, data_attach, context=context_attach))
else:
values = self.default_get(cr, uid, ['body', 'body_html', 'subject', 'partner_ids', 'attachment_ids'], context=context)

View File

@ -102,9 +102,9 @@ class mail_compose_message(osv.TransientModel):
'partner_ids': fields.many2many('res.partner',
'mail_compose_message_res_partner_rel',
'wizard_id', 'partner_id', 'Additional contacts'),
'attachment_ids': fields.one2many('ir.attachment', 'res_id',
domain=lambda self: [('res_model', '=', self._name)],
string='Attachments'),
'attachment_ids': fields.many2many('ir.attachment',
'mail_compose_message_ir_attachments_rel',
'wizard_id', 'attachment_id', 'Attachments'),
'filter_id': fields.many2one('ir.filters', 'Filters'),
'body_text': fields.text('Plain-text Contents'),
'content_subtype': fields.char('Message content subtype', size=32, readonly=1,