From 22afd0cefdc3f5547757ce5ae79c3839cee61e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 25 Feb 2013 11:19:18 +0100 Subject: [PATCH] [IMP] email_template: renamed email_recipients field to partner_to, in order to have a name that means something. bzr revid: tde@openerp.com-20130225101918-khyd6qkvtsyr2wi3 --- addons/account/edi/invoice_action_data.xml | 2 +- addons/crm/crm_data.xml | 5 ++--- addons/email_template/email_template.py | 8 +++++--- addons/email_template/email_template_view.xml | 4 ++-- addons/email_template/tests/test_mail.py | 6 +++--- .../wizard/email_template_preview_view.xml | 2 +- addons/email_template/wizard/mail_compose_message.py | 10 +++++----- addons/portal_sale/portal_sale_data.xml | 4 ++-- addons/purchase/edi/purchase_order_action_data.xml | 2 +- addons/sale/edi/sale_order_action_data.xml | 2 +- 10 files changed, 23 insertions(+), 22 deletions(-) diff --git a/addons/account/edi/invoice_action_data.xml b/addons/account/edi/invoice_action_data.xml index 18ac71f55ce..b3fe8362b8b 100644 --- a/addons/account/edi/invoice_action_data.xml +++ b/addons/account/edi/invoice_action_data.xml @@ -24,7 +24,7 @@ Invoice - Send by Email ${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.id} + ${object.partner_id.id} diff --git a/addons/crm/crm_data.xml b/addons/crm/crm_data.xml index 3726c744b2e..e53d8e73599 100644 --- a/addons/crm/crm_data.xml +++ b/addons/crm/crm_data.xml @@ -80,11 +80,10 @@ basis for email recipients, name and to ease the definition of a further elaborated template. --> Opportunity - Send Emails - ${object.user_id.email or ''} - Opportunity ${object.name | h}) + ${object.name} - ${object.partner_id.id} + ${object.partner_id.id} diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index 743384059b4..6778f8cf752 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -143,7 +143,9 @@ class email_template(osv.osv): 'subject': fields.char('Subject', translate=True, help="Subject (placeholders may be used here)",), 'email_from': fields.char('From', help="Sender address (placeholders may be used here)"), 'email_to': fields.char('To (Emails)', help="Comma-separated recipient addresses (placeholders may be used here)"), - 'email_recipients': fields.char('To (Partners)', help="Comma-separated ids of recipient partners (placeholders may be used here)"), + 'partner_to': fields.char('To (Partners)', + help="Comma-separated ids of recipient partners (placeholders may be used here)", + oldname='email_recipients'), 'email_cc': fields.char('Cc', help="Carbon copy recipients (placeholders may be used here)"), 'reply_to': fields.char('Reply-To', help="Preferred response address (placeholders may be used here)"), 'mail_server_id': fields.many2one('ir.mail_server', 'Outgoing Mail Server', readonly=False, @@ -311,7 +313,7 @@ class email_template(osv.osv): template = self.get_email_template(cr, uid, template_id, res_id, context) values = {} for field in ['subject', 'body_html', 'email_from', - 'email_to', 'email_recipients', 'email_cc', 'reply_to']: + 'email_to', 'partner_to', 'email_cc', 'reply_to']: values[field] = self.render_template(cr, uid, getattr(template, field), template.model, res_id, context=context) \ or False @@ -371,7 +373,7 @@ class email_template(osv.osv): values = self.generate_email(cr, uid, template_id, res_id, context=context) assert 'email_from' in values, 'email_from is missing or empty after template rendering, send_mail() cannot proceed' attachments = values.pop('attachments') or {} - del values['email_recipients'] # TODO Properly use them. + del values['partner_to'] # TODO Properly use them. msg_id = mail_mail.create(cr, uid, values, context=context) # link attachments attachment_ids = [] diff --git a/addons/email_template/email_template_view.xml b/addons/email_template/email_template_view.xml index 4cddb31c8e1..5e1d7b931da 100644 --- a/addons/email_template/email_template_view.xml +++ b/addons/email_template/email_template_view.xml @@ -30,7 +30,7 @@ - + @@ -78,7 +78,7 @@ - + diff --git a/addons/email_template/tests/test_mail.py b/addons/email_template/tests/test_mail.py index b87b6d63000..c3ee385cf11 100644 --- a/addons/email_template/tests/test_mail.py +++ b/addons/email_template/tests/test_mail.py @@ -170,20 +170,20 @@ class test_message_compose(TestMailBase): self.assertEqual(set(message_bird_pids), set(partner_ids), 'mail.message on bird notified_partner_ids incorrect') # ---------------------------------------- - # CASE4: test newly introduced email_recipients field + # CASE4: test newly introduced partner_to field # ---------------------------------------- # get already-created partners back p_b_id = self.res_partner.search(cr, uid, [('email', '=', 'b@b.b')])[0] p_c_id = self.res_partner.search(cr, uid, [('email', '=', 'c@c.c')])[0] p_d_id = self.res_partner.search(cr, uid, [('email', '=', 'd@d.d')])[0] - # modify template: use email_recipients, use template and email address in email_to to test all features together + # modify template: use partner_to, use template and email address in email_to to test all features together user_model_id = self.registry('ir.model').search(cr, uid, [('model', '=', 'res.users')])[0] email_template.write(cr, uid, [email_template_id], { 'model_id': user_model_id, 'body_html': '${object.login}', 'email_to': '${object.email} c@c', - 'email_recipients': '%i,%i' % (p_b_id, p_c_id), + 'partner_to': '%i,%i' % (p_b_id, p_c_id), 'email_cc': 'd@d', }) # patner by email + partner by id (no double) diff --git a/addons/email_template/wizard/email_template_preview_view.xml b/addons/email_template/wizard/email_template_preview_view.xml index 8dd4bc92ba7..2d7abcb4eef 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 b39ed4e5639..bc97383bc19 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -65,7 +65,7 @@ class mail_compose_message(osv.TransientModel): """ - mass_mailing: we cannot render, so return the template values - normal mode: return rendered values """ if template_id and composition_mode == 'mass_mail': - values = self.pool.get('email.template').read(cr, uid, template_id, ['subject', 'body_html'], context) + values = self.pool.get('email.template').read(cr, uid, template_id, ['email_from', 'partner_to', 'reply_to', 'subject', 'body_html'], context) values.pop('id') elif template_id: # FIXME odo: change the mail generation to avoid attachment duplication @@ -122,7 +122,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_html', 'subject', 'email_to', 'email_recipients', 'email_cc', 'attachments'] + fields = ['body_html', 'subject', 'email_to', 'partner_to', '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 @@ -132,9 +132,9 @@ class mail_compose_message(osv.TransientModel): 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) - email_recipients = values.pop('email_recipients', '') - if email_recipients: - for partner_id in email_recipients.split(','): + partner_to = values.pop('partner_to', '') + if partner_to: + for partner_id in partner_to.split(','): values['partner_ids'].append(int(partner_id)) values['partner_ids'] = list(set(values['partner_ids'])) diff --git a/addons/portal_sale/portal_sale_data.xml b/addons/portal_sale/portal_sale_data.xml index 31a2f19ef28..2cd7ca8b501 100644 --- a/addons/portal_sale/portal_sale_data.xml +++ b/addons/portal_sale/portal_sale_data.xml @@ -8,7 +8,7 @@ Sales Order - Send by Email (Portal) ${object.user_id.email or ''} ${object.company_id.name} ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref ${object.name or 'n/a' }) - ${object.partner_invoice_id.id} + ${object.partner_invoice_id.id} @@ -97,7 +97,7 @@ Invoice - Send by Email (Portal) ${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.id} + ${object.partner_id.id} diff --git a/addons/purchase/edi/purchase_order_action_data.xml b/addons/purchase/edi/purchase_order_action_data.xml index d616ff1d116..819f7e26b55 100644 --- a/addons/purchase/edi/purchase_order_action_data.xml +++ b/addons/purchase/edi/purchase_order_action_data.xml @@ -21,7 +21,7 @@ Purchase Order - Send by mail ${object.validator.email or ''} ${object.company_id.name} Order (Ref ${object.name or 'n/a' }) - ${object.partner_id.id} + ${object.partner_id.id} diff --git a/addons/sale/edi/sale_order_action_data.xml b/addons/sale/edi/sale_order_action_data.xml index 16712532285..a7f597f4339 100644 --- a/addons/sale/edi/sale_order_action_data.xml +++ b/addons/sale/edi/sale_order_action_data.xml @@ -22,7 +22,7 @@ Sales Order - Send by Email ${object.user_id.email or ''} ${object.company_id.name} ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref ${object.name or 'n/a' }) - ${object.partner_invoice_id.id} + ${object.partner_invoice_id.id}