[IMP] remove duplicate code in crm, crm_claim. crm_helpdesk, event, hr_recruitment, project_issu relate to send mail wizard.and improve email.message.send wizard.
bzr revid: ysa@tinyerp.com-20110218124509-srcrk6lz4p4f3wlw
This commit is contained in:
parent
b086aadd1e
commit
d1dcd5a16f
|
@ -83,7 +83,7 @@ Create dashboard for CRM that includes:
|
|||
'wizard/crm_opportunity_to_phonecall_view.xml',
|
||||
'wizard/crm_partner_to_opportunity_view.xml',
|
||||
|
||||
'wizard/crm_send_email_view.xml',
|
||||
# 'wizard/crm_send_email_view.xml',
|
||||
'wizard/crm_add_note_view.xml',
|
||||
'wizard/crm_merge_opportunities_view.xml',
|
||||
|
||||
|
|
|
@ -207,9 +207,9 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="action_send_email"
|
||||
context="{'mail':'new', 'model': 'crm.lead', 'rec_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="object"/>
|
||||
name="%(emails.action_email_message_wizard_send)d"
|
||||
context="{'mail':'new', 'model': 'crm.lead', 'record_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import crm_send_email
|
||||
#import crm_send_email
|
||||
import crm_add_note
|
||||
|
||||
import crm_lead_to_partner
|
||||
|
|
|
@ -100,38 +100,6 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
#'stage_id': _get_stage_id,
|
||||
}
|
||||
|
||||
def action_send_email(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Open Send email wizard.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
for data in self.browse(cr, uid ,ids, context):
|
||||
context.update({
|
||||
'mail':'new',
|
||||
'default_name': data.name,
|
||||
'default_email_to': data.email_from,
|
||||
'default_email_from': data.user_id and data.user_id.address_id and data.user_id.address_id.email,
|
||||
'default_description': '\n' + (tools.ustr(data.user_id.signature or '')),
|
||||
'default_model': context.get('model',''),
|
||||
'default_email_cc': tools.ustr(data.email_cc or ''),
|
||||
'default_res_id': context.get('rec_id',0)
|
||||
})
|
||||
if hasattr(data, 'section_id'):
|
||||
context.update({'default_reply_to': data.section_id and data.section_id.reply_to or False})
|
||||
|
||||
result = {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'email.message.wizard_send',
|
||||
'view_id': False,
|
||||
'context': context,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'nodestroy': True
|
||||
}
|
||||
return result
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, part, email=False):
|
||||
"""This function returns value of partner address based on partner
|
||||
@param self: The object pointer
|
||||
|
|
|
@ -75,15 +75,10 @@
|
|||
<group>
|
||||
<field name="name" />
|
||||
<field name="date"/>
|
||||
|
||||
|
||||
</group>
|
||||
|
||||
<group colspan="4" col="6">
|
||||
|
||||
<field name="user_id"/>
|
||||
<field name="section_id" widget="selection" />
|
||||
|
||||
<group colspan="2" col="4">
|
||||
<field name="stage_id" domain="[('type','=','claim')]"/>
|
||||
<button name="stage_previous" string="" type="object" icon="gtk-go-back" />
|
||||
|
@ -203,9 +198,9 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="action_send_email"
|
||||
context="{'mail':'new', 'model': 'crm.claim', 'rec_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="object"/>
|
||||
name="%(emails.action_email_message_wizard_send)d"
|
||||
context="{'mail':'new', 'model': 'crm.claim', 'record_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</group>
|
||||
|
|
|
@ -94,38 +94,6 @@ class crm_fundraising(crm.crm_case, osv.osv):
|
|||
'planned_revenue': lambda *a:0.0,
|
||||
}
|
||||
|
||||
def action_send_email(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Open Send email wizard.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
for data in self.browse(cr, uid ,ids, context):
|
||||
context.update({
|
||||
'mail':'new',
|
||||
'default_name': data.name,
|
||||
'default_email_to': data.email_from,
|
||||
'default_email_from': data.user_id and data.user_id.address_id and data.user_id.address_id.email,
|
||||
'default_description': '\n' + (tools.ustr(data.user_id.signature or '')),
|
||||
'default_model': context.get('model',''),
|
||||
'default_email_cc': tools.ustr(data.email_cc or ''),
|
||||
'default_res_id': context.get('rec_id',0)
|
||||
})
|
||||
if hasattr(data, 'section_id'):
|
||||
context.update({'default_reply_to': data.section_id and data.section_id.reply_to or False})
|
||||
|
||||
result = {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'email.message.wizard_send',
|
||||
'view_id': False,
|
||||
'context': context,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'nodestroy': True
|
||||
}
|
||||
return result
|
||||
|
||||
crm_fundraising()
|
||||
|
||||
|
||||
|
|
|
@ -187,9 +187,9 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="action_send_email"
|
||||
context="{'mail':'new', 'model': 'crm.fundraising', 'rec_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="object"/>
|
||||
name="%(emails.action_email_message_wizard_send)d"
|
||||
context="{'mail':'new', 'model': 'crm.fundraising', 'record_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
<page string="Extra Info" groups="base.group_extended">
|
||||
<group col="2" colspan="2">
|
||||
|
|
|
@ -87,38 +87,6 @@ class crm_helpdesk(crm.crm_case, osv.osv):
|
|||
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
|
||||
}
|
||||
|
||||
def action_send_email(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Open Send email wizard.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
for data in self.browse(cr, uid ,ids, context):
|
||||
context.update({
|
||||
'mail':'new',
|
||||
'default_name': data.name,
|
||||
'default_email_to': data.email_from,
|
||||
'default_email_from': data.user_id and data.user_id.address_id and data.user_id.address_id.email,
|
||||
'default_description': '\n' + (tools.ustr(data.user_id.signature or '')),
|
||||
'default_model': context.get('model',''),
|
||||
'default_email_cc': tools.ustr(data.email_cc or ''),
|
||||
'default_res_id': context.get('rec_id',0)
|
||||
})
|
||||
if hasattr(data, 'section_id'):
|
||||
context.update({'default_reply_to': data.section_id and data.section_id.reply_to or False})
|
||||
|
||||
result = {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'email.message.wizard_send',
|
||||
'view_id': False,
|
||||
'context': context,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'nodestroy': True
|
||||
}
|
||||
return result
|
||||
|
||||
crm_helpdesk()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -139,9 +139,9 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="action_send_email"
|
||||
context="{'mail':'new', 'model': 'crm.helpdesk', 'rec_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="object"/>
|
||||
name="%(emails.action_email_message_wizard_send)d"
|
||||
context="{'mail':'new', 'model': 'crm.helpdesk', 'record_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
<page string="Extra Info" groups="base.group_extended">
|
||||
<group colspan="2" col="2">
|
||||
|
|
|
@ -34,11 +34,36 @@ class email_message_wizard_send(osv.osv_memory):
|
|||
context = {}
|
||||
result = super(email_message_wizard_send, self).default_get(cr, uid, fields, context=context)
|
||||
message_pool = self.pool.get('email.message')
|
||||
|
||||
model_pool = self.pool.get('ir.model')
|
||||
message_id = context.get('message_id', False)
|
||||
message_data = False
|
||||
if message_id:
|
||||
if context.get('record_id',False) and context.get('model',False):
|
||||
model_obj = self.pool.get(context.get('model'))
|
||||
data = model_obj.browse(cr, uid ,context.get('record_id'), context)
|
||||
if 'name' in fields:
|
||||
result['name'] = data.name
|
||||
|
||||
if 'email_to' in fields:
|
||||
result['email_to'] = data.email_from
|
||||
|
||||
if 'email_from' in fields:
|
||||
result['email_from'] = data.user_id and data.user_id.address_id and data.user_id.address_id.email
|
||||
|
||||
if 'description' in fields:
|
||||
result['description'] = '\n' + (tools.ustr(data.user_id.signature or ''))
|
||||
|
||||
if 'model' in fields:
|
||||
result['model'] = context.get('model','')
|
||||
|
||||
if 'email_cc' in fields:
|
||||
result['email_cc'] = tools.ustr(data.email_cc or '')
|
||||
|
||||
if 'res_id' in fields:
|
||||
result['res_id'] = context.get('record_id',0)
|
||||
|
||||
if 'reply_to' in fields and hasattr(data, 'section_id'):
|
||||
result['reply_to'] = data.section_id and data.section_id.reply_to or False
|
||||
|
||||
elif message_id:
|
||||
message_data = message_pool.browse(cr, uid, int(message_id), context)
|
||||
if 'template_id' in fields:
|
||||
result['template_id'] = message_data and message_data.template_id and message_data.template_id.id or False
|
||||
|
|
|
@ -335,38 +335,6 @@ class event_registration(osv.osv):
|
|||
'user_id': lambda self, cr, uid, ctx: uid,
|
||||
}
|
||||
|
||||
def action_send_email(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Open Send email wizard.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
for data in self.browse(cr, uid ,ids, context):
|
||||
context.update({
|
||||
'mail':'new',
|
||||
'default_name': data.name,
|
||||
'default_email_to': data.email_from,
|
||||
'default_email_from': data.user_id and data.user_id.address_id and data.user_id.address_id.email,
|
||||
'default_description': '\n' + (tools.ustr(data.user_id.signature or '')),
|
||||
'default_model': context.get('model',''),
|
||||
'default_email_cc': tools.ustr(data.email_cc or ''),
|
||||
'default_res_id': context.get('rec_id',0)
|
||||
})
|
||||
if hasattr(data, 'section_id'):
|
||||
context.update({'default_reply_to': data.section_id and data.section_id.reply_to or False})
|
||||
|
||||
result = {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'email.message.wizard_send',
|
||||
'view_id': False,
|
||||
'context': context,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'nodestroy': True
|
||||
}
|
||||
return result
|
||||
|
||||
def _make_invoice(self, cr, uid, reg, lines, context=None):
|
||||
""" Create Invoice from Invoice lines
|
||||
@param reg: Model of Event Registration
|
||||
|
|
|
@ -430,9 +430,9 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="action_send_email"
|
||||
context="{'mail':'new', 'model': 'event.registration', 'rec_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="object"/>
|
||||
name="%(emails.action_email_message_wizard_send)d"
|
||||
context="{'mail':'new', 'model': 'event.registration', 'record_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
|
|
|
@ -176,38 +176,6 @@ class hr_applicant(crm.crm_case, osv.osv):
|
|||
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
|
||||
}
|
||||
|
||||
def action_send_email(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Open Send email wizard.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
for data in self.browse(cr, uid ,ids, context):
|
||||
context.update({
|
||||
'mail':'new',
|
||||
'default_name': data.name,
|
||||
'default_email_to': data.email_from,
|
||||
'default_email_from': data.user_id and data.user_id.address_id and data.user_id.address_id.email,
|
||||
'default_description': '\n' + (tools.ustr(data.user_id.signature or '')),
|
||||
'default_model': context.get('model',''),
|
||||
'default_email_cc': tools.ustr(data.email_cc or ''),
|
||||
'default_res_id': context.get('rec_id',0)
|
||||
})
|
||||
if hasattr(data, 'section_id'):
|
||||
context.update({'default_reply_to': data.section_id and data.section_id.reply_to or False})
|
||||
|
||||
result = {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'email.message.wizard_send',
|
||||
'view_id': False,
|
||||
'context': context,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'nodestroy': True
|
||||
}
|
||||
return result
|
||||
|
||||
def onchange_job(self,cr, uid, ids, job, context=None):
|
||||
result = {}
|
||||
|
||||
|
|
|
@ -184,9 +184,9 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="action_send_email"
|
||||
context="{'mail':'new', 'model': 'hr.applicant', 'rec_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="object"/>
|
||||
name="%(emails.action_email_message_wizard_send)d"
|
||||
context="{'mail':'new', 'model': 'hr.applicant', 'record_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field name="description" nolabel="1" colspan="4"/>
|
||||
|
|
|
@ -243,38 +243,6 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
'project_id':_get_project,
|
||||
}
|
||||
|
||||
def action_send_email(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Open Send email wizard.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
for data in self.browse(cr, uid ,ids, context):
|
||||
context.update({
|
||||
'mail':'new',
|
||||
'default_name': data.name,
|
||||
'default_email_to': data.email_from,
|
||||
'default_email_from': data.user_id and data.user_id.address_id and data.user_id.address_id.email,
|
||||
'default_description': '\n' + (tools.ustr(data.user_id.signature or '')),
|
||||
'default_model': context.get('model',''),
|
||||
'default_email_cc': tools.ustr(data.email_cc or ''),
|
||||
'default_res_id': context.get('rec_id',0)
|
||||
})
|
||||
if hasattr(data, 'section_id'):
|
||||
context.update({'default_reply_to': data.section_id and data.section_id.reply_to or False})
|
||||
|
||||
result = {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'email.message.wizard_send',
|
||||
'view_id': False,
|
||||
'context': context,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'nodestroy': True
|
||||
}
|
||||
return result
|
||||
|
||||
def convert_issue_task(self, cr, uid, ids, context=None):
|
||||
case_obj = self.pool.get('project.issue')
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
|
|
|
@ -141,9 +141,9 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="action_send_email"
|
||||
context="{'mail':'new', 'model': 'project.issue', 'rec_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="object"/>
|
||||
name="%(emails.action_email_message_wizard_send)d"
|
||||
context="{'mail':'new', 'model': 'project.issue', 'record_id' : active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
<page string="Extra Info" groups="base.group_extended">
|
||||
<group col="2" colspan="2">
|
||||
|
|
Loading…
Reference in New Issue