[FIX] marketing_campaign: make tests pass again, move partner resolution to mail_compose_message

email_template's job is to generate a mail.mail record, but it
does not care about linking it automatically to a partner
(and certainly not creating new partners) as this must be
usable for mass mailing and for marketing campaign,
and we don't want to pollute the partners database with
possibly thousands of partially fake emails

bzr revid: odo@openerp.com-20120824120102-jycs8x4vkxdmrvge
This commit is contained in:
Olivier Dony 2012-08-24 14:01:02 +02:00
parent f4c2bd121f
commit 545d7843e3
3 changed files with 9 additions and 15 deletions

View File

@ -315,7 +315,6 @@ class email_template(osv.osv):
'message_id': False,
'state': 'outgoing',
'content_subtype': 'plain',
'partner_ids': [],
}
if not template_id:
return values
@ -330,13 +329,6 @@ class email_template(osv.osv):
template.model, res_id, context=context) \
or False
# if email_to: find or create a partner
if values['email_to']:
partner_id = self.pool.get('mail.thread').message_partner_by_email(cr, uid, values['email_to'], context=context)['partner_id']
if not partner_id:
partner_id = self.pool.get('res.partner').name_create(cr, uid, values['email_to'], context=context)
values['partner_ids'] = [partner_id]
if values['body_html']:
values.update(content_subtype='html')

View File

@ -241,6 +241,14 @@ class mail_compose_message(osv.TransientModel):
subject = self.render_template(cr, uid, subject, active_model, active_id)
body = self.render_template(cr, uid, wizard.body_html, active_model, active_id)
# TODO TDE: find partner_ids
# if email_to: find or create a partner
if values['email_to']:
partner_id = self.pool.get('mail.thread').message_partner_by_email(cr, uid, values['email_to'], context=context)['partner_id']
if not partner_id:
partner_id = self.pool.get('res.partner').name_create(cr, uid, values['email_to'], context=context)
values['partner_ids'] = [partner_id]
# determine the ids we are commenting
if mass_mail_mode:
res_ids = context.get('active_ids', [])

View File

@ -42,7 +42,7 @@
record = self.browse(cr, uid, ids[0])
assert record.state == 'todo' or record.state == 'done' , 'Marketing Workitem shoud be in draft state.'
-
I check follow-up detail of first activity.
I process follow-up of first activity.
-
!python {model: marketing.campaign.workitem}: |
ids = self.search(cr, uid, [('segment_id', '=', ref('marketing_campaign_segment0')),
@ -50,12 +50,6 @@
assert ids, 'Follow-up item is not created for first activity.'
work_item_id = self.browse(cr ,uid ,ids[0] ,context)
assert work_item_id.res_name, 'Resource Name is not defined.'
-
I process follow-up of first activity.
-
!python {model: marketing.campaign.workitem}: |
ids = self.search(cr, uid, [('segment_id', '=', ref('marketing_campaign_segment0')),
('campaign_id', '=', ref('marketing_campaign_openerppartnerchannel')), ('activity_id', '=', ref('marketing_campaign_activity_0'))])
self.process(cr, uid, ids)
record = self.browse(cr, uid, ids)[0]
assert record.state == "done", "Follow-up item should be closed after process."