[FIX] email_template: void value in partner_ids when generating tmeplate does not erase wizard value anymore.
bzr revid: tde@openerp.com-20130308091156-ytw5k4y5w321705f
This commit is contained in:
@@ -70,6 +70,7 @@ class mail_compose_message(osv.TransientModel):
|
||||
elif template_id:
|
||||
# FIXME odo: change the mail generation to avoid attachment duplication
|
||||
values = self.generate_email_for_composer(cr, uid, template_id, res_id, context=context)
|
||||
print values.get('partner_ids')
|
||||
# transform attachments into attachment_ids
|
||||
values['attachment_ids'] = []
|
||||
ir_attach_obj = self.pool.get('ir.attachment')
|
||||
@@ -80,7 +81,7 @@ class mail_compose_message(osv.TransientModel):
|
||||
'datas_fname': attach_fname,
|
||||
'res_model': model,
|
||||
'res_id': res_id,
|
||||
'type': 'binary', # override default_type from context, possibly meant for another model!
|
||||
'type': 'binary', # override default_type from context, possibly meant for another model!
|
||||
}
|
||||
values['attachment_ids'].append(ir_attach_obj.create(cr, uid, data_attach, context=context))
|
||||
else:
|
||||
@@ -125,19 +126,22 @@ class mail_compose_message(osv.TransientModel):
|
||||
fields = ['body_html', 'subject', 'email_to', 'email_recipients', 'email_cc', 'attachments']
|
||||
values = dict((field, template_values[field]) for field in fields if template_values.get(field))
|
||||
values['body'] = values.pop('body_html', '')
|
||||
# transform email_to, email_cc into partner_ids
|
||||
values['partner_ids'] = []
|
||||
|
||||
# transform email_to, email_cc into partner_ids
|
||||
partner_ids = set()
|
||||
mails = tools.email_split(values.pop('email_to', '') + ' ' + values.pop('email_cc', ''))
|
||||
for mail in mails:
|
||||
partner_id = self.pool.get('res.partner').find_or_create(cr, uid, mail, context=context)
|
||||
values['partner_ids'].append(partner_id)
|
||||
partner_ids.add(partner_id)
|
||||
email_recipients = values.pop('email_recipients', '')
|
||||
if email_recipients:
|
||||
for partner_id in email_recipients.split(','):
|
||||
values['partner_ids'].append(int(partner_id))
|
||||
|
||||
values['partner_ids'] = list(set(values['partner_ids']))
|
||||
if partner_id: # placeholders could generate '', 3, 2 due to some empty field values
|
||||
partner_ids.add(int(partner_id))
|
||||
# legacy template behavior: void values do not erase existing values and the
|
||||
# related key is removed from the values dict
|
||||
if partner_ids:
|
||||
values['partner_ids'] = [(6, 0, list(partner_ids))]
|
||||
|
||||
return values
|
||||
|
||||
|
||||
Reference in New Issue
Block a user