[REVIEW+MERGE] merged from ysa-emails-framework-addons
bzr revid: hmo@tinyerp.com-20110301074005-aywzcqnyonkuygrj
This commit is contained in:
commit
d4d4411229
|
@ -34,73 +34,20 @@ class email_compose_message(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context)
|
||||
if model not in email_model:
|
||||
return result
|
||||
model_obj = self.pool.get(model)
|
||||
data = model_obj.browse(cr, uid , resource_id, context)
|
||||
result.update({
|
||||
'name' : data.name,
|
||||
'email_to' : data.email_from,
|
||||
'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or False,
|
||||
'description' : '\n' + (tools.ustr(data.user_id.signature or '')),
|
||||
'email_cc' : tools.ustr(data.email_cc or '')
|
||||
})
|
||||
if hasattr(data, 'section_id'):
|
||||
result.update({'reply_to' : data.section_id and data.section_id.reply_to or False})
|
||||
return result
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
|
||||
if context.get('active_id',False) and context.get('email_model',False) and context.get('email_model') in email_model:
|
||||
vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context)
|
||||
if 'name' in fields:
|
||||
result.update({'name' : vals.get('name','')})
|
||||
|
||||
if 'email_to' in fields:
|
||||
result.update({'email_to' : vals.get('email_to','')})
|
||||
|
||||
if 'email_from' in fields:
|
||||
result.update({'email_from' : vals.get('email_from','')})
|
||||
|
||||
if 'description' in fields:
|
||||
result.update({'description' : vals.get('description','')})
|
||||
|
||||
if 'model' in fields:
|
||||
result['model'] = context.get('email_model','')
|
||||
|
||||
if 'email_cc' in fields:
|
||||
result.update({'email_cc' : vals.get('email_cc','')})
|
||||
|
||||
if 'res_id' in fields:
|
||||
result['res_id'] = context.get('active_id',0)
|
||||
|
||||
if 'reply_to' in fields:
|
||||
result['reply_to'] = vals.get('reply_to','')
|
||||
|
||||
return result
|
||||
|
||||
def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if context.get('mail') == 'reply':
|
||||
return {'value':{}}
|
||||
result = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context)
|
||||
value = {}
|
||||
if not result.get('value'):
|
||||
result.update({'value':{}})
|
||||
if resource_id and model in email_model:
|
||||
vals = self.get_value(cr, uid, model, resource_id, context)
|
||||
result['value'].update({
|
||||
'email_from': vals.get('email_from',''),
|
||||
'email_to': vals.get('email_to',''),
|
||||
'name': vals.get('name',''),
|
||||
'description': vals.get('description',''),
|
||||
'email_cc': vals.get('email_cc',''),
|
||||
'email_bcc': vals.get('email_bcc',''),
|
||||
'reply_to': vals.get('reply_to',''),
|
||||
})
|
||||
if model in email_model and resource_id:
|
||||
model_obj = self.pool.get(model)
|
||||
data = model_obj.browse(cr, uid , resource_id, context)
|
||||
result.update({
|
||||
'name' : data.name,
|
||||
'email_to' : data.email_from,
|
||||
'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or False,
|
||||
'description' : '\n' + (tools.ustr(data.user_id.signature or '')),
|
||||
'email_cc' : tools.ustr(data.email_cc or ''),
|
||||
'model': model,
|
||||
'res_id': resource_id,
|
||||
})
|
||||
if hasattr(data, 'section_id'):
|
||||
result.update({'reply_to' : data.section_id and data.section_id.reply_to or False})
|
||||
return result
|
||||
|
||||
email_compose_message()
|
||||
|
|
|
@ -32,75 +32,68 @@ class email_compose_message(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
|
||||
message_pool = self.pool.get('email.message')
|
||||
message_id = context.get('message_id', False)
|
||||
if message_id:
|
||||
message_data = message_pool.browse(cr, uid, int(message_id), context)
|
||||
if 'message_id' in fields:
|
||||
result['message_id'] = message_data and message_data.message_id
|
||||
vals = {}
|
||||
if context.get('email_model') and context.get('email_res_id'):
|
||||
vals = self.get_value(cr, uid, context.get('email_model'), context.get('email_res_id'), context)
|
||||
elif context.get('message_id', False):
|
||||
vals = self.get_message_data(cr, uid, int(context.get('message_id', False)), context)
|
||||
else:
|
||||
result['model'] = context.get('email_model', False)
|
||||
|
||||
if 'attachment_ids' in fields:
|
||||
result['attachment_ids'] = message_data and message_pool.read(cr, uid, message_id, ['attachment_ids'])['attachment_ids']
|
||||
if not vals:
|
||||
return result
|
||||
|
||||
if 'res_id' in fields:
|
||||
result['res_id'] = message_data and message_data.res_id
|
||||
if 'name' in fields:
|
||||
result.update({'name' : vals.get('name','')})
|
||||
|
||||
if 'email_from' in fields:
|
||||
result['email_from'] = message_data and message_data.email_to
|
||||
if 'email_to' in fields:
|
||||
result.update({'email_to' : vals.get('email_to','')})
|
||||
|
||||
if 'email_to' in fields:
|
||||
result['email_to'] = message_data and message_data.email_from
|
||||
if 'email_from' in fields:
|
||||
result.update({'email_from' : vals.get('email_from','')})
|
||||
|
||||
if 'email_cc' in fields:
|
||||
result['email_cc'] = message_data and message_data.email_cc
|
||||
if 'description' in fields:
|
||||
result.update({'description' : vals.get('description','')})
|
||||
|
||||
if 'email_bcc' in fields:
|
||||
result['email_bcc'] = message_data and message_data.email_bcc
|
||||
if 'model' in fields:
|
||||
result.update({'model' : vals.get('model','')})
|
||||
|
||||
if 'name' in fields:
|
||||
result['name'] = tools.ustr(message_data and message_data.name or '')
|
||||
if context.get('mail','') == 'reply':
|
||||
result['name'] = "Re :- " + result['name']
|
||||
if 'email_cc' in fields:
|
||||
result.update({'email_cc' : vals.get('email_cc','')})
|
||||
|
||||
if 'description' in fields:
|
||||
description = message_data and message_data.description and message_data.description or ''
|
||||
if context.get('mail','') == 'reply':
|
||||
header = '-------- Original Message --------'
|
||||
sender = 'From: %s' % tools.ustr(message_data.email_from or '')
|
||||
email_to = 'To: %s' % tools.ustr(message_data.email_to or '')
|
||||
sentdate = 'Date: %s' % message_data.date
|
||||
desc = '\n > \t %s' % tools.ustr(description.replace('\n', "\n > \t") or '')
|
||||
result['description'] = '\n'.join([header, sender, email_to, sentdate, desc])
|
||||
else:
|
||||
result['description'] = description
|
||||
if 'email_bcc' in fields:
|
||||
result.update({'email_bcc' : vals.get('email_bcc','')})
|
||||
|
||||
if 'reply_to' in fields:
|
||||
result['reply_to'] = message_data and message_data.reply_to
|
||||
if 'res_id' in fields:
|
||||
result.update({'res_id' : vals.get('res_id',0)})
|
||||
|
||||
if 'model' in fields:
|
||||
result['model'] = message_data and message_data.model
|
||||
if 'reply_to' in fields:
|
||||
result['reply_to'] = vals.get('reply_to','')
|
||||
|
||||
if 'user_id' in fields:
|
||||
result['user_id'] = message_data and message_data.user_id and message_data.user_id.id or False
|
||||
if 'message_id' in fields:
|
||||
result['message_id'] = vals.get('message_id','')
|
||||
|
||||
if 'references' in fields:
|
||||
result['references'] = message_data and message_data.references and tools.ustr(message_data.references)
|
||||
if 'attachment_ids' in fields:
|
||||
result['attachment_ids'] = vals.get('attachment_ids',[])
|
||||
|
||||
if 'sub_type' in fields:
|
||||
result['sub_type'] = message_data and message_data.sub_type
|
||||
if 'user_id' in fields:
|
||||
result['user_id'] = vals.get('user_id',False)
|
||||
|
||||
if 'headers' in fields:
|
||||
result['headers'] = message_data and message_data.headers
|
||||
if 'references' in fields:
|
||||
result['references'] = vals.get('references',False)
|
||||
|
||||
if 'priority' in fields:
|
||||
result['priority'] = message_data and message_data.priority
|
||||
if 'sub_type' in fields:
|
||||
result['sub_type'] = vals.get('sub_type',False)
|
||||
|
||||
if 'debug' in fields:
|
||||
result['debug'] = message_data and message_data.debug
|
||||
if 'headers' in fields:
|
||||
result['headers'] = vals.get('headers',False)
|
||||
|
||||
if 'model' in fields and context.get('email_model',False):
|
||||
result['model'] = context.get('email_model')
|
||||
if 'priority' in fields:
|
||||
result['priority'] = vals.get('priority',False)
|
||||
|
||||
if 'debug' in fields:
|
||||
result['debug'] = vals.get('debug',False)
|
||||
|
||||
return result
|
||||
|
||||
def _get_records(self, cr, uid, context=None):
|
||||
|
@ -132,11 +125,99 @@ class email_compose_message(osv.osv_memory):
|
|||
'res_id':fields.selection(_get_records, 'Referred Document'),
|
||||
}
|
||||
|
||||
def get_value(self, cr, uid, model, resource_id, context=None):
|
||||
def get_value(self, cr, uid, model, res_id, context=None):
|
||||
return {}
|
||||
|
||||
def get_message_data(self, cr, uid, message_id, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = {}
|
||||
message_pool = self.pool.get('email.message')
|
||||
if message_id:
|
||||
message_data = message_pool.browse(cr, uid, message_id, context)
|
||||
if 'message_id' in fields:
|
||||
result['message_id'] = message_data and message_data.message_id or False
|
||||
|
||||
if 'attachment_ids' in fields:
|
||||
result['attachment_ids'] = message_data and message_pool.read(cr, uid, message_id, ['attachment_ids'])['attachment_ids'] or []
|
||||
|
||||
if 'res_id' in fields:
|
||||
result['res_id'] = message_data and message_data.res_id or False
|
||||
|
||||
if 'email_from' in fields:
|
||||
result['email_from'] = message_data and message_data.email_to or False
|
||||
|
||||
if 'email_to' in fields:
|
||||
result['email_to'] = message_data and message_data.email_from or False
|
||||
|
||||
if 'email_cc' in fields:
|
||||
result['email_cc'] = message_data and message_data.email_cc or False
|
||||
|
||||
if 'email_bcc' in fields:
|
||||
result['email_bcc'] = message_data and message_data.email_bcc or False
|
||||
|
||||
if 'name' in fields:
|
||||
result['name'] = tools.ustr(message_data and message_data.name or '')
|
||||
if context.get('mail','') == 'reply':
|
||||
result['name'] = "Re :- " + result['name']
|
||||
|
||||
if 'description' in fields:
|
||||
description = message_data and message_data.description and message_data.description or ''
|
||||
if context.get('mail','') == 'reply':
|
||||
header = '-------- Original Message --------'
|
||||
sender = 'From: %s' % tools.ustr(message_data.email_from or '')
|
||||
email_to = 'To: %s' % tools.ustr(message_data.email_to or '')
|
||||
sentdate = 'Date: %s' % message_data.date
|
||||
desc = '\n > \t %s' % tools.ustr(description.replace('\n', "\n > \t") or '')
|
||||
result['description'] = '\n'.join([header, sender, email_to, sentdate, desc])
|
||||
else:
|
||||
result['description'] = description
|
||||
|
||||
if 'reply_to' in fields:
|
||||
result['reply_to'] = message_data and message_data.reply_to or False
|
||||
|
||||
if 'model' in fields:
|
||||
result['model'] = message_data and message_data.model or False
|
||||
|
||||
if 'user_id' in fields:
|
||||
result['user_id'] = message_data and message_data.user_id and message_data.user_id.id or False
|
||||
|
||||
if 'references' in fields:
|
||||
result['references'] = message_data and message_data.references and tools.ustr(message_data.references) or False
|
||||
|
||||
if 'sub_type' in fields:
|
||||
result['sub_type'] = message_data and message_data.sub_type or False
|
||||
|
||||
if 'headers' in fields:
|
||||
result['headers'] = message_data and message_data.headers or False
|
||||
|
||||
if 'priority' in fields:
|
||||
result['priority'] = message_data and message_data.priority or False
|
||||
|
||||
if 'debug' in fields:
|
||||
result['debug'] = message_data and message_data.debug or False
|
||||
|
||||
return result
|
||||
|
||||
def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None):
|
||||
return {'value':{}}
|
||||
if context is None:
|
||||
context = {}
|
||||
if context.get('mail') == 'reply':
|
||||
return {'value':{}}
|
||||
result = {}
|
||||
if resource_id and model:
|
||||
vals = self.get_value(cr, uid, model, resource_id, context)
|
||||
if vals:
|
||||
result.update({
|
||||
'email_from': vals.get('email_from',''),
|
||||
'email_to': vals.get('email_to',''),
|
||||
'name': vals.get('name',''),
|
||||
'description': vals.get('description',''),
|
||||
'email_cc': vals.get('email_cc',''),
|
||||
'email_bcc': vals.get('email_bcc',''),
|
||||
'reply_to': vals.get('reply_to',''),
|
||||
})
|
||||
return {'value': result}
|
||||
|
||||
def on_change_smtp_server(self, cr, uid, ids, smtp_server_id, email_from, context=None):
|
||||
if not email_from and smtp_server_id:
|
||||
|
|
|
@ -27,14 +27,6 @@ from tools.translate import _
|
|||
class email_compose_message(osv.osv_memory):
|
||||
_inherit = 'email.compose.message'
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
|
||||
if context.get('email_model',False) and context.get('email_model') == 'hr.evaluation.interview' and 'model' in fields:
|
||||
result['model'] = context.get('email_model','')
|
||||
return result
|
||||
|
||||
def _get_records(self, cr, uid, context=None):
|
||||
"""
|
||||
Return Records of particular Model
|
||||
|
@ -53,22 +45,16 @@ class email_compose_message(osv.osv_memory):
|
|||
'res_id':fields.selection(_get_records, 'Referred Document'),
|
||||
}
|
||||
|
||||
def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None):
|
||||
def get_value(self, cr, uid, model, resource_id, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if context.get('mail') == 'reply':
|
||||
return {'value':{}}
|
||||
result = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context)
|
||||
value = {}
|
||||
if not result.get('value'):
|
||||
result.update({'value':{}})
|
||||
|
||||
result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context)
|
||||
if model == 'hr.evaluation.interview' and resource_id:
|
||||
model_pool = self.pool.get(model)
|
||||
record_data = model_pool.browse(cr, uid, resource_id, context)
|
||||
if record_data.state == "waiting_answer":
|
||||
msg = _("Hello %s, \n\n Kindly post your response for '%s' survey interview. \n\n Thanks,") %(record_data.user_to_review_id.name, record_data.survey_id.title)
|
||||
result['value'].update({
|
||||
result.update({
|
||||
'email_from': tools.config.get('email_from',''),
|
||||
'email_to': record_data.user_to_review_id.work_email or False,
|
||||
'name': _("Reminder to fill up Survey"),
|
||||
|
|
|
@ -30,85 +30,37 @@ class email_compose_message(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context)
|
||||
if model != 'project.task':
|
||||
return result
|
||||
task_pool = self.pool.get('project.task')
|
||||
task_data = task_pool.browse(cr, uid, resource_id, context=context)
|
||||
partner = task_data.partner_id or task_data.project_id.partner_id
|
||||
|
||||
result.update({'email_from': task_data.user_id and task_data.user_id.user_email or False})
|
||||
val = {
|
||||
'name': task_data.name,
|
||||
'user_id': task_data.user_id.name,
|
||||
'task_id': "%d/%d" % (task_data.project_id.id, task_data.id),
|
||||
'date_start': task_data.date_start,
|
||||
'date': task_data.date_end,
|
||||
'state': task_data.state
|
||||
}
|
||||
header = (task_data.project_id.warn_header or '') % val
|
||||
footer = (task_data.project_id.warn_footer or '') % val
|
||||
description = u'%s\n %s\n %s\n\n \n%s' % (header, task_data.description or '', footer, task_data.user_id and task_data.user_id.signature)
|
||||
result.update({'description': description or False})
|
||||
result.update({'email_to': task_data.project_id.user_id and task_data.project_id.user_id.user_email or False})
|
||||
if partner and len(partner.address) and 'email_to' in fields:
|
||||
result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email})
|
||||
result.update({'name': _("Task '%s' Closed") % task_data.name})
|
||||
|
||||
return result
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
|
||||
if context.get('active_id',False) and context.get('email_model',False) and context.get('email_model') == 'project.task':
|
||||
if model == 'project.task' and resource_id:
|
||||
task_pool = self.pool.get('project.task')
|
||||
task_data = task_pool.browse(cr, uid, context.get('active_id'), context=context)
|
||||
task_data = task_pool.browse(cr, uid, resource_id, context=context)
|
||||
partner = task_data.partner_id or task_data.project_id.partner_id
|
||||
|
||||
if task_data.project_id.warn_manager and (not task_data.project_id.user_id or task_data.project_id.user_id and not task_data.project_id.user_id.user_email) :
|
||||
raise osv.except_osv(_('Error'), _("Please specify the Project Manager or email address of Project Manager."))
|
||||
elif task_data.project_id.warn_customer and (not partner or not len(partner.address) or (partner and len(partner.address) and not partner.address[0].email)):
|
||||
raise osv.except_osv(_('Error'), _("Please specify the Customer or email address of Customer."))
|
||||
vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context)
|
||||
if 'email_from' in fields:
|
||||
result.update({'email_from': vals.get('email_from','')})
|
||||
|
||||
if 'description' in fields:
|
||||
result.update({'description': vals.get('description','')})
|
||||
|
||||
if 'email_to' in fields:
|
||||
result.update({'description': vals.get('description','')})
|
||||
|
||||
if 'name' in fields:
|
||||
result.update({'description': vals.get('name','')})
|
||||
|
||||
if 'model' in fields:
|
||||
result.update({'model':context.get('email_model')})
|
||||
|
||||
if 'res_id' in fields:
|
||||
result.update({'res_id':context.get('active_id')})
|
||||
|
||||
return result
|
||||
|
||||
def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if context.get('mail') == 'reply':
|
||||
return {'value':{}}
|
||||
result = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context)
|
||||
if not result.get('value'):
|
||||
result.update({'value':{}})
|
||||
if resource_id and model == 'project.task':
|
||||
vals = self.get_value(cr, uid, model, resource_id, context)
|
||||
result.get('value',{}).update({
|
||||
'email_from': vals.get('email_from',''),
|
||||
'email_to': vals.get('email_to',''),
|
||||
'description': vals.get('description',''),
|
||||
'name': vals.get('name',''),
|
||||
'email_cc': vals.get('email_cc',''),
|
||||
'email_bcc': vals.get('email_bcc',''),
|
||||
'reply_to': vals.get('reply_to',''),
|
||||
result.update({'email_from': task_data.user_id and task_data.user_id.user_email or False})
|
||||
val = {
|
||||
'name': task_data.name,
|
||||
'user_id': task_data.user_id.name,
|
||||
'task_id': "%d/%d" % (task_data.project_id.id, task_data.id),
|
||||
'date_start': task_data.date_start,
|
||||
'date': task_data.date_end,
|
||||
'state': task_data.state
|
||||
}
|
||||
header = (task_data.project_id.warn_header or '') % val
|
||||
footer = (task_data.project_id.warn_footer or '') % val
|
||||
description = u'%s\n %s\n %s\n\n \n%s' % (header, task_data.description or '', footer, task_data.user_id and task_data.user_id.signature)
|
||||
if partner and len(partner.address) and 'email_to' in fields:
|
||||
result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email})
|
||||
result.update({
|
||||
'description': description or False,
|
||||
'email_to': task_data.project_id.user_id and task_data.project_id.user_id.user_email or False,
|
||||
'name': _("Task '%s' Closed") % task_data.name,
|
||||
'model': model,
|
||||
'res_id': resource_id,
|
||||
})
|
||||
|
||||
return result
|
||||
|
||||
email_compose_message()
|
||||
|
|
|
@ -30,72 +30,27 @@ class email_compose_message(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context)
|
||||
if model != 'project.scrum.meeting':
|
||||
return result
|
||||
meeting_pool = self.pool.get('project.scrum.meeting')
|
||||
user_pool = self.pool.get('res.users')
|
||||
meeting = meeting_pool.browse(cr, uid, resource_id, context=context)
|
||||
if model == 'project.scrum.meeting' and resource_id:
|
||||
meeting_pool = self.pool.get('project.scrum.meeting')
|
||||
user_pool = self.pool.get('res.users')
|
||||
meeting = meeting_pool.browse(cr, uid, resource_id, context=context)
|
||||
|
||||
sprint = meeting.sprint_id
|
||||
user_data = user_pool.browse(cr, uid, uid, context=context)
|
||||
result.update({'email_from': user_data.address_id and user_data.address_id.email or False})
|
||||
sprint = meeting.sprint_id
|
||||
user_data = user_pool.browse(cr, uid, uid, context=context)
|
||||
result.update({'email_from': user_data.address_id and user_data.address_id.email or False})
|
||||
|
||||
if sprint.scrum_master_id and sprint.scrum_master_id.user_email:
|
||||
result.update({'email_to': sprint.scrum_master_id.user_email})
|
||||
if sprint.product_owner_id and sprint.product_owner_id.user_email:
|
||||
result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + sprint.product_owner_id.user_email or sprint.product_owner_id.user_email})
|
||||
if sprint.scrum_master_id and sprint.scrum_master_id.user_email:
|
||||
result.update({'email_to': sprint.scrum_master_id.user_email})
|
||||
if sprint.product_owner_id and sprint.product_owner_id.user_email:
|
||||
result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + sprint.product_owner_id.user_email or sprint.product_owner_id.user_email})
|
||||
|
||||
subject = _("Scrum Meeting : %s") %(meeting.date)
|
||||
result.update({'name': subject})
|
||||
message = _("Hello , \nI am sending you Scrum Meeting : %s for the Sprint '%s' of Project '%s'") %(meeting.date, sprint.name, sprint.project_id.name)
|
||||
result.update({'description': message})
|
||||
return result
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
|
||||
|
||||
if context.get('active_id',False) and context.get('email_model',False) and context.get('email_model') == 'project.scrum.meeting':
|
||||
vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context)
|
||||
if 'email_from' in fields:
|
||||
result.update({'email_from': vals.get('email_from','')})
|
||||
|
||||
if 'email_to' in fields:
|
||||
result.update({'email_to': vals.get('email_to','')})
|
||||
|
||||
if 'name' in fields:
|
||||
result.update({'name': vals.get('name','')})
|
||||
|
||||
if 'description' in fields:
|
||||
result.update({'description': vals.get('description','')})
|
||||
|
||||
if 'model' in fields:
|
||||
result.update({'model':context.get('email_model')})
|
||||
|
||||
if 'res_id' in fields:
|
||||
result.update({'res_id':context.get('active_id')})
|
||||
|
||||
return result
|
||||
|
||||
def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if context.get('mail') == 'reply':
|
||||
return {'value':{}}
|
||||
result = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context)
|
||||
if not result.get('value'):
|
||||
result.update({'value':{}})
|
||||
if resource_id and model == 'project.scrum.meeting':
|
||||
vals = self.get_value(cr, uid, model, resource_id, context)
|
||||
result.get('value',{}).update({
|
||||
'email_from': vals.get('email_from',''),
|
||||
'email_to': vals.get('email_to',''),
|
||||
'description': vals.get('description',''),
|
||||
'name': vals.get('name',''),
|
||||
'email_cc': vals.get('email_cc',''),
|
||||
'email_bcc': vals.get('email_bcc',''),
|
||||
'reply_to': vals.get('reply_to',''),
|
||||
subject = _("Scrum Meeting : %s") %(meeting.date)
|
||||
message = _("Hello , \nI am sending you Scrum Meeting : %s for the Sprint '%s' of Project '%s'") %(meeting.date, sprint.name, sprint.project_id.name)
|
||||
result.update({
|
||||
'name': subject,
|
||||
'description': message,
|
||||
'model': model,
|
||||
'res_id': resource_id
|
||||
})
|
||||
return result
|
||||
|
||||
|
|
Loading…
Reference in New Issue