diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index e5d07b2df42..d0be688c8a5 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -259,7 +259,9 @@ class crm_lead(base_stage, format_address, osv.osv): 'channel_id': fields.many2one('crm.case.channel', 'Channel', help="Communication channel (mail, direct, phone, ...)"), 'contact_name': fields.char('Contact Name', size=64), 'partner_name': fields.char("Customer Name", size=64,help='The name of the future partner company that will be created while converting the lead into opportunity', select=1), - 'opt_out': fields.boolean('Opt-Out', oldname='optout', help="If opt-out is checked, this contact has refused to receive emails or unsubscribed to a campaign."), + 'opt_out': fields.boolean('Opt-Out', oldname='optout', + help="If opt-out is checked, this contact has refused to receive emails for mass mailing and marketing campaign. " + "Filter 'Available for Mass Mailing' allows users to filter the leads when performing mass mailing."), 'type':fields.selection([ ('lead','Lead'), ('opportunity','Opportunity'), ],'Type', help="Type is used to separate Leads and Opportunities"), 'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority', select=True), 'date_closed': fields.datetime('Closed', readonly=True), @@ -975,8 +977,8 @@ class crm_lead(base_stage, format_address, osv.osv): through message_process. This override updates the document according to the email. """ - if custom_values is None: custom_values = {} - + if custom_values is None: + custom_values = {} desc = html2plaintext(msg.get('body')) if msg.get('body') else '' defaults = { 'name': msg.get('subject') or _("No Subject"), diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index df68f90aa57..91154b1ee5a 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -341,7 +341,11 @@ - + + + diff --git a/addons/crm/wizard/crm_opportunity_to_phonecall.py b/addons/crm/wizard/crm_opportunity_to_phonecall.py index ad9d30c80a4..ee7ed1fc31f 100644 --- a/addons/crm/wizard/crm_opportunity_to_phonecall.py +++ b/addons/crm/wizard/crm_opportunity_to_phonecall.py @@ -52,8 +52,6 @@ class crm_opportunity2phonecall(osv.osv_memory): res.update({'categ_id': categ_id}) if 'partner_id' in fields: res.update({'partner_id': opp.partner_id and opp.partner_id.id or False}) - if 'note' in fields: - res.update({'note': opp.description}) if 'contact_name' in fields: res.update({'contact_name': opp.partner_id and opp.partner_id.name or False}) if 'phone' in fields: diff --git a/addons/crm/wizard/crm_opportunity_to_phonecall_view.xml b/addons/crm/wizard/crm_opportunity_to_phonecall_view.xml index 6e44573cc89..ad369448517 100644 --- a/addons/crm/wizard/crm_opportunity_to_phonecall_view.xml +++ b/addons/crm/wizard/crm_opportunity_to_phonecall_view.xml @@ -13,14 +13,14 @@ + - diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index 743384059b4..08ef3ec6e98 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -65,6 +65,7 @@ class email_template(osv.osv): "Templates for sending email" _name = "email.template" _description = 'Email Templates' + _order = 'name' def render_template(self, cr, uid, template, model, res_id, context=None): """Render the given template text, replace mako expressions ``${expr}`` @@ -141,7 +142,9 @@ class email_template(osv.osv): help="If checked, the user's signature will be appended to the text version " "of the message"), '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_from': fields.char('From', + help="Sender address (placeholders may be used here). If not set, the default " + "value will be the author's email alias if configured, or email address."), '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)"), 'email_cc': fields.char('Cc', help="Carbon copy recipients (placeholders may be used here)"), diff --git a/addons/email_template/email_template_view.xml b/addons/email_template/email_template_view.xml index 4cddb31c8e1..73e796394a8 100644 --- a/addons/email_template/email_template_view.xml +++ b/addons/email_template/email_template_view.xml @@ -28,7 +28,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/addons/email_template/res_partner.py b/addons/email_template/res_partner.py index 987fca43219..cb3ef67862f 100644 --- a/addons/email_template/res_partner.py +++ b/addons/email_template/res_partner.py @@ -19,7 +19,7 @@ # ############################################################################## -from openerp.osv import fields,osv +from openerp.osv import fields, osv class res_partner(osv.osv): """Inherit res.partner to add a generic opt-out field that can be used @@ -28,8 +28,9 @@ class res_partner(osv.osv): _inherit = 'res.partner' _columns = { - 'opt_out': fields.boolean('Opt-Out', help="If checked, this partner will not receive any automated email " \ - "notifications, such as the availability of invoices."), + 'opt_out': fields.boolean('Opt-Out', + help="If opt-out is checked, this contact has refused to receive emails for mass mailing and marketing campaign. " + "Filter 'Available for Mass Mailing' allows users to filter the partners when performing mass mailing."), } _defaults = { diff --git a/addons/email_template/res_partner_view.xml b/addons/email_template/res_partner_view.xml index 3d17120d69e..1eab8029cb2 100644 --- a/addons/email_template/res_partner_view.xml +++ b/addons/email_template/res_partner_view.xml @@ -11,5 +11,19 @@ + + + res.partner.opt_out.search + res.partner + + + + + + + + diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index b39ed4e5639..255f93998a2 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -80,7 +80,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 +125,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'] = list(partner_ids) return values diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py index 1b3ca152a9a..8bca0f85b94 100644 --- a/addons/mail/mail_mail.py +++ b/addons/mail/mail_mail.py @@ -191,20 +191,31 @@ class mail_mail(osv.Model): return body def send_get_mail_reply_to(self, cr, uid, mail, partner=None, context=None): - """ Return a specific ir_email body. The main purpose of this method - is to be inherited by Portal, to add a link for signing in, in - each notification email a partner receives. + """ Return a specific ir_email reply_to. :param browse_record mail: mail.mail browse_record :param browse_record partner: specific recipient partner """ if mail.reply_to: return mail.reply_to - if not mail.model or not mail.res_id: - return False - if not hasattr(self.pool.get(mail.model), 'message_get_reply_to'): - return False - return self.pool.get(mail.model).message_get_reply_to(cr, uid, [mail.res_id], context=context)[0] + email_reply_to = False + + # if model and res_id: try to use ``message_get_reply_to`` that returns the document alias + if mail.model and mail.res_id and hasattr(self.pool.get(mail.model), 'message_get_reply_to'): + email_reply_to = self.pool.get(mail.model).message_get_reply_to(cr, uid, [mail.res_id], context=context)[0] + # no alias reply_to -> reply_to will be the email_from, only the email part + if not email_reply_to and mail.email_from: + emails = tools.email_split(mail.email_from) + if emails: + email_reply_to = emails[0] + + # format 'Document name ' + if email_reply_to and mail.model and mail.res_id: + document_name = self.pool.get(mail.model).name_get(cr, SUPERUSER_ID, [mail.res_id], context=context)[0] + if document_name: + email_reply_to = _('Followers of %s <%s>') % (document_name[1], email_reply_to) + + return email_reply_to def send_get_email_dict(self, cr, uid, mail, partner=None, context=None): """ Return a dictionary for specific email values, depending on a diff --git a/addons/mail/mail_message_view.xml b/addons/mail/mail_message_view.xml index 7d2e9483773..8f2fb3f1020 100644 --- a/addons/mail/mail_message_view.xml +++ b/addons/mail/mail_message_view.xml @@ -59,12 +59,12 @@ - - + res.partner + + +