@@ -208,7 +208,7 @@
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(emails.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'new'}"
|
||||
context="{'mail':'new', 'email_model':'crm.lead'}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
@@ -193,7 +193,7 @@
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(emails.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'new'}"
|
||||
context="{'mail':'new', 'email_model': 'crm.lead'}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
<page string="Extra Info" groups="base.group_extended">
|
||||
|
||||
@@ -23,16 +23,19 @@ from osv import osv
|
||||
from osv import fields
|
||||
import tools
|
||||
|
||||
email_model = [
|
||||
'crm.lead',
|
||||
]
|
||||
|
||||
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 = {}
|
||||
model = ['crm.lead', 'crm.claim', 'crm.fundraising', 'crm.helpdesk', 'event.registration', 'hr.applicant', 'project.issue']
|
||||
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
|
||||
if context.get('active_id',False) and context.get('active_model',False) and context.get('active_model') in model:
|
||||
model_obj = self.pool.get(context.get('active_model'))
|
||||
if context.get('active_id',False) and context.get('email_model',False) and context.get('email_model') in email_model:
|
||||
model_obj = self.pool.get(context.get('email_model'))
|
||||
data = model_obj.browse(cr, uid ,context.get('active_id'), context)
|
||||
if 'name' in fields:
|
||||
result['name'] = data.name
|
||||
@@ -47,7 +50,7 @@ class email_compose_message(osv.osv_memory):
|
||||
result['description'] = '\n' + (tools.ustr(data.user_id.signature or ''))
|
||||
|
||||
if 'model' in fields:
|
||||
result['model'] = context.get('active_model','')
|
||||
result['model'] = context.get('email_model','')
|
||||
|
||||
if 'email_cc' in fields:
|
||||
result['email_cc'] = tools.ustr(data.email_cc or '')
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
from osv import fields, osv
|
||||
from crm import crm
|
||||
import time
|
||||
from crm import wizard
|
||||
|
||||
wizard.email_compose_message.email_model.append('crm.claim')
|
||||
|
||||
class crm_claim(crm.crm_case, osv.osv):
|
||||
"""
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(emails.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'new'}"
|
||||
context="{'mail':'new', 'email_model':'crm.claim'}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
from osv import fields, osv
|
||||
from crm import crm
|
||||
from crm import wizard
|
||||
|
||||
wizard.email_compose_message.email_model.append('crm.fundraising')
|
||||
|
||||
class crm_fundraising(crm.crm_case, osv.osv):
|
||||
""" Fund Raising Cases """
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(emails.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'new'}"
|
||||
context="{'mail':'new', 'email_model':'crm.fundraising'}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
<page string="Extra Info" groups="base.group_extended">
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
from crm import crm
|
||||
from osv import fields, osv
|
||||
import time
|
||||
from crm import wizard
|
||||
|
||||
wizard.email_compose_message.email_model.append('crm.helpdesk')
|
||||
|
||||
class crm_helpdesk(crm.crm_case, osv.osv):
|
||||
""" Helpdesk Cases """
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(emails.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'new'}"
|
||||
context="{'mail':'new', 'email_model':'crm.helpdesk'}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
<page string="Extra Info" groups="base.group_extended">
|
||||
|
||||
@@ -183,15 +183,15 @@ This is useful for CRM leads for example"),
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
for template in self.browse(cr, uid, ids, context=context):
|
||||
src_obj = template.model_id.model
|
||||
model_data_id = data_obj._get_id(cr, uid, 'email_template', 'email_template_send_wizard_form')
|
||||
model_data_id = data_obj._get_id(cr, uid, 'emails', 'email_compose_message_wizard_form')
|
||||
res_id = data_obj.browse(cr, uid, model_data_id, context=context).res_id
|
||||
vals['ref_ir_act_window'] = action_obj.create(cr, uid, {
|
||||
'name': template.name,
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'email_template.send.wizard',
|
||||
'res_model': 'email.compose.message',
|
||||
'src_model': src_obj,
|
||||
'view_type': 'form',
|
||||
'context': "{'src_model':'%s','template_id':'%d','src_rec_id':active_id,'src_rec_ids':active_ids}" % (src_obj, template.id),
|
||||
'context': "{'email_model':'%s','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',
|
||||
|
||||
@@ -26,6 +26,57 @@ 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):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
|
||||
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
|
||||
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)
|
||||
|
||||
if 'template_id' in fields:
|
||||
result['template_id'] = template.id
|
||||
|
||||
if 'smtp_server_id' in fields:
|
||||
result['smtp_server_id'] = template.smtp_server_id.id
|
||||
|
||||
if 'attachment_ids' in fields:
|
||||
result['attachment_ids'] = template_pool.read(cr, uid, template.id, ['attachment_ids'])['attachment_ids']
|
||||
|
||||
if 'model' in fields:
|
||||
result['model'] = context.get('email_model')
|
||||
|
||||
if 'res_id' in fields:
|
||||
result['res_id'] = context.get('active_id')
|
||||
|
||||
if 'email_to' in fields:
|
||||
result['email_to'] = _get_template_value('email_to')
|
||||
|
||||
if 'email_cc' in fields:
|
||||
result['email_cc'] = _get_template_value('email_cc')
|
||||
|
||||
if 'email_bcc' in fields:
|
||||
result['email_bcc'] = _get_template_value('email_bcc')
|
||||
|
||||
if 'name' in fields:
|
||||
result['name'] = _get_template_value('subject')
|
||||
|
||||
if 'description' in fields:
|
||||
result['description'] = _get_template_value('description')
|
||||
|
||||
if 'reply_to' in fields:
|
||||
result['reply_to'] = _get_template_value('reply_to')
|
||||
|
||||
return result
|
||||
|
||||
def _get_templates(self, cr, uid, context=None):
|
||||
"""
|
||||
@@ -42,8 +93,6 @@ class email_compose_message(osv.osv_memory):
|
||||
model = message_data.model
|
||||
elif context.get('email_model',False):
|
||||
model = context.get('email_model')
|
||||
elif context.get('active_model',False):
|
||||
model = context.get('active_model')
|
||||
if model:
|
||||
record_ids = email_temp_pool.search(cr, uid, [('model','=',model)])
|
||||
return email_temp_pool.name_get(cr, uid, record_ids, context)
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<field name="template_id" colspan="4"
|
||||
on_change="on_change_template(model, res_id, template_id, context)"/>
|
||||
<field name="res_id"
|
||||
invisible="context.get('active_model','') != 'ir.ui.menu'"
|
||||
colspan="4" on_change="on_change_template(model, res_id, template_id, context)"/>
|
||||
invisible="context.get('active_model','') != 'ir.ui.menu'"
|
||||
colspan="4" on_change="on_change_template(model, res_id, template_id, context)"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -47,10 +47,10 @@ class email_compose_message(osv.osv_memory):
|
||||
result['res_id'] = message_data and message_data.res_id
|
||||
|
||||
if 'email_from' in fields:
|
||||
result['email_from'] = message_data and message_data.email_from
|
||||
result['email_from'] = message_data and message_data.email_to
|
||||
|
||||
if 'email_to' in fields:
|
||||
result['email_to'] = message_data and message_data.email_to
|
||||
result['email_to'] = message_data and message_data.email_from
|
||||
|
||||
if 'email_cc' in fields:
|
||||
result['email_cc'] = message_data and message_data.email_cc
|
||||
@@ -123,10 +123,6 @@ class email_compose_message(osv.osv_memory):
|
||||
record_ids = context.get('record_ids',[])
|
||||
if not record_ids:
|
||||
record_ids = model_pool.search(cr, uid, [])
|
||||
elif context.get('active_model',False):
|
||||
model = context.get('active_model')
|
||||
model_pool = self.pool.get(model)
|
||||
record_ids = context.get('active_ids',[])
|
||||
if model_pool:
|
||||
return model_pool.name_get(cr, uid, record_ids, context)
|
||||
return []
|
||||
|
||||
@@ -25,6 +25,9 @@ from crm import crm
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import decimal_precision as dp
|
||||
from crm import wizard
|
||||
|
||||
wizard.email_compose_message.email_model.append('event.registration')
|
||||
|
||||
class event_type(osv.osv):
|
||||
""" Event Type """
|
||||
|
||||
@@ -431,7 +431,7 @@
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(emails.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'new'}"
|
||||
context="{'mail':'new', 'email_model':'event.registration'}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
@@ -50,7 +50,7 @@ class email_compose_message(osv.osv_memory):
|
||||
return super(email_compose_message, self)._get_records(cr, uid, context=context)
|
||||
|
||||
_columns = {
|
||||
'resource_id':fields.selection(_get_records, 'Referred Document'),
|
||||
'res_id':fields.selection(_get_records, 'Referred Document'),
|
||||
}
|
||||
|
||||
def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None):
|
||||
|
||||
@@ -29,6 +29,9 @@ import collections
|
||||
import binascii
|
||||
import tools
|
||||
from tools.translate import _
|
||||
from crm import wizard
|
||||
|
||||
wizard.email_compose_message.email_model.append('hr.applicant')
|
||||
|
||||
AVAILABLE_STATES = [
|
||||
('draft', 'New'),
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(emails.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'new'}"
|
||||
context="{'mail':'new', 'email_model': 'hr.applicant'}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
|
||||
@@ -26,6 +26,9 @@ from tools.translate import _
|
||||
import binascii
|
||||
import time
|
||||
import tools
|
||||
from crm import wizard
|
||||
|
||||
wizard.email_compose_message.email_model.append('project.issue')
|
||||
|
||||
class project_issue_version(osv.osv):
|
||||
_name = "project.issue.version"
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(emails.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'new'}"
|
||||
context="{'mail':'new', 'email_model':'project.issue'}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
<page string="Extra Info" groups="base.group_extended">
|
||||
|
||||
@@ -396,7 +396,7 @@
|
||||
<field name="user_id"/>
|
||||
<button name="%(emails.action_email_compose_message_wizard)d"
|
||||
string="Send Email" type="action" icon="terp-mail-message-new"
|
||||
context="{'mail':'new'}"/>
|
||||
context="{'mail':'new', 'email_model': 'project.scrum.meeting'}"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Scrum Meeting">
|
||||
|
||||
@@ -31,7 +31,7 @@ class email_compose_message(osv.osv_memory):
|
||||
context = {}
|
||||
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
|
||||
|
||||
if context.get('active_id',False) and context.get('active_model',False) and context.get('active_model') == 'project.scrum.meeting':
|
||||
if context.get('active_id',False) and context.get('email_model',False) and context.get('email_model') == 'project.scrum.meeting':
|
||||
|
||||
meeting_pool = self.pool.get('project.scrum.meeting')
|
||||
user_pool = self.pool.get('res.users')
|
||||
@@ -57,7 +57,7 @@ class email_compose_message(osv.osv_memory):
|
||||
result.update({'description': message})
|
||||
|
||||
if 'model' in fields:
|
||||
result.update({'model':context.get('active_model')})
|
||||
result.update({'model':context.get('email_model')})
|
||||
|
||||
if 'res_id' in fields:
|
||||
result.update({'res_id':context.get('active_id')})
|
||||
|
||||
Reference in New Issue
Block a user