From 42dd7711b59d5c4774ac921123d64fdbbe1181ce Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 7 Nov 2012 12:39:25 +0100 Subject: [PATCH] [FIX] email_template: change name value and concat test bzr revid: chm@openerp.com-20121107113925-1nmjicj444nez25c --- addons/account/edi/invoice_action_data.xml | 3 +-- addons/email_template/email_template.py | 6 ++--- addons/email_template/email_template_view.xml | 2 +- addons/email_template/tests/test_mail.py | 23 ++++++++----------- .../wizard/email_template_preview_view.xml | 2 +- .../wizard/mail_compose_message.py | 4 ++-- .../edi/purchase_order_action_data.xml | 3 +-- 7 files changed, 18 insertions(+), 25 deletions(-) diff --git a/addons/account/edi/invoice_action_data.xml b/addons/account/edi/invoice_action_data.xml index e19b4df5c27..d86ebca3537 100644 --- a/addons/account/edi/invoice_action_data.xml +++ b/addons/account/edi/invoice_action_data.xml @@ -40,8 +40,7 @@ Automated Invoice Notification Mail ${object.user_id.email or object.company_id.email or 'noreply@localhost'} ${object.company_id.name} Invoice (Ref ${object.number or 'n/a' }) - ${object.partner_id.email or ''} - ${object.partner_id.id} + ${object.partner_id.id} - + diff --git a/addons/email_template/tests/test_mail.py b/addons/email_template/tests/test_mail.py index 5db90504db3..769a1c2f9f7 100644 --- a/addons/email_template/tests/test_mail.py +++ b/addons/email_template/tests/test_mail.py @@ -172,20 +172,18 @@ class test_message_compose(test_mail.TestMailMockups): self.assertEqual(set(message_bird_pids), set(partner_ids), 'mail.message on bird notified_partner_ids incorrect') - def test_10_template_email_for_composer(self): - """ Tests designed for message_post. """ - cr, uid = self.cr, self.uid + # ---------------------------------------- + # CASE4: Created message with template, test recipients + # ---------------------------------------- - # 1 - Bert Tartopoils, with email, object to send message, add his partner_id from email_to - u_a_id = self.res_users.create(cr, uid, {'name': 'Bert Tartopoils', 'email': 'raoul@raoul.fr', 'login': 'raoul'}) - p_a_id = self.res_users.browse(cr, uid, u_a_id).partner_id.id - # 2 - Carine Poilvache, with email, add his partner_id from email_to and email_to_partner + # 1 - Admin, with email, object to send message, add his partner_id from email_to + # p_a_id + # 2 - Carine Poilvache, with email, add his partner_id from email_to and email_recipients p_b_id = self.res_partner.create(cr, uid, {'name': 'Carine Poilvache', 'email': 'c@c'}) - # 3 - Dédé Grosbedon, without email, add his partner_id from email_to_partner + # 3 - Dédé Grosbedon, without email, add his partner_id from email_recipients p_c_id = self.res_partner.create(cr, uid, {'name': 'Dédé Grosbedon'}) # 4 - Truc Much, without email, add his partner_id from email_cc p_d_id = self.res_partner.create(cr, uid, {'name': 'Truc Much', 'email': 'd@d'}) - # Create template on res.users user_model_id = self.registry('ir.model').search(cr, uid, [('model', '=', 'res.users')])[0] self.email_template_id = self.email_template.create(cr, uid, { @@ -194,15 +192,12 @@ class test_message_compose(test_mail.TestMailMockups): 'subject': '${object.name}', 'body_html': '${object.login}', 'email_to': '${object.email} c@c', - 'email_to_partner': '%i,%i' % (p_b_id, p_c_id), + 'email_recipients': '%i,%i' % (p_b_id, p_c_id), 'email_cc': 'd@d' }) # patner by email + partner by id (no double) send_to = [p_a_id, p_b_id, p_c_id, p_d_id]; - # Generate messsage with default email and partner on template mail_value = self.mail_compose.generate_email_for_composer(cr, uid, self.email_template_id, u_a_id) - mail_value['partner_ids'].sort() - - self.assertEqual(mail_value['partner_ids'], send_to, 'mail.message the partner_ids list create by template is incorrect') + self.assertEqual(set(mail_value['partner_ids']), set(send_to), 'mail.message the partner_ids list create by template is incorrect') diff --git a/addons/email_template/wizard/email_template_preview_view.xml b/addons/email_template/wizard/email_template_preview_view.xml index a3dbf40ad70..8dd4bc92ba7 100644 --- a/addons/email_template/wizard/email_template_preview_view.xml +++ b/addons/email_template/wizard/email_template_preview_view.xml @@ -17,7 +17,7 @@ - + diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 49f66734ae6..1f69377cf53 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -148,7 +148,7 @@ class mail_compose_message(osv.TransientModel): mail.compose.message, transform email_cc and email_to into partner_ids """ template_values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context) # filter template values - fields = ['body', 'body_html', 'subject', 'email_to', 'email_to_partner', 'email_cc', 'attachments'] + fields = ['body', '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 @@ -159,7 +159,7 @@ class mail_compose_message(osv.TransientModel): partner_id = self.pool.get('res.partner').find_or_create(cr, uid, mail, context=context) values['partner_ids'].append(partner_id) - partner_ids = values.pop('email_to_partner', '').split(',') + partner_ids = values.pop('email_recipients', '').split(',') for partner_id in partner_ids: if partner_id: values['partner_ids'].append(int(partner_id)) diff --git a/addons/purchase/edi/purchase_order_action_data.xml b/addons/purchase/edi/purchase_order_action_data.xml index 8464c533696..fab7eeacf6c 100644 --- a/addons/purchase/edi/purchase_order_action_data.xml +++ b/addons/purchase/edi/purchase_order_action_data.xml @@ -40,8 +40,7 @@ Automated Purchase Order Notification Mail ${object.validator.email or ''} ${object.company_id.name} Order (Ref ${object.name or 'n/a' }) - ${object.partner_id.email or ''} - ${object.partner_id.id} + ${object.partner_id.id}