diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index 2ddcc8268c4..02d0ad646d0 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -108,7 +108,7 @@
@@ -227,7 +227,7 @@
icon="terp-document-new" type="action" />
diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml
index 756df5ca1a6..fc8be9ae32a 100644
--- a/addons/crm/crm_opportunity_view.xml
+++ b/addons/crm/crm_opportunity_view.xml
@@ -61,7 +61,7 @@
@@ -183,7 +183,7 @@
icon="terp-document-new" type="action" />
diff --git a/addons/crm/wizard/email_compose_message.py b/addons/crm/wizard/email_compose_message.py
index d24c06ad70c..8f995b5e256 100644
--- a/addons/crm/wizard/email_compose_message.py
+++ b/addons/crm/wizard/email_compose_message.py
@@ -38,13 +38,13 @@ class email_compose_message(osv.osv_memory):
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,
+ 'name' : data.name or False,
+ 'email_to' : data.email_from or False,
'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,
+ 'model': model or False,
+ 'res_id': resource_id or False,
})
if hasattr(data, 'section_id'):
result.update({'reply_to' : data.section_id and data.section_id.reply_to or False})
diff --git a/addons/crm_claim/crm_claim_view.xml b/addons/crm_claim/crm_claim_view.xml
index aac8ef990b1..c10d1d8565e 100644
--- a/addons/crm_claim/crm_claim_view.xml
+++ b/addons/crm_claim/crm_claim_view.xml
@@ -215,7 +215,7 @@
icon="terp-document-new" type="action" />
diff --git a/addons/crm_fundraising/crm_fundraising_view.xml b/addons/crm_fundraising/crm_fundraising_view.xml
index c989af8b4be..33e8037964b 100644
--- a/addons/crm_fundraising/crm_fundraising_view.xml
+++ b/addons/crm_fundraising/crm_fundraising_view.xml
@@ -206,7 +206,7 @@
icon="terp-document-new" type="action" />
diff --git a/addons/crm_helpdesk/crm_helpdesk_view.xml b/addons/crm_helpdesk/crm_helpdesk_view.xml
index 14d76369927..ca8c0be1851 100644
--- a/addons/crm_helpdesk/crm_helpdesk_view.xml
+++ b/addons/crm_helpdesk/crm_helpdesk_view.xml
@@ -140,7 +140,7 @@
icon="terp-document-new" type="action" />
diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py
index ebd2003496e..ea09a7fff8b 100644
--- a/addons/email_template/email_template.py
+++ b/addons/email_template/email_template.py
@@ -191,7 +191,7 @@ This is useful for CRM leads for example"),
'res_model': 'email.compose.message',
'src_model': src_obj,
'view_type': 'form',
- 'context': "{'email_model':'%s','template_id':'%d','src_rec_id':active_id,'src_rec_ids':active_ids}" % (src_obj, template.id),
+ 'context': "{'email_model':'%s', 'email_res_id': active_id,'template_id':'%d','src_rec_id':active_id,'src_rec_ids':active_ids}" % (src_obj, template.id),
'view_mode':'form,tree',
'view_id': res_id,
'target': 'new',
diff --git a/addons/email_template/wizard/email_compose_message.py b/addons/email_template/wizard/email_compose_message.py
index 01f31b0a7fa..37e4c3df9f0 100644
--- a/addons/email_template/wizard/email_compose_message.py
+++ b/addons/email_template/wizard/email_compose_message.py
@@ -26,55 +26,82 @@ import tools
class email_compose_message(osv.osv_memory):
_name = 'email.compose.message'
_inherit = 'email.compose.message'
- def default_get(self, cr, uid, fields, context=None):
+
+ def get_template_data(self, cr, uid, res_id, template_id, context=None):
if context is None:
context = {}
- result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
+ result = {}
template_pool = self.pool.get('email.template')
- model_pool = self.pool.get('ir.model')
- template_id = context.get('template_id', False)
if template_id:
template = template_pool.get_email_template(cr, uid, template_id=template_id, context=context)
def _get_template_value(field):
if not template:
return False
- if len(context['src_rec_ids']) > 1: # Multiple Mail: Gets original template values for multiple email change
+ if len(context.get('src_rec_ids',[])) > 1: # Multiple Mail: Gets original template values for multiple email change
return getattr(template, field)
else: # Simple Mail: Gets computed template values
- return template_pool.get_template_value(cr, uid, getattr(template, field), template.model, context.get('active_id'), context)
+ return template_pool.get_template_value(cr, uid, getattr(template, field), template.model, context.get('email_res_id'), context)
+ result.update({
+ 'template_id' : template.id,
+ 'smtp_server_id' : template.smtp_server_id.id,
+ 'description' : _get_template_value('description') or False,
+ 'name' : _get_template_value('subject') or False,
+ 'attachment_ids' : template_pool.read(cr, uid, template.id, ['attachment_ids'])['attachment_ids'] or [],
+ 'res_id' : res_id or False,
+ 'email_to' : _get_template_value('email_to') or False,
+ 'email_cc' : _get_template_value('email_cc') or False,
+ 'email_bcc' : _get_template_value('email_bcc') or False,
+ 'reply_to' : _get_template_value('reply_to') or False,
+ 'model' : template.model or False,
+ })
+ return result
- if 'template_id' in fields:
- result['template_id'] = template.id
+ 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)
+ template_id = context.get('template_id', False)
+ vals = {}
+ if template_id and context.get('email_model') and context.get('email_res_id'):
+ vals = self.get_template_data(cr, uid, context.get('email_res_id'), template_id, context)
+ else:
+ result['model'] = context.get('email_model', False)
- if 'smtp_server_id' in fields:
- result['smtp_server_id'] = template.smtp_server_id.id
+ if not vals:
+ return result
- if 'attachment_ids' in fields:
- result['attachment_ids'] = template_pool.read(cr, uid, template.id, ['attachment_ids'])['attachment_ids']
+ if 'template_id' in fields:
+ result.update({'template_id' : vals.get('template_id', False)})
- if 'model' in fields:
- result['model'] = context.get('email_model')
+ if 'smtp_server_id' in fields:
+ result.update({'smtp_server_id' : vals.get('smtp_server_id', False)})
- if 'res_id' in fields:
- result['res_id'] = context.get('active_id')
+ if 'attachment_ids' in fields:
+ result.update({'attachment_ids' : vals.get('attachment_ids', False)})
- if 'email_to' in fields:
- result['email_to'] = _get_template_value('email_to')
+ if 'model' in fields:
+ result.update({'model' : vals.get('model', False)})
- if 'email_cc' in fields:
- result['email_cc'] = _get_template_value('email_cc')
+ if 'res_id' in fields:
+ result.update({'res_id' : vals.get('res_id', False)})
- if 'email_bcc' in fields:
- result['email_bcc'] = _get_template_value('email_bcc')
+ if 'email_to' in fields:
+ result.update({'email_to' : vals.get('email_to', False)})
- if 'name' in fields:
- result['name'] = _get_template_value('subject')
+ if 'email_cc' in fields:
+ result.update({'email_cc' : vals.get('email_cc', False)})
- if 'description' in fields:
- result['description'] = _get_template_value('description')
+ if 'email_bcc' in fields:
+ result.update({'email_bcc' : vals.get('email_bcc', False)})
- if 'reply_to' in fields:
- result['reply_to'] = _get_template_value('reply_to')
+ if 'name' in fields:
+ result.update({'name' : vals.get('name', False)})
+
+ if 'description' in fields:
+ result.update({'description' : vals.get('description', False)})
+
+ if 'reply_to' in fields:
+ result.update({'reply_to' : vals.get('reply_to', False)})
return result
@@ -107,18 +134,10 @@ class email_compose_message(osv.osv_memory):
context = {}
if context.get('mail') == 'reply':
return {'value':{}}
- email_temp_previ_pool = self.pool.get('email_template.preview')
result = self.on_change_referred_doc(cr, uid, [], model, resource_id, context=context)
vals = result.get('value',{})
if template_id and resource_id:
- email_temp_pool = self.pool.get('email.template')
- email_temp_data = email_temp_pool.browse(cr, uid, template_id, context)
- vals.update({'smtp_server_id': email_temp_data.smtp_server_id and email_temp_data.smtp_server_id.id or False})
- context.update({'template_id': template_id})
- value = email_temp_previ_pool.on_change_ref(cr, uid, [], resource_id, context)
- vals.update(value.get('value',{}))
- vals.update({'name': value.get('value',{}).get('subject','')})
- vals.update({'attachment_ids' : email_temp_pool.read(cr, uid, template_id, ['attachment_ids'])['attachment_ids']})
+ vals.update(self.get_template_data(cr, uid, resource_id, template_id, context))
else:
vals.update({'attachment_ids' : []})
return {'value': vals}
diff --git a/addons/emails/wizard/email_compose_message.py b/addons/emails/wizard/email_compose_message.py
index 5e4e336783f..b198378ea8b 100644
--- a/addons/emails/wizard/email_compose_message.py
+++ b/addons/emails/wizard/email_compose_message.py
@@ -93,7 +93,7 @@ class email_compose_message(osv.osv_memory):
if 'debug' in fields:
result['debug'] = vals.get('debug',False)
-
+
return result
def _get_records(self, cr, uid, context=None):
@@ -112,7 +112,7 @@ class email_compose_message(osv.osv_memory):
elif context.get('email_model',False):
model = context.get('email_model')
model_pool = self.pool.get(model)
- record_ids = context.get('active_ids',[])
+ record_ids = context.get('email_res_id') and [context.get('email_res_id')] or []
if not record_ids:
record_ids = model_pool.search(cr, uid, [])
if model_pool:
@@ -135,68 +135,40 @@ class email_compose_message(osv.osv_memory):
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
+ subject = tools.ustr(message_data and message_data.name or '')
+ if context.get('mail','') == 'reply':
+ subject = "Re :- " + subject
- if 'attachment_ids' in fields:
- result['attachment_ids'] = message_data and message_pool.read(cr, uid, message_id, ['attachment_ids'])['attachment_ids'] or []
+ description = message_data and message_data.description and message_data.description or ''
+ message_body = False
+ 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 '')
+ description = '\n'.join([header, sender, email_to, sentdate, desc])
- if 'res_id' in fields:
- result['res_id'] = message_data and message_data.res_id or False
+ result.update({
+ 'description' : description,
+ 'name' : subject,
+ 'message_id' : message_data and message_data.message_id or False,
+ 'attachment_ids' : message_data and message_pool.read(cr, uid, message_id, ['attachment_ids'])['attachment_ids'] or [],
+ 'res_id' : message_data and message_data.res_id or False,
+ 'email_from' : message_data and message_data.email_to or False,
+ 'email_to' : message_data and message_data.email_from or False,
+ 'email_cc' : message_data and message_data.email_cc or False,
+ 'email_bcc' : message_data and message_data.email_bcc or False,
+ 'reply_to' : message_data and message_data.reply_to or False,
+ 'model' : message_data and message_data.model or False,
+ 'user_id' : message_data and message_data.user_id and message_data.user_id.id or False,
+ 'references' : message_data and message_data.references and tools.ustr(message_data.references) or False,
+ 'sub_type' : message_data and message_data.sub_type or False,
+ 'headers' : message_data and message_data.headers or False,
+ 'priority' : message_data and message_data.priority or False,
+ 'debug': message_data and message_data.debug 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):
diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml
index d35d6efbe25..321f919502c 100644
--- a/addons/event/event_view.xml
+++ b/addons/event/event_view.xml
@@ -431,7 +431,7 @@
icon="terp-document-new" type="action" />
diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py
index e69bbdf87a2..296d592396a 100644
--- a/addons/fetchmail/fetchmail.py
+++ b/addons/fetchmail/fetchmail.py
@@ -117,7 +117,7 @@ class email_server(osv.osv):
context = {}
for server in self.browse(cr, uid, ids, context=context):
logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name))
- context.update({'server_id': server.id, 'server_type': server.type})
+ context.update({'server_id': server.id})
try:
if server.type == 'imap':
imap_server = None
@@ -215,22 +215,14 @@ class email_message(osv.osv):
_columns = {
'server_id': fields.many2one('email.server', "Mail Server", readonly=True, select=True),
- 'server_type':fields.selection([
- ('pop', 'POP Server'),
- ('imap', 'IMAP Server'),
- ], 'Server Type', select=True, readonly=True),
}
- _order = 'id desc'
def create(self, cr, uid, values, context=None):
if context is None:
context={}
server_id = context.get('server_id',False)
- server_type = context.get('server_type',False)
if server_id:
values['server_id'] = server_id
- if server_type:
- values['server_type'] = server_type
res = super(email_message,self).create(cr, uid, values, context=context)
return res
@@ -238,11 +230,8 @@ class email_message(osv.osv):
if context is None:
context={}
server_id = context.get('server_id',False)
- server_type = context.get('server_type',False)
if server_id:
values['server_id'] = server_id
- if server_type:
- values['server_type'] = server_type
res = super(email_message,self).write(cr, uid, ids, values, context=context)
return res
diff --git a/addons/hr_evaluation/wizard/email_compose_message.py b/addons/hr_evaluation/wizard/email_compose_message.py
index 486abdf859a..da25dcd8cfc 100644
--- a/addons/hr_evaluation/wizard/email_compose_message.py
+++ b/addons/hr_evaluation/wizard/email_compose_message.py
@@ -55,15 +55,15 @@ class email_compose_message(osv.osv_memory):
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.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"),
- 'description': msg,
- 'res_id': resource_id,
- 'email_cc': False,
- 'email_bcc': False,
- 'reply_to': False,
- })
+ '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"),
+ 'description': msg,
+ 'res_id': resource_id,
+ 'email_cc': False,
+ 'email_bcc': False,
+ 'reply_to': False,
+ })
return result
email_compose_message()
diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml
index 40cbfd44e73..6b65b0ee5f7 100644
--- a/addons/hr_recruitment/hr_recruitment_view.xml
+++ b/addons/hr_recruitment/hr_recruitment_view.xml
@@ -185,7 +185,7 @@
icon="terp-document-new" type="action" />
diff --git a/addons/project/wizard/email_compose_message.py b/addons/project/wizard/email_compose_message.py
index 2796dc602c1..68445661716 100644
--- a/addons/project/wizard/email_compose_message.py
+++ b/addons/project/wizard/email_compose_message.py
@@ -51,7 +51,7 @@ class email_compose_message(osv.osv_memory):
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:
+ if partner and len(partner.address):
result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email})
result.update({
'description': description or False,
diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml
index 2130d7fa8d5..894025df71e 100644
--- a/addons/project_issue/project_issue_view.xml
+++ b/addons/project_issue/project_issue_view.xml
@@ -142,7 +142,7 @@
icon="terp-document-new" type="action" />
diff --git a/addons/project_planning/project_planning_view.xml b/addons/project_planning/project_planning_view.xml
index dcf614c5df4..ec380b0cc2c 100644
--- a/addons/project_planning/project_planning_view.xml
+++ b/addons/project_planning/project_planning_view.xml
@@ -109,7 +109,7 @@
-
+
diff --git a/addons/project_scrum/project_scrum_view.xml b/addons/project_scrum/project_scrum_view.xml
index a49cad89b62..88cec4e4f23 100644
--- a/addons/project_scrum/project_scrum_view.xml
+++ b/addons/project_scrum/project_scrum_view.xml
@@ -396,7 +396,7 @@
+ context="{'email_model': 'project.scrum.meeting', 'email_res_id': active_id}"/>