diff --git a/addons/account/edi/invoice_action_data.xml b/addons/account/edi/invoice_action_data.xml
index 9aa1a4b720f..53fa03a6902 100644
--- a/addons/account/edi/invoice_action_data.xml
+++ b/addons/account/edi/invoice_action_data.xml
@@ -123,64 +123,6 @@
]]>
-
%s' % body, + 'email_to': dest, + 'email_from': data_user.email or tools.config.options['email_from']} + self.pool.get('mail.mail').create(cr, uid, vals, context=context) msg_sent += partner.name + '\n' except Exception, e: raise osv.except_osv('Error !', e ) diff --git a/addons/auth_reset_password/auth_reset_password.xml b/addons/auth_reset_password/auth_reset_password.xml index d2256a8911a..b7d7e0baef6 100644 --- a/addons/auth_reset_password/auth_reset_password.xml +++ b/addons/auth_reset_password/auth_reset_password.xml @@ -9,16 +9,13 @@
You may change your password following this link, +or by copy-pasting the following URL in your browser: ${object._auth_reset_password_link()}
-${object._auth_reset_password_link()} - -If you don't have asked for password reset, you can safely ignore this email. - -]]>Note: If you did not ask for a password reset, you can safely ignore this email.
]]> diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 8c115baed23..7e9bbacab13 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -302,33 +302,27 @@ the rule to mark CC(mail to any other person defined in actions)."), return self.format_body(body % data) def email_send(self, cr, uid, obj, emails, body, emailfrom=None, context=None): - """ send email - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param email: pass the emails - @param emailfrom: Pass name the email From else False - @param context: A standard dictionary for contextual values """ - if not emailfrom: - emailfrom = tools.config.get('email_from', False) - - if context is None: - context = {} - - mail_message = self.pool.get('mail.message') + emailfrom = tools.config.get('email_from') body = self.format_mail(obj, body) - if not emailfrom: - if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.email: - emailfrom = obj.user_id.email - - name = '[%d] %s' % (obj.id, tools.ustr(obj.name)) + if not emailfrom and hasattr(obj, 'user_id') and obj.user_id and obj.user_id.email: + emailfrom = obj.user_id.email emailfrom = tools.ustr(emailfrom) reply_to = emailfrom if not emailfrom: raise osv.except_osv(_('Error!'), - _("No email ID found for your company address.")) - return mail_message.schedule_with_attach(cr, uid, emailfrom, emails, name, body, model='base.action.rule', reply_to=reply_to, res_id=obj.id) + _("Missing default email address or missing email on responsible user")) + return self.pool.get('mail.mail').create(cr, uid, + { 'email_from': emailfrom, + 'email_to': emails.join(','), + 'reply_to': reply_to, + 'state': 'outgoing', + 'subject': '[%d] %s' % (obj.id, tools.ustr(obj.name)), + 'body_html': '%s' % body, + 'res_id': obj.id, + 'model': obj._table_name, + 'auto_delete': True + }, context=context) def do_check(self, cr, uid, action, obj, context=None): diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index d560eaacd66..a6d5f6859af 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -471,18 +471,10 @@ property or property parameter."), def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context=None): """ Send mail for event invitation to event attendees. - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param ids: List of attendee’s IDs. @param email_from: Email address for user sending the mail - @param context: A standard dictionary for contextual values @return: True """ - if context is None: - context = {} - company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.name - mail_message = self.pool.get('mail.message') for att in self.browse(cr, uid, ids, context=context): sign = att.sent_by_uid and att.sent_by_uid.signature or '' sign = '
Event: %s Event Date: %s Description: %s @@ -888,20 +854,21 @@ From: ---- %s - +""" % (alarm.name, alarm.trigger_date, alarm.description, \ alarm.user_id.name, alarm.user_id.signature) mail_to = [alarm.user_id.email] for att in alarm.attendee_ids: mail_to.append(att.user_id.email) if mail_to: - mail_message.schedule_with_attach(cr, uid, - tools.config.get('email_from', False), - mail_to, - sub, - body, - context=context - ) + vals = { + 'state': 'outgoing', + 'subject': sub, + 'body_html': body, + 'email_to': mail_to, + 'email_from': tools.config.get('email_from', mail_to), + } + self.pool.get('mail.mail').create(cr, uid, vals, context=context) if next_trigger_date: update_vals.update({'trigger_date': next_trigger_date}) else: diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 26afe548217..529e70fdb49 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -297,55 +297,31 @@ class base_stage(object): destination=False) def remind_user(self, cr, uid, ids, context=None, attach=False, destination=True): - mail_message = self.pool.get('mail.message') - for case in self.browse(cr, uid, ids, context=context): - if not destination and not case.email_from: - return False - if not case.user_id.email: - return False - if destination and case.section_id.user_id: - case_email = case.section_id.user_id.email - else: - case_email = case.user_id.email - - src = case_email - dest = case.user_id.email or "" - body = case.description or "" - for message in case.message_ids: - if message.email_from and message.body: - body = message.body - break - - if not destination: - src, dest = dest, case.email_from - if body and case.user_id.signature: - if body: - body += '\n\n%s' % (case.user_id.signature) - else: - body = '\n\n%s' % (case.user_id.signature) - - body = self.format_body(body) - - attach_to_send = {} - - if attach: - attach_ids = self.pool.get('ir.attachment').search(cr, uid, [('res_model', '=', self._name), ('res_id', '=', case.id)]) - attach_to_send = self.pool.get('ir.attachment').read(cr, uid, attach_ids, ['datas_fname', 'datas']) - attach_to_send = dict(map(lambda x: (x['datas_fname'], base64.decodestring(x['datas'])), attach_to_send)) - - # Send an email - subject = "Reminder: [%s] %s" % (str(case.id), case.name, ) - mail_message.schedule_with_attach(cr, uid, - src, - [dest], - subject, - body, - model=self._name, - reply_to=case.section_id.reply_to, - res_id=case.id, - attachments=attach_to_send, - context=context - ) + if 'message_post' in self: + for case in self.browse(cr, uid, ids, context=context): + if destination: + recipient_id = case.user_id.partner_id.id + else: + if not case.email_from: + return False + recipient_id = self.pool.get('res.partner').find_or_create(cr, uid, case.email_from, context=context) + + body = case.description or "" + for message in case.message_ids: + if message.type == 'email' and message.body: + body = message.body + break + body = self.format_body(body) + attach_to_send = {} + if attach: + attach_ids = self.pool.get('ir.attachment').search(cr, uid, [('res_model', '=', self._name), ('res_id', '=', case.id)]) + attach_to_send = self.pool.get('ir.attachment').read(cr, uid, attach_ids, ['datas_fname', 'datas']) + attach_to_send = dict(map(lambda x: (x['datas_fname'], x['datas'].decode('base64')), attach_to_send)) + + subject = "Reminder: [%s] %s" % (case.id, case.name) + self.message_post(cr, uid, case.id, body=body, + subject=subject, attachments=attach_to_send, + partner_ids=[recipient_id], context=context) return True def _check(self, cr, uid, ids=False, context=None): @@ -360,17 +336,6 @@ class base_stage(object): def format_mail(self, obj, body): return self.pool.get('base.action.rule').format_mail(obj, body) - def message_thread_followers(self, cr, uid, ids, context=None): - res = {} - for case in self.browse(cr, uid, ids, context=context): - l=[] - if case.email_cc: - l.append(case.email_cc) - if case.user_id and case.user_id.email: - l.append(case.user_id.email) - res[case.id] = l - return res - # ****************************** # Notifications # ****************************** diff --git a/addons/crm/crm_action_rule.py b/addons/crm/crm_action_rule.py index 36700b5b6c2..8b1ba655afc 100644 --- a/addons/crm/crm_action_rule.py +++ b/addons/crm/crm_action_rule.py @@ -46,21 +46,11 @@ class base_action_rule(osv.osv): } def email_send(self, cr, uid, obj, emails, body, emailfrom=tools.config.get('email_from', False), context=None): - mail_message = self.pool.get('mail.message') - body = self.format_mail(obj, body) - if not emailfrom: - if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.email: - emailfrom = obj.user_id.email - - name = '[%d] %s' % (obj.id, tools.ustr(obj.name)) - emailfrom = tools.ustr(emailfrom) - if hasattr(obj, 'section_id') and obj.section_id and obj.section_id.alias_id: + mail_id = super(base_action_rule, self).email_send(cr, uid, obj, emails, body, emailfrom=emailfrom, context=context) + if mail_id and hasattr(obj, 'section_id') and obj.section_id and obj.section_id.alias_id: reply_to = obj.section_id.alias_id.name_get()[0][1] - else: - reply_to = emailfrom - if not emailfrom: - raise osv.except_osv(_('Error!'), _("There is no email for your company address.")) - return mail_message.schedule_with_attach(cr, uid, emailfrom, emails, name, body, model=obj._name, reply_to=reply_to, res_id=obj.id) + self.pool.get('mail.mail').write(cr, uid, [mail_id], {'reply_to': reply_to}, context=context) + return mail_id def do_check(self, cr, uid, action, obj, context=None): ok = super(base_action_rule, self).do_check(cr, uid, action, obj, context=context) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 801895885b2..36af90fcf07 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -671,24 +671,6 @@ class crm_lead(base_stage, osv.osv): partner_ids[lead.id] = partner_id return partner_ids - def _send_mail_to_salesman(self, cr, uid, lead, context=None): - """ - Send mail to salesman with updated Lead details. - @ lead: browse record of 'crm.lead' object. - """ - #TOFIX: mail template should be used here instead of fix subject, body text. - message = self.pool.get('mail.message') - email_to = lead.user_id and lead.user_id.email - if not email_to: - return False - - email_from = lead.section_id and lead.section_id.user_id and lead.section_id.user_id.email or email_to - partner = lead.partner_id and lead.partner_id.name or lead.partner_name - subject = "lead %s converted into opportunity" % lead.name - body = "Info \n Id : %s \n Subject: %s \n Partner: %s \n Description : %s " % (lead.id, lead.name, lead.partner_id.name, lead.description) - return message.schedule_with_attach(cr, uid, email_from, [email_to], subject, body) - - def allocate_salesman(self, cr, uid, ids, user_ids, team_id=False, context=None): index = 0 for lead_id in ids: diff --git a/addons/crm_partner_assign/wizard/crm_forward_to_partner.py b/addons/crm_partner_assign/wizard/crm_forward_to_partner.py index 6ed8da7b231..0cac38e0163 100644 --- a/addons/crm_partner_assign/wizard/crm_forward_to_partner.py +++ b/addons/crm_partner_assign/wizard/crm_forward_to_partner.py @@ -89,11 +89,6 @@ class crm_lead_forward_to_partner(osv.osv_memory): lead = self.pool.get(model).browse(cr, uid, res_id, context=context) body = self._get_message_body(cr, uid, lead, history_mode, context=context) return {'value': {'body': body}} - - def on_change_partner_ids(self, cr, uid, ids, partner_ids, context=None): - """ TDE-TODO: Keep void; maybe we could check that partner_ids have - email defined. """ - return {} def create(self, cr, uid, values, context=None): """ TDE-HACK: remove 'type' from context, because when viewing an @@ -106,9 +101,7 @@ class crm_lead_forward_to_partner(osv.osv_memory): return new_id def action_forward(self, cr, uid, ids, context=None): - """ - Forward the lead to a partner - """ + """ Forward the lead to a partner """ if context is None: context = {} res = {'type': 'ir.actions.act_window_close'} @@ -126,7 +119,7 @@ class crm_lead_forward_to_partner(osv.osv_memory): self.send_mail(cr, uid, ids, context=context) # for case in lead.browse(cr, uid, lead_ids, context=context): - # TDE: WHAT TO DO WITH THAT ? + # TODO: WHAT TO DO WITH THAT ? # if (this.send_to == 'partner' and this.partner_id): # lead.assign_partner(cr, uid, [case.id], this.partner_id.id, context=context) diff --git a/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml b/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml index fe9e1476817..0d8f27eec74 100644 --- a/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml +++ b/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml @@ -16,7 +16,7 @@ on_change="on_change_history_mode(history_mode, model, res_id)"/>
The event ${object.event_id.name} that you registered for is confirmed and will be held from ${object.event_id.date_begin} to ${object.event_id.date_end}. + For any further information please contact our event department.
+Thank you for your participation!
+Best regards
]]>We confirm that your registration to the event ${object.event_id.name} has been recorded. + You will automatically receive an email providing you more practical information (such as the schedule, the agenda...) as soon as the event is confirmed.
+Thank you for your participation!
+Best regards
]]>%s' % body, + 'email_to': child.work_email, + 'email_from': evaluation.employee_id.work_email} + self.pool.get('mail.mail').create(cr, uid, vals, context=context) self.write(cr, uid, ids, {'state':'wait'}, context=context) return True diff --git a/addons/hr_evaluation/hr_evaluation_view.xml b/addons/hr_evaluation/hr_evaluation_view.xml index 9f64df8808d..4f49b7ba516 100644 --- a/addons/hr_evaluation/hr_evaluation_view.xml +++ b/addons/hr_evaluation/hr_evaluation_view.xml @@ -267,16 +267,27 @@
%s' % body}, context=context)) # force direct delivery, as users expect instant notification - mail_message.send(cr, uid, msg_ids, context=context) - _logger.info('%d share notification(s) sent.', len(msg_ids)) + mail_mail.send(cr, uid, mail_ids, context=context) + _logger.info('%d share notification(s) sent.', len(mail_ids)) def onchange_embed_options(self, cr, uid, ids, opt_title, opt_search, context=None): wizard = self.browse(cr, uid, ids[0], context) diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 66098b45fa8..e2216ea8389 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -420,7 +420,17 @@ class survey_question_wiz(osv.osv_memory): if user_email and resp_email: user_name = user_obj.browse(cr, uid, uid, context=context).name mail = "Hello " + survey_data.responsible_id.name + ",\n\n " + str(user_name) + " has given the Response Of " + survey_data.title + " Survey.\nThe Response has been attached herewith.\n\n Thanks." - mail_message.schedule_with_attach(cr, uid, user_email, [resp_email], "Survey Answer Of " + str(user_name) , mail, attachments=attachments, context=context) + vals = {'state': 'outgoing', + 'subject': "Survey Answer Of " + user_name, + 'body_html': '
%s' % mail, + 'email_to': [resp_email], + 'email_from': user_email} + if attachments: + vals['attachment_ids'] = [(0,0,{'name': a_name, + 'datas_fname': a_name, + 'datas': str(a_content).encode('base64')}) + for a_name, a_content in attachments] + self.pool.get('mail.mail').create(cr, uid, vals, context=context) xml_form = etree.Element('form', {'string': _('Complete Survey Answer')}) etree.SubElement(xml_form, 'separator', {'string': 'Complete Survey', 'colspan': "4"}) diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index da439959ec5..5677a985e09 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -116,7 +116,6 @@ class survey_send_invitation(osv.osv_memory): existing = "" created = "" error = "" - user_exists = False new_user = [] attachments = {} current_sur = survey_ref.browse(cr, uid, context.get('active_id'), context=context) @@ -150,8 +149,14 @@ class survey_send_invitation(osv.osv_memory): mail = record['mail']%{'login':partner.email, 'passwd':user.password, \ 'name' : partner.name} if record['send_mail_existing']: - mail_message.schedule_with_attach(cr, uid, record['mail_from'], [partner.email] , \ - record['mail_subject_existing'] , mail, context=context) + vals = { + 'state': 'outgoing', + 'subject': record['mail_subject_existing'], + 'body_html': '
%s' % mail, + 'email_to': partner.email, + 'email_from': record['mail_from'], + } + self.pool.get('mail.mail').create(cr, uid, vals, context=context) existing+= "- %s (Login: %s, Password: %s)\n" % (user.name, partner.email, \ user.password) continue @@ -160,8 +165,19 @@ class survey_send_invitation(osv.osv_memory): out+= partner.email + ',' + passwd + '\n' mail= record['mail'] % {'login' : partner.email, 'passwd' : passwd, 'name' : partner.name} if record['send_mail']: - ans = mail_message.schedule_with_attach(cr, uid, record['mail_from'], [partner.email], \ - record['mail_subject'], mail, attachments=attachments, context=context) + vals = { + 'state': 'outgoing', + 'subject': record['mail_subject'], + 'body_html': '
%s' % mail, + 'email_to': partner.email, + 'email_from': record['mail_from'], + } + if attachments: + vals['attachment_ids'] = [(0,0,{'name': a_name, + 'datas_fname': a_name, + 'datas': str(a_content).encode('base64')}) + for a_name, a_content in attachments] + ans = self.pool.get('mail.mail').create(cr, uid, vals, context=context) if ans: res_data = {'name': partner.name or _('Unknown'), 'login': partner.email,