[IMP] email.compose.message :- add the email_model=model name pass in context in xml file and change the active_model to email_model in default_get method. Global list define of email_model in crm and module are install then add the model name in this list.
bzr revid: ysa@tinyerp.com-20110224101305-iagvga1j6o6h4k0k
This commit is contained in:
parent
bf37d84341
commit
ece864e532
|
@ -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">
|
||||
|
|
|
@ -42,8 +42,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')})
|
||||
|
|
Loading…
Reference in New Issue