[IMP] call email_send method of email.message object insted of tools.

bzr revid: ysa@tinyerp.com-20110204061819-bb3p94bs7og680je
This commit is contained in:
YSA (Openerp)
2011-02-04 11:48:19 +05:30
parent e9e229568b
commit bbdac458fd
15 changed files with 114 additions and 95 deletions
@@ -205,6 +205,7 @@ class account_followup_print_all(osv.osv_memory):
move_obj = self.pool.get('account.move.line')
user_obj = self.pool.get('res.users')
line_obj = self.pool.get('account_followup.stat')
email_message_obj = self.pool.get('email.message')
if context is None:
context = {}
@@ -276,7 +277,7 @@ class account_followup_print_all(osv.osv_memory):
msg = ''
if dest:
try:
tools.email_send(src, dest, sub, body)
email_message_obj.email_send(src, dest, sub, body, model='account.followup.print.all')
msg_sent += partner.name + '\n'
except Exception, e:
raise osv.except_osv('Error !', e )
+2 -1
View File
@@ -300,6 +300,7 @@ the rule to mark CC(mail to any other person defined in actions)."),
if context is None:
context = {}
email_message_obj = self.pool.get('email.message')
body = self.format_mail(obj, body)
if not emailfrom:
if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and\
@@ -312,7 +313,7 @@ the rule to mark CC(mail to any other person defined in actions)."),
if not emailfrom:
raise osv.except_osv(_('Error!'),
_("No E-Mail ID Found for your Company address!"))
return tools.email_send(emailfrom, emails, name, body, reply_to=reply_to, openobject_id=str(obj.id))
return email_message_obj.email_send(emailfrom, emails, name, body, model='base.action.rule', reply_to=reply_to, openobject_id=str(obj.id))
def do_check(self, cr, uid, action, obj, context=None):
+7 -3
View File
@@ -480,6 +480,7 @@ property or property parameter."),
context = {}
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.name
email_message_obj = self.pool.get('email.message')
for att in self.browse(cr, uid, ids, context=context):
sign = att.sent_by_uid and att.sent_by_uid.signature or ''
sign = '<br>'.join(sign and sign.split('\n') or [])
@@ -506,11 +507,12 @@ property or property parameter."),
body = html_invitation % body_vals
if mail_to and email_from:
attach = self.get_ics_file(cr, uid, res_obj, context=context)
tools.email_send(
email_message_obj.email_send(
email_from,
mail_to,
sub,
body,
model='calendar.attendee',
attach=attach and [('invitation.ics', attach)] or None,
subtype='html',
reply_to=email_from
@@ -809,6 +811,7 @@ class calendar_alarm(osv.osv):
return True # XXX FIXME REMOVE THIS AFTER FIXING get_recurrent_dates!!
if context is None:
context = {}
email_message_obj = self.pool.get('email.message')
current_datetime = datetime.now()
request_obj = self.pool.get('res.request')
alarm_ids = self.search(cr, uid, [('state', '!=', 'done')], context=context)
@@ -890,11 +893,12 @@ From:
for att in alarm.attendee_ids:
mail_to.append(att.user_id.address_id.email)
if mail_to:
tools.email_send(
email_message_obj.email_send(
tools.config.get('email_from', False),
mail_to,
sub,
body
body,
model='calendar.alarm'
)
if next_trigger_date:
update_vals.update({'trigger_date': next_trigger_date})
+39 -37
View File
@@ -49,7 +49,7 @@ class crm_case(object):
def _find_lost_stage(self, cr, uid, type, section_id):
return self._find_percent_stage(cr, uid, 0.0, type, section_id)
def _find_won_stage(self, cr, uid, type, section_id):
return self._find_percent_stage(cr, uid, 100.0, type, section_id)
@@ -60,14 +60,14 @@ class crm_case(object):
stage_pool = self.pool.get('crm.case.stage')
if section_id :
ids = stage_pool.search(cr, uid, [("probability", '=', percent), ("type", 'like', type), ("section_ids", 'in', [section_id])])
else :
else :
ids = stage_pool.search(cr, uid, [("probability", '=', percent), ("type", 'like', type)])
if ids:
return ids[0]
return False
def _find_first_stage(self, cr, uid, type, section_id):
"""
return the first stage that has a sequence number equal or higher than sequence
@@ -75,9 +75,9 @@ class crm_case(object):
stage_pool = self.pool.get('crm.case.stage')
if section_id :
ids = stage_pool.search(cr, uid, [("sequence", '>', 0), ("type", 'like', type), ("section_ids", 'in', [section_id])])
else :
else :
ids = stage_pool.search(cr, uid, [("sequence", '>', 0), ("type", 'like', type)])
if ids:
stages = stage_pool.browse(cr, uid, ids)
stage_min = stages[0]
@@ -85,9 +85,9 @@ class crm_case(object):
if stage_min.sequence > stage.sequence:
stage_min = stage
return stage_min.id
else :
else :
return False
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
""" @param self: The object pointer
@@ -95,7 +95,7 @@ class crm_case(object):
@param uid: the current user’s ID for security checks,
@param ids: List of stage’s IDs
@stage_id: change state id on run time """
if not stage_id:
return {'value':{}}
@@ -151,19 +151,19 @@ class crm_case(object):
default = {}
default.update({
'message_ids': [],
'message_ids': [],
})
if hasattr(self, '_columns'):
if self._columns.get('date_closed'):
default.update({
'date_closed': False,
'date_closed': False,
})
if self._columns.get('date_open'):
default.update({
'date_open': False
})
return super(osv.osv, self).copy(cr, uid, id, default, context=context)
def _get_default_email(self, cr, uid, context=None):
"""Gives default email address for current user
@param self: The object pointer
@@ -214,7 +214,7 @@ class crm_case(object):
return next_stage
else :
return self._find_next_stage(cr, uid, stage_list, index + 1, current_seq, stage_pool)
def stage_change(self, cr, uid, ids, context=None, order='sequence'):
if context is None:
context = {}
@@ -226,12 +226,12 @@ class crm_case(object):
for case in self.browse(cr, uid, ids, context=context):
next_stage = False
value = {}
if case.section_id.id :
if case.section_id.id :
domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)]
else :
domain = [('type', '=', stage_type)]
stages = stage_pool.search(cr, uid, domain, order=order)
current_seq = case.stage_id.sequence
index = -1
@@ -239,18 +239,18 @@ class crm_case(object):
index = stages.index(case.stage_id.id)
next_stage = self._find_next_stage(cr, uid, stages, index, current_seq, stage_pool, context=context)
if next_stage:
next_stage_id = next_stage.id
value.update({'stage_id': next_stage.id})
if next_stage.on_change:
value.update({'probability': next_stage.probability})
self.write(cr, uid, [case.id], value, context=context)
return next_stage_id #FIXME should return a list of all id
def stage_next(self, cr, uid, ids, context=None):
"""This function computes next stage for case from its current stage
using available stage for that case type
@@ -259,9 +259,9 @@ class crm_case(object):
@param uid: the current user’s ID for security checks,
@param ids: List of case IDs
@param context: A standard dictionary for contextual values"""
return self.stage_change(cr, uid, ids, context=context, order='sequence')
def stage_previous(self, cr, uid, ids, context=None):
"""This function computes previous stage for case from its current stage
using available stage for that case type
@@ -283,7 +283,7 @@ class crm_case(object):
"""
if not part:
return {'value': {'partner_address_id': False,
'email_from': False,
'email_from': False,
'phone': False
}}
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['contact'])
@@ -321,7 +321,7 @@ class crm_case(object):
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
cases = self.browse(cr, uid, ids)
self._history(cr, uid, cases, _('Open'))
for case in cases:
@@ -329,9 +329,9 @@ class crm_case(object):
if not case.user_id:
data['user_id'] = uid
self.write(cr, uid, case.id, data)
self._action(cr, uid, cases, 'open')
self._action(cr, uid, cases, 'open')
return True
def case_close(self, cr, uid, ids, *args):
@@ -450,6 +450,7 @@ class crm_case(object):
@param context: A standard dictionary for contextual values
"""
email_message_obj = self.pool.get('email.message')
for case in self.browse(cr, uid, ids, context=context):
if not case.section_id.reply_to:
raise osv.except_osv(_('Error!'), ("Reply To is not specified in the sales team"))
@@ -480,11 +481,12 @@ class crm_case(object):
# Send an email
subject = "Reminder: [%s] %s" % (str(case.id), case.name, )
tools.email_send(
email_message_obj.email_send(
src,
[dest],
subject,
subject,
body,
model='crm.case',
reply_to=case.section_id.reply_to,
openobject_id=str(case.id),
attach=attach_to_send
@@ -550,9 +552,9 @@ class crm_case_stage(osv.osv):
_description = "Stage of case"
_rec_name = 'name'
_order = "sequence"
def _get_type_value(self, cr, user, context):
return [('lead','Lead'),('opportunity','Opportunity')]
@@ -566,8 +568,8 @@ class crm_case_stage(osv.osv):
'requirements': fields.text('Requirements'),
'type': fields.selection(_get_type_value, 'Type'),
}
def _find_stage_type(self, cr, uid, context=None):
"""Finds type of stage according to object.
@param self: The object pointer
@@ -612,7 +614,7 @@ class crm_case_section(osv.osv):
'child_ids': fields.one2many('crm.case.section', 'parent_id', 'Child Teams'),
'resource_calendar_id': fields.many2one('resource.calendar', "Working Time"),
'note': fields.text('Description'),
'working_hours': fields.float('Working Hours', digits=(16,2 )),
'working_hours': fields.float('Working Hours', digits=(16,2 )),
'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'),
}
@@ -708,7 +710,7 @@ class crm_case_stage(osv.osv):
_columns = {
'section_ids':fields.many2many('crm.case.section', 'section_stage_rel', 'stage_id', 'section_id', 'Sections'),
}
crm_case_stage()
+16 -15
View File
@@ -37,25 +37,26 @@ class base_action_rule(osv.osv):
""" Base Action Rule """
_inherit = 'base.action.rule'
_description = 'Action Rules'
_columns = {
'trg_section_id': fields.many2one('crm.case.section', 'Sales Team'),
'trg_max_history': fields.integer('Maximum Communication History'),
'trg_categ_id': fields.many2one('crm.case.categ', 'Category'),
'regex_history' : fields.char('Regular Expression on Case History', size=128),
'act_section_id': fields.many2one('crm.case.section', 'Set Team to'),
'act_categ_id': fields.many2one('crm.case.categ', 'Set Category to'),
'trg_section_id': fields.many2one('crm.case.section', 'Sales Team'),
'trg_max_history': fields.integer('Maximum Communication History'),
'trg_categ_id': fields.many2one('crm.case.categ', 'Category'),
'regex_history' : fields.char('Regular Expression on Case History', size=128),
'act_section_id': fields.many2one('crm.case.section', 'Set Team to'),
'act_categ_id': fields.many2one('crm.case.categ', 'Set Category to'),
'act_mail_to_partner': fields.boolean('Mail to Partner', help="Check \
this if you want the rule to send an email to the partner."),
this if you want the rule to send an email to the partner."),
}
def email_send(self, cr, uid, obj, emails, body, emailfrom=tools.config.get('email_from', False), context=None):
email_message_obj = self.pool.get('email.message')
body = self.format_mail(obj, body)
if not emailfrom:
if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and obj.user_id.address_id.email:
emailfrom = obj.user_id.address_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.reply_to:
@@ -63,10 +64,10 @@ this if you want the rule to send an email to the partner."),
else:
reply_to = emailfrom
if not emailfrom:
raise osv.except_osv(_('Error!'),
raise osv.except_osv(_('Error!'),
_("No E-Mail ID Found for your Company address!"))
return tools.email_send(emailfrom, emails, name, body, reply_to=reply_to, openobject_id=str(obj.id))
return email_message_obj.email_send(emailfrom, emails, name, body, model='base.action.rule', reply_to=reply_to, openobject_id=str(obj.id))
def do_check(self, cr, uid, action, obj, context=None):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@@ -79,7 +80,7 @@ this if you want the rule to send an email to the partner."),
if hasattr(obj, 'categ_id'):
ok = ok and (not action.trg_categ_id or action.trg_categ_id.id==obj.categ_id.id)
#Cheking for history
#Cheking for history
regex = action.regex_history
result_history = True
if regex:
@@ -109,7 +110,7 @@ this if you want the rule to send an email to the partner."),
@param context: A standard dictionary for contextual values """
res = super(base_action_rule, self).do_action(cr, uid, action, model_obj, obj, context=context)
write = {}
if hasattr(action, 'act_section_id') and action.act_section_id:
obj.section_id = action.act_section_id
write['section_id'] = action.act_section_id.id
+4 -3
View File
@@ -57,14 +57,14 @@ class crm_send_new_email(osv.osv_memory):
'body': fields.text('Message Body', required=True),
'state': fields.selection(AVAILABLE_STATES, string='Set New State To', required=True),
'attachment_ids' : fields.one2many('crm.send.mail.attachment', 'wizard_id'),
'html': fields.boolean('HTML formatting?', help="Select this if you want to send email with HTML formatting."),
'html': fields.boolean('HTML formatting?', help="Select this if you want to send email with HTML formatting."),
}
def action_send(self, cr, uid, ids, context=None):
""" This sends an email to ALL the addresses of the selected partners.
"""
hist_obj = self.pool.get('mailgate.message')
email_message_obj = self.pool.get('email.message')
if context is None:
context = {}
@@ -124,11 +124,12 @@ class crm_send_new_email(osv.osv_memory):
if obj.html:
subtype = 'html'
flag = tools.email_send(
flag = email_message_obj.email_send(
email_from,
emails,
obj.subject,
body,
model='crm.send.mail',
email_cc=email_cc,
attach=attach,
subtype=subtype,
+2 -2
View File
@@ -521,7 +521,7 @@ class event_registration(osv.osv):
"""
Send email to user
"""
email_message_obj = self.pool.get('email.message')
for regestration in self.browse(cr, uid, ids, context=context):
src = regestration.event_id.reply_to or False
email_to = []
@@ -545,7 +545,7 @@ class event_registration(osv.osv):
subject = _('Auto Confirmation: [%s] %s') %(regestration.id, regestration.name)
body = regestration.event_id.mail_confirm
if subject or body:
tools.email_send(src, email_to, subject, body, email_cc=email_cc, openobject_id=regestration.id)
email_message_obj.email_send(src, email_to, subject, body, model='event.registration', email_cc=email_cc, openobject_id=regestration.id)
self.history(cr, uid, [regestration], subject, history = True, \
email=email_to, details=body, \
subjec=subject, email_from=src, \
+2 -1
View File
@@ -193,6 +193,7 @@ class hr_evaluation(osv.osv):
return {'value': {'plan_id':evaluation_plan_id}}
def button_plan_in_progress(self, cr, uid, ids, context=None):
email_message_obj = self.pool.get('email.message')
hr_eval_inter_obj = self.pool.get('hr.evaluation.interview')
if context is None:
context = {}
@@ -229,7 +230,7 @@ class hr_evaluation(osv.osv):
sub = phase.email_subject
dest = [child.work_email]
if dest:
tools.email_send(evaluation.employee_id.work_email, dest, sub, body)
email_message_obj.email_send(evaluation.employee_id.work_email, dest, sub, body, model='hr_evaluation.evaluation')
self.write(cr, uid, ids, {'state':'wait'}, context=context)
return True
@@ -29,13 +29,14 @@ class hr_evaluation_reminder(osv.osv_memory):
}
def send_mail(self, cr, uid, ids, context=None):
email_message_obj = self.pool.get('email.message')
hr_evaluation_interview_obj = self.pool.get('hr.evaluation.interview')
evaluation_data = self.read(cr, uid, ids, context=context)[0]
current_interview = hr_evaluation_interview_obj.browse(cr, uid, evaluation_data.get('evaluation_id'))
if current_interview.state == "waiting_answer" and current_interview.user_to_review_id.work_email :
msg = " Hello %s, \n\n Kindly post your response for '%s' survey interview. \n\n Thanks," %(current_interview.user_to_review_id.name, current_interview.survey_id.title)
tools.email_send(tools.config['email_from'], [current_interview.user_to_review_id.work_email],\
'Reminder to fill up Survey', msg)
email_message_obj.email_send(tools.config['email_from'], [current_interview.user_to_review_id.work_email],\
'Reminder to fill up Survey', msg, model='hr.evaluation.reminder')
return {'type': 'ir.actions.act_window_close'}
hr_evaluation_reminder()
+5 -4
View File
@@ -45,13 +45,13 @@ class project_task_close(osv.osv_memory):
context = {}
record_id = context and context.get('active_id', False) or False
task_pool = self.pool.get('project.task')
res = super(project_task_close, self).default_get(cr, uid, fields, context=context)
task = task_pool.browse(cr, uid, record_id, context=context)
project = task.project_id
manager = project.user_id or False
partner = task.partner_id or task.project_id.partner_id
if 'description' in fields:
res.update({'description': task.description or False})
if 'manager_warn' in fields:
@@ -67,7 +67,8 @@ class project_task_close(osv.osv_memory):
def send(self, cr, uid, ids, context=None):
if context is None:
context = {}
email_message_obj = self.pool.get('email.message')
task_pool = self.pool.get('project.task')
task_id = context.get('active_id', False)
if not task_id:
@@ -106,7 +107,7 @@ class project_task_close(osv.osv_memory):
to_adr.append(data.manager_email)
if data.partner_warn and data.partner_email:
to_adr.append(data.partner_email)
mail_id = tools.email_send(from_adr, to_adr, subject, tools.ustr(body), email_bcc=[from_adr])
mail_id = email_message_obj.email_send(from_adr, to_adr, subject, tools.ustr(body), model='project.task.close', email_bcc=[from_adr])
if not mail_id:
raise osv.except_osv(_('Error'), _("Couldn't send mail! Check the email ids and smtp configuration settings"))
return {}
+2 -1
View File
@@ -317,6 +317,7 @@ class project_scrum_meeting(osv.osv):
return True
def email_send(self, cr, uid, ids, email, context=None):
email_message_obj = self.pool.get('email.message')
email_from = tools.config.get('email_from', False)
meeting_id = self.browse(cr, uid, ids, context=context)[0]
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
@@ -325,7 +326,7 @@ class project_scrum_meeting(osv.osv):
body += "\n"+ _('*Tasks since yesterday:')+ '\n_______________________%s' % (meeting_id.question_yesterday) + '\n' +_("*Task for Today:")+ '\n_______________________ %s\n' % (meeting_id.question_today )+ '\n' +_('*Blocks encountered:') +'\n_______________________ %s' % (meeting_id.question_blocks or _('No Blocks'))
body += "\n\n"+_('Thank you')+",\n"+ user.name
sub_name = meeting_id.name or _('Scrum Meeting of %s') % meeting_id.date
flag = tools.email_send(user_email , [email], sub_name, body, reply_to=None, openobject_id=str(meeting_id.id))
flag = email_message_obj.email_send(user_email , [email], sub_name, body, model='project.scrum.meeting', reply_to=None, openobject_id=str(meeting_id.id))
if not flag:
return False
return True
@@ -69,6 +69,7 @@ class project_scrum_email(osv.osv_memory):
if context is None:
context = {}
email_message_obj = self.pool.get('email.message')
active_id = context.get('active_id', False)
scrum_meeting_pool = self.pool.get('project.scrum.meeting')
user_pool = self.pool.get('res.users')
@@ -91,7 +92,7 @@ class project_scrum_email(osv.osv_memory):
body += "\n%s\n" %_("Task for Today")
body += "_______________________ \n"
body += "\n%s\n" %(meeting.question_today or _('None'))
body += "\n%s\n" % _('Blocking points encountered:')
body += "\n%s\n" % _('Blocking points encountered:')
body += "_______________________ \n"
body += "\n%s\n" %(meeting.question_blocks or _('None'))
body += "\n%s\n%s" %(_('Thank you,'), user.name)
@@ -100,8 +101,8 @@ class project_scrum_email(osv.osv_memory):
if data.scrum_master_email == data.product_owner_email:
data.product_owner_email = False
if data.scrum_master_email:
tools.email_send(user_email, [data.scrum_master_email], data.subject, body, reply_to=user_email)
email_message_obj.email_send(user_email, [data.scrum_master_email], data.subject, body, model='project.scrum.email', reply_to=user_email)
if data.product_owner_email:
tools.email_send(user_email, [data.product_owner_email], data.subject, body, reply_to=user_email)
email_message_obj.email_send(user_email, [data.product_owner_email], data.subject, body, model='project.scrum.email', reply_to=user_email)
return {'type': 'ir.actions.act_window_close'}
project_scrum_email()
+15 -13
View File
@@ -171,7 +171,7 @@ class share_create(osv.osv_memory):
during recursion
@param suffix: optional suffix to append to the field path to reach the main object
"""
if relation_fields is None:
relation_fields = []
local_rel_fields = []
@@ -222,7 +222,7 @@ class share_create(osv.osv_memory):
"""
model_access_obj = self.pool.get('ir.model.access')
user_obj = self.pool.get('res.users')
target_model_ids = [x[1].id for x in fields_relations]
target_model_ids = [x[1].id for x in fields_relations]
perms_to_add = (mode == 'readonly') and READ_ONLY_ACCESS or FULL_ACCESS
current_user = user_obj.browse(cr, uid, uid, context=context)
@@ -296,7 +296,7 @@ class share_create(osv.osv_memory):
related_domain = []
for element in domain:
if domain_expr._is_leaf(element):
left, operator, right = element
left, operator, right = element
left = '%s.%s'%(rel_field, left)
element = left, operator, right
related_domain.append(element)
@@ -368,7 +368,7 @@ class share_create(osv.osv_memory):
user_obj.write(cr, 1, user_ids, {
'groups_id': [(4,group_id)],
})
self._setup_action_and_shortcut(cr, uid, wizard_data, user_ids,
self._setup_action_and_shortcut(cr, uid, wizard_data, user_ids,
(wizard_data.user_type == 'new'), context=context)
@@ -388,7 +388,7 @@ class share_create(osv.osv_memory):
obj0, obj1, obj2, obj3 = self._get_relationship_classes(cr, uid, model, context=context)
mode = wizard_data.access_mode
# Add access to [obj0] and [obj1] according to chosen mode
# Add access to [obj0] and [obj1] according to chosen mode
self._add_access_rights_for_share_group(cr, uid, group_id, mode, obj0, context=context)
self._add_access_rights_for_share_group(cr, uid, group_id, mode, obj1, context=context)
@@ -399,18 +399,18 @@ class share_create(osv.osv_memory):
# IR.RULES
# A. On [obj0]: 1 rule with domain of shared action
# B. For each model in [obj1]: 1 rule in the form:
# B. For each model in [obj1]: 1 rule in the form:
# many2one_rel.domain_of_obj0
# where many2one_rel is the many2one used in the definition of the
# one2many, and domain_of_obj0 is the sharing domain
# For example if [obj0] is project.project with a domain of
# For example if [obj0] is project.project with a domain of
# ['id', 'in', [1,2]]
# then we will have project.task in [obj1] and we need to create this
# then we will have project.task in [obj1] and we need to create this
# ir.rule on project.task:
# ['project_id.id', 'in', [1,2]]
# C. And on [obj0], [obj1], [obj2], [obj3]: add all rules from all groups of
# the user that is sharing
# (Warning: rules must be copied instead of linked if they contain a reference
# C. And on [obj0], [obj1], [obj2], [obj3]: add all rules from all groups of
# the user that is sharing
# (Warning: rules must be copied instead of linked if they contain a reference
# to uid, and it must be replaced correctly)
rule_obj = self.pool.get('ir.rule')
# A.
@@ -443,6 +443,7 @@ class share_create(osv.osv_memory):
}
def send_emails(self, cr, uid, ids, context=None):
email_message_obj = self.pool.get('email.message')
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if not user.user_email:
raise osv.except_osv(_('Email required'), _('The current user must have an email address configured in User Preferences to be able to send outgoing emails.'))
@@ -462,11 +463,12 @@ class share_create(osv.osv_memory):
body += _("This additional data has been automatically added to your current access.\n")
body += _("You may use your existing login and password to view it. As a reminder, your login is %s.\n") % result_line.login
if not tools.email_send(
if not email_message_obj.email_send(
user.user_email,
[email_to],
subject,
body):
body,
model='share.wizard'):
self.__logger.warning('Failed to send sharing email from %s to %s', user.user_email, email_to)
return {'type': 'ir.actions.act_window_close'}
share_create()
+4 -3
View File
@@ -49,7 +49,7 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values
@return : Dictionary value for created view of particular survey pages.
"""
result = super(survey_question_wiz, self).fields_view_get(cr, uid, view_id, \
view_type, context, toolbar,submenu)
@@ -61,6 +61,7 @@ class survey_question_wiz(osv.osv_memory):
sur_response_obj = self.pool.get('survey.response')
que_col_head = self.pool.get('survey.question.column.heading')
user_obj = self.pool.get('res.users')
email_message_obj = self.pool.get('email.message')
if context is None:
context = {}
if view_type in ['form']:
@@ -79,7 +80,7 @@ class survey_question_wiz(osv.osv_memory):
wiz_id = surv_name_wiz.create(cr, uid, res_data)
sur_name_rec = surv_name_wiz.browse(cr, uid, wiz_id, context=context)
context.update({'sur_name_id' :wiz_id})
if context.has_key('active_id'):
context.pop('active_id')
@@ -428,7 +429,7 @@ 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) + " Give Response Of " + survey_data.title + " Survey.\n\n Thanks,"
tools.email_send(user_email, [resp_email], "Survey Answer Of " + str(user_name) , mail, attach = attachments)
email_message_obj.email_send(user_email, [resp_email], "Survey Answer Of " + str(user_name) , mail, model='survey.question.wiz', attach = attachments)
xml_form = etree.Element('form', {'string': _('Complete Survey Answer')})
etree.SubElement(xml_form, 'separator', {'string': 'Complete Survey', 'colspan': "4"})
@@ -102,6 +102,7 @@ class survey_send_invitation(osv.osv_memory):
partner_ids = record['partner_ids']
user_ref= self.pool.get('res.users')
survey_ref= self.pool.get('survey')
email_message_obj = self.pool.get('email.message')
model_data_obj = self.pool.get('ir.model.data')
group_id = model_data_obj._get_id(cr, uid, 'survey', 'group_survey_user')
@@ -151,8 +152,8 @@ class survey_send_invitation(osv.osv_memory):
mail = record['mail']%{'login':addr.email, 'passwd':user.password, \
'name' : addr.name}
if record['send_mail_existing']:
tools.email_send(record['mail_from'], [addr.email] , \
record['mail_subject_existing'] , mail)
email_message_obj.email_send(record['mail_from'], [addr.email] , \
record['mail_subject_existing'] , mail, model='survey.send.invitation')
existing+= "- %s (Login: %s, Password: %s)\n" % (user.name, addr.email, \
user.password)
continue
@@ -162,8 +163,8 @@ class survey_send_invitation(osv.osv_memory):
mail = record['mail']%{'login': user_email.login, \
'passwd': user_email.password, 'name': addr.name}
if record['send_mail_existing']:
tools.email_send(record['mail_from'], [addr.email],\
record['mail_subject_existing'], mail)
email_message_obj.email_send(record['mail_from'], [addr.email],\
record['mail_subject_existing'], mail, model='survey.send.invitation')
res_user+= "- %s (Login: %s, Password: %s)\n" % \
(user_email.name, user_email.login, user_email.password)
continue
@@ -171,8 +172,8 @@ class survey_send_invitation(osv.osv_memory):
out+= addr.email + ',' + passwd + '\n'
mail= record['mail'] % {'login' : addr.email, 'passwd' : passwd, 'name' : addr.name}
if record['send_mail']:
ans = tools.email_send(record['mail_from'], [addr.email], \
record['mail_subject'], mail,attach = attachments)
ans = email_message_obj.email_send(record['mail_from'], [addr.email], \
record['mail_subject'], mail, model='survey.send.invitation', attach = attachments)
if ans:
res_data = {'name': addr.name or 'Unknown',