[MERGE] cleanup email module and rename it with mail module
bzr revid: hmo@tinyerp.com-20110406054513-bn5e5sys9ugm1vq5
This commit is contained in:
commit
37a916b539
|
@ -44,7 +44,7 @@ Note that if you want to check the followup level for a given partner/account en
|
|||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'images': ['images/follow_ups.jpeg','images/send_followups.jpeg'],
|
||||
'depends': ['account', 'email'],
|
||||
'depends': ['account', 'mail'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'security/ir.model.access.csv',
|
||||
|
|
|
@ -278,7 +278,7 @@ class account_followup_print_all(osv.osv_memory):
|
|||
msg = ''
|
||||
if dest:
|
||||
try:
|
||||
email_message_obj.email_send(cr, uid, src, dest, sub, body, model='account.followup.print.all')
|
||||
email_message_obj.schedule_with_attach(cr, uid, src, dest, sub, body, model='account.followup.print.all')
|
||||
msg_sent += partner.name + '\n'
|
||||
except Exception, e:
|
||||
raise osv.except_osv('Error !', e )
|
||||
|
|
|
@ -36,7 +36,7 @@ trigger an automatic reminder email.
|
|||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'depends': ['base', 'email'],
|
||||
'depends': ['base', 'mail'],
|
||||
'init_xml': [
|
||||
'base_action_rule_data.xml'
|
||||
],
|
||||
|
|
|
@ -315,7 +315,7 @@ the rule to mark CC(mail to any other person defined in actions)."),
|
|||
if not emailfrom:
|
||||
raise osv.except_osv(_('Error!'),
|
||||
_("No E-Mail ID Found for your Company address!"))
|
||||
return email_message_obj.email_send(cr, uid, emailfrom, emails, name, body, model='base.action.rule', reply_to=reply_to, openobject_id=str(obj.id))
|
||||
return email_message_obj.schedule_with_attach(cr, uid, emailfrom, emails, name, body, model='base.action.rule', reply_to=reply_to, openobject_id=str(obj.id))
|
||||
|
||||
|
||||
def do_check(self, cr, uid, action, obj, context=None):
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
{
|
||||
"name" : "Basic Calendar Functionality",
|
||||
"version" : "1.0",
|
||||
"depends" : ["base", "email"],
|
||||
"depends" : ["base", "mail"],
|
||||
'description': """
|
||||
This is a full-featured calendar system.
|
||||
========================================
|
||||
|
|
|
@ -507,7 +507,7 @@ property or property parameter."),
|
|||
body = html_invitation % body_vals
|
||||
if mail_to and email_from:
|
||||
attach = self.get_ics_file(cr, uid, res_obj, context=context)
|
||||
email_message_obj.email_send(cr, uid,
|
||||
email_message_obj.schedule_with_attach(cr, uid,
|
||||
email_from,
|
||||
mail_to,
|
||||
sub,
|
||||
|
@ -893,7 +893,7 @@ From:
|
|||
for att in alarm.attendee_ids:
|
||||
mail_to.append(att.user_id.address_id.email)
|
||||
if mail_to:
|
||||
email_message_obj.email_send(cr, uid,
|
||||
email_message_obj.schedule_with_attach(cr, uid,
|
||||
tools.config.get('email_from', False),
|
||||
mail_to,
|
||||
sub,
|
||||
|
|
|
@ -57,7 +57,7 @@ Creates a dashboard for CRM that includes:
|
|||
'base',
|
||||
'base_action_rule',
|
||||
'process',
|
||||
'email',
|
||||
'mail',
|
||||
'base_calendar',
|
||||
'resource',
|
||||
'board'
|
||||
|
|
|
@ -308,8 +308,8 @@ class crm_case(object):
|
|||
return {'value': {'phone': address.phone}}
|
||||
|
||||
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=[], context=None):
|
||||
mailgate_pool = self.pool.get('mailgate.thread')
|
||||
return mailgate_pool.history(cr, uid, cases, keyword, history=history,\
|
||||
thread_pool = self.pool.get('email.thread')
|
||||
return thread_pool.history(cr, uid, cases, keyword, history=history,\
|
||||
subject=subject, email=email, \
|
||||
details=details, email_from=email_from,\
|
||||
message_id=message_id, attach=attach, \
|
||||
|
@ -458,7 +458,7 @@ class crm_case(object):
|
|||
raise osv.except_osv(_('Error!'), ("Partner Email is not specified in Case"))
|
||||
if not case.user_id.user_email:
|
||||
raise osv.except_osv(_('Error!'), ("User Email is not specified in Case"))
|
||||
|
||||
|
||||
if destination and case.section_id.user_id:
|
||||
case_email = case.section_id.user_id.user_email
|
||||
else:
|
||||
|
@ -486,9 +486,9 @@ class crm_case(object):
|
|||
attach_to_send = self.pool.get('ir.attachment').read(cr, uid, attach_ids, ['datas_fname', 'datas'])
|
||||
attach_to_send = map(lambda x: (x['datas_fname'], base64.decodestring(x['datas'])), attach_to_send)
|
||||
|
||||
# Send an email
|
||||
# Send an email
|
||||
subject = "Reminder: [%s] %s" % (str(case.id), case.name, )
|
||||
email_message_obj.email_send(cr, uid,
|
||||
email_message_obj.schedule_with_attach(cr, uid,
|
||||
src,
|
||||
[dest],
|
||||
subject,
|
||||
|
@ -538,7 +538,7 @@ class crm_case(object):
|
|||
def format_mail(self, obj, body):
|
||||
return self.pool.get('base.action.rule').format_mail(obj, body)
|
||||
|
||||
def message_followers(self, cr, uid, ids, context=None):
|
||||
def thread_followers(self, cr, uid, ids, context=None):
|
||||
""" Get a list of emails of the people following this thread
|
||||
"""
|
||||
res = {}
|
||||
|
|
|
@ -66,7 +66,7 @@ this if you want the rule to send an email to the partner."),
|
|||
if not emailfrom:
|
||||
raise osv.except_osv(_('Error!'),
|
||||
_("No E-Mail ID Found for your Company address!"))
|
||||
return email_message_obj.email_send(cr, uid, emailfrom, emails, name, body, model='base.action.rule', reply_to=reply_to, openobject_id=str(obj.id))
|
||||
return email_message_obj.schedule_with_attach(cr, uid, emailfrom, emails, name, body, model='base.action.rule', reply_to=reply_to, openobject_id=str(obj.id))
|
||||
|
||||
def do_check(self, cr, uid, action, obj, context=None):
|
||||
""" @param self: The object pointer
|
||||
|
|
|
@ -40,7 +40,7 @@ class crm_lead(crm_case, osv.osv):
|
|||
_name = "crm.lead"
|
||||
_description = "Lead/Opportunity"
|
||||
_order = "date_action, priority, id desc"
|
||||
_inherit = ['mailgate.thread','res.partner.address']
|
||||
_inherit = ['email.thread','res.partner.address']
|
||||
def _compute_day(self, cr, uid, ids, fields, args, context=None):
|
||||
"""
|
||||
@param cr: the current row, from the database cursor,
|
||||
|
@ -325,8 +325,9 @@ class crm_lead(crm_case, osv.osv):
|
|||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks
|
||||
@param msg: dictionary object to contain email message data
|
||||
"""
|
||||
mailgate_pool = self.pool.get('email.server.tools')
|
||||
thread_pool = self.pool.get('email.thread')
|
||||
|
||||
subject = msg.get('subject')
|
||||
body = msg.get('body')
|
||||
|
@ -343,7 +344,7 @@ class crm_lead(crm_case, osv.osv):
|
|||
if msg.get('priority', False):
|
||||
vals['priority'] = priority
|
||||
|
||||
res = mailgate_pool.get_partner(cr, uid, msg.get('from') or msg.get_unixfrom())
|
||||
res = thread_pool.get_partner(cr, uid, msg.get('from', False))
|
||||
if res:
|
||||
vals.update(res)
|
||||
|
||||
|
@ -399,18 +400,6 @@ class crm_lead(crm_case, osv.osv):
|
|||
res = self.write(cr, uid, [case.id], values, context=context)
|
||||
return res
|
||||
|
||||
def msg_send(self, cr, uid, id, *args, **argv):
|
||||
|
||||
""" Send The Message
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of email’s IDs
|
||||
@param *args: Return Tuple Value
|
||||
@param **args: Return Dictionary of Keyword Value
|
||||
"""
|
||||
return True
|
||||
|
||||
def on_change_optin(self, cr, uid, ids, optin):
|
||||
return {'value':{'optin':optin,'optout':False}}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
<separator string="Communication" colspan="4" col="3"/>
|
||||
<field name="email_from" widget="email"/>
|
||||
<button string="Send Email"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'email_model':'crm.lead', 'email_res_id': active_id}"
|
||||
icon="terp-mail-message-new" type="action" colspan="1"/>
|
||||
<newline/>
|
||||
|
@ -189,7 +189,7 @@
|
|||
<field name="history" invisible="1"/>
|
||||
<button
|
||||
string="Reply" attrs="{'invisible': [('history', '!=', True)]}"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action" />
|
||||
</tree>
|
||||
|
@ -199,15 +199,15 @@
|
|||
<field name="date"/>
|
||||
<field name="email_to" widget="char" size="512"/>
|
||||
<field name="email_cc" widget="char" size="512"/>
|
||||
<field name="name" colspan="4" widget="char" size="512"/>
|
||||
<field name="subject" colspan="4" widget="char" size="512"/>
|
||||
<field name="history" invisible="1"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Details">
|
||||
<group attrs="{'invisible': [('history', '!=', True)]}">
|
||||
<field name="description" colspan="4" nolabel="1" height="250"/>
|
||||
<field name="body" colspan="4" nolabel="1" height="250"/>
|
||||
<button colspan="4" string="Reply"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action"/>
|
||||
</group>
|
||||
|
@ -226,7 +226,7 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'email_model':'crm.lead', 'email_res_id': active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
|
|
|
@ -42,7 +42,7 @@ class crm_meeting(crm_case, osv.osv):
|
|||
_name = 'crm.meeting'
|
||||
_description = "Meeting"
|
||||
_order = "id desc"
|
||||
_inherit = ['mailgate.thread',"calendar.event"]
|
||||
_inherit = ['email.thread',"calendar.event"]
|
||||
_columns = {
|
||||
# From crm.case
|
||||
'name': fields.char('Summary', size=124, required=True, states={'done': [('readonly', True)]}),
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<group col="3" colspan="2">
|
||||
<field name="email_from" string="Email" />
|
||||
<button string="Send Email"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'email_model': 'crm.lead', 'email_res_id': active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</group>
|
||||
|
@ -145,7 +145,7 @@
|
|||
<field name="display_text" string="History Information"/>
|
||||
<field name="history" invisible="1"/>
|
||||
<button string="Reply"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action"/>
|
||||
</tree>
|
||||
|
@ -155,17 +155,17 @@
|
|||
<field name="date"/>
|
||||
<field name="email_to" size="512"/>
|
||||
<field name="email_cc" size="512"/>
|
||||
<field name="name" colspan="4" attrs="{'invisible': [('history', '=', True)]}"/>
|
||||
<field name="subject" colspan="4" attrs="{'invisible': [('history', '=', True)]}"/>
|
||||
<field name="display_text" colspan="4" attrs="{'invisible': [('history', '=', False)]}"/>
|
||||
<field name="history" invisible="1"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Details">
|
||||
<field name="description" colspan="4" nolabel="1"/>
|
||||
<field name="body" colspan="4" nolabel="1"/>
|
||||
<group attrs="{'invisible': [('history', '!=', True)]}">
|
||||
<button colspan="4"
|
||||
string="Reply"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action" />
|
||||
</group>
|
||||
|
@ -182,7 +182,7 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'email_model': 'crm.lead', 'email_res_id': active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
|
|
|
@ -32,7 +32,7 @@ class crm_phonecall(crm_case, osv.osv):
|
|||
_name = "crm.phonecall"
|
||||
_description = "Phonecall"
|
||||
_order = "id desc"
|
||||
_inherit = ['mailgate.thread']
|
||||
_inherit = ['email.thread']
|
||||
_columns = {
|
||||
# From crm.case
|
||||
'id': fields.integer('ID'),
|
||||
|
|
|
@ -27,15 +27,15 @@
|
|||
"access_res_partner_manager","res.partner.crm.manager","base.model_res_partner","base.group_sale_manager",1,0,0,0
|
||||
"access_res_partner_address_manager","res.partner.address.crm.user.manager","base.model_res_partner_address","base.group_sale_manager",1,0,0,0
|
||||
"access_res_partner_category_manager","res.partner.category.crm.manager","base.model_res_partner_category","base.group_sale_manager",1,0,0,0
|
||||
"email_email_message_manager","email.email.message.manager","email.model_email_message","base.group_sale_manager",1,0,0,0
|
||||
"email_thread_manager","email.mailgate.thread.manager","email.model_mailgate_thread","base.group_sale_manager",1,1,1,1
|
||||
"email_email_message_manager","mail.email.message.manager","mail.model_email_message","base.group_sale_manager",1,0,0,0
|
||||
"email_thread_manager","mail.thread.manager","mail.model_email_thread","base.group_sale_manager",1,1,1,1
|
||||
"access_calendar_attendee_crm_user","calendar.attendee.crm.user","model_calendar_attendee","base.group_sale_salesman",1,1,1,0
|
||||
"access_calendar_attendee_crm_manager","calendar.attendee.crm.manager","model_calendar_attendee","base.group_sale_manager",1,1,1,1
|
||||
"access_res_partner","res.partner.crm.user","base.model_res_partner","base.group_sale_salesman",1,1,1,0
|
||||
"access_res_partner_address","res.partner.address.crm.user","base.model_res_partner_address","base.group_sale_salesman",1,1,1,0
|
||||
"access_res_partner_category","res.partner.category.crm.user","base.model_res_partner_category","base.group_sale_salesman",1,1,1,0
|
||||
"email_mailgate_thread","email.mailgate.thread","email.model_mailgate_thread","base.group_sale_salesman",1,1,1,1
|
||||
"email_gateway_email_message_user","email.email.message.user","email.model_email_message","base.group_sale_salesman",1,1,1,1
|
||||
"email_mailgate_thread","email.thread","mail.model_email_thread","base.group_sale_salesman",1,1,1,1
|
||||
"email_gateway_email_message_user","mail.email.message.user","mail.model_email_message","base.group_sale_salesman",1,1,1,1
|
||||
"access_crm_case_categ_manager","crm.case.categ manager","model_crm_case_categ","base.group_sale_manager",1,1,1,1
|
||||
"access_base_action_rule_manager","base.action.rule manager","model_base_action_rule","base.group_sale_manager",1,1,1,1
|
||||
"access_crm_lead_report_user","crm.lead.report user","model_crm_lead_report","base.group_sale_salesman",1,1,1,1
|
||||
|
|
|
|
@ -45,7 +45,7 @@ class crm_send_new_email(osv.osv_memory):
|
|||
'body': fields.text('Message Body', required=True),
|
||||
'state': fields.selection(AVAILABLE_STATES, string='Set New State To', required=True),
|
||||
'attachment_ids' : fields.one2many('crm.send.mail.attachment', 'wizard_id', 'Attachment'),
|
||||
'html': fields.boolean('HTML formatting?', help="Select this if you want to send email with HTML formatting."),
|
||||
'html': fields.boolean('HTML formatting?', help="Select this if you want to send email with HTML formatting."),
|
||||
}
|
||||
|
||||
def action_send(self, cr, uid, ids, context=None):
|
||||
|
@ -111,7 +111,7 @@ class crm_send_new_email(osv.osv_memory):
|
|||
if obj.html:
|
||||
subtype = 'html'
|
||||
|
||||
flag = email_message_obj.email_send(cr, uid,
|
||||
flag = email_message_obj.schedule_with_attach(cr, uid,
|
||||
email_from,
|
||||
emails,
|
||||
obj.subject,
|
||||
|
|
|
@ -41,7 +41,7 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
_name = "crm.claim"
|
||||
_description = "Claim"
|
||||
_order = "priority,date desc"
|
||||
_inherit = ['mailgate.thread']
|
||||
_inherit = ['email.thread']
|
||||
_columns = {
|
||||
'id': fields.integer('ID', readonly=True),
|
||||
'name': fields.char('Claim Subject', size=128, required=True),
|
||||
|
@ -83,7 +83,7 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
|
||||
'message_ids': fields.one2many('email.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
}
|
||||
|
||||
|
||||
def stage_next(self, cr, uid, ids, context=None):
|
||||
stage = super(crm_claim, self).stage_next(cr, uid, ids, context=context)
|
||||
if stage:
|
||||
|
@ -97,7 +97,7 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, stage, context=context)
|
||||
self.history(cr, uid, ids, _("Changed Stage to: ") + stage_obj.name)
|
||||
return stage
|
||||
|
||||
|
||||
def _get_stage_id(self, cr, uid, context=None):
|
||||
"""Finds type of stage according to object.
|
||||
@param self: The object pointer
|
||||
|
@ -171,7 +171,7 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
self.write(cr, uid, [ids[i]], {'stage_id' : stage_id})
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def message_new(self, cr, uid, msg, context=None):
|
||||
"""
|
||||
Automatically calls when new email message arrives
|
||||
|
@ -179,8 +179,9 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks
|
||||
@param msg: dictionary object to contain email message data
|
||||
"""
|
||||
mailgate_pool = self.pool.get('email.server.tools')
|
||||
thread_pool = self.pool.get('email.thread')
|
||||
|
||||
subject = msg.get('subject')
|
||||
body = msg.get('body')
|
||||
|
@ -197,7 +198,7 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
if msg.get('priority', False):
|
||||
vals['priority'] = priority
|
||||
|
||||
res = mailgate_pool.get_partner(cr, uid, msg.get('from') or msg.get_unixfrom())
|
||||
res = thread_pool.get_partner(cr, uid, msg.get('from', False))
|
||||
if res:
|
||||
vals.update(res)
|
||||
|
||||
|
@ -221,7 +222,7 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of update mail’s IDs
|
||||
@param ids: List of update mail’s IDs
|
||||
"""
|
||||
if isinstance(ids, (str, int, long)):
|
||||
ids = [ids]
|
||||
|
@ -253,18 +254,6 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
res = self.write(cr, uid, [case.id], values, context=context)
|
||||
return res
|
||||
|
||||
def msg_send(self, cr, uid, id, *args, **argv):
|
||||
|
||||
""" Send The Message
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of email’s IDs
|
||||
@param *args: Return Tuple Value
|
||||
@param **args: Return Dictionary of Keyword Value
|
||||
"""
|
||||
return True
|
||||
|
||||
crm_claim()
|
||||
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@
|
|||
<field name="display_text" string="History Information"/>
|
||||
<button
|
||||
string="Reply" attrs="{'invisible': [('history', '!=', True)]}"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action" />
|
||||
</tree>
|
||||
|
@ -195,7 +195,7 @@
|
|||
<group attrs="{'invisible': [('history', '!=', True)]}">
|
||||
<field name="description" colspan="4" nolabel="1" height="250"/>
|
||||
<button colspan="4" string="Reply"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action"/>
|
||||
</group>
|
||||
|
@ -214,7 +214,7 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'email_model':'crm.claim', 'email_res_id': active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
|
|
|
@ -31,7 +31,7 @@ class crm_fundraising(crm.crm_case, osv.osv):
|
|||
_name = "crm.fundraising"
|
||||
_description = "Fund Raising"
|
||||
_order = "id desc"
|
||||
_inherit = ['mailgate.thread']
|
||||
_inherit = ['email.thread']
|
||||
_columns = {
|
||||
'id': fields.integer('ID'),
|
||||
'name': fields.char('Name', size=128, required=True),
|
||||
|
|
|
@ -168,7 +168,7 @@
|
|||
<field name="history" invisible="1"/>
|
||||
<button
|
||||
string="Reply" attrs="{'invisible': [('history', '!=', True)]}"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action" />
|
||||
</tree>
|
||||
|
@ -186,7 +186,7 @@
|
|||
<group attrs="{'invisible': [('history', '!=', True)]}">
|
||||
<field name="description" colspan="4" nolabel="1" height="250"/>
|
||||
<button colspan="4" string="Reply"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action"/>
|
||||
</group>
|
||||
|
@ -205,7 +205,7 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'email_model':'crm.fundraising', 'email_res_id': active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
|
|
|
@ -39,7 +39,7 @@ class crm_helpdesk(crm.crm_case, osv.osv):
|
|||
_name = "crm.helpdesk"
|
||||
_description = "Helpdesk"
|
||||
_order = "id desc"
|
||||
_inherit = ['mailgate.thread']
|
||||
_inherit = ['email.thread']
|
||||
_columns = {
|
||||
'id': fields.integer('ID', readonly=True),
|
||||
'name': fields.char('Name', size=128, required=True),
|
||||
|
@ -103,8 +103,9 @@ class crm_helpdesk(crm.crm_case, osv.osv):
|
|||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks
|
||||
@param msg: dictionary object to contain email message data
|
||||
"""
|
||||
mailgate_pool = self.pool.get('email.server.tools')
|
||||
thread_pool = self.pool.get('email.thread')
|
||||
|
||||
subject = msg.get('subject')
|
||||
body = msg.get('body')
|
||||
|
@ -121,7 +122,7 @@ class crm_helpdesk(crm.crm_case, osv.osv):
|
|||
if msg.get('priority', False):
|
||||
vals['priority'] = priority
|
||||
|
||||
res = mailgate_pool.get_partner(cr, uid, msg.get('from') or msg.get_unixfrom())
|
||||
res = thread_pool.get_partner(cr, uid, msg.get('from', False))
|
||||
if res:
|
||||
vals.update(res)
|
||||
|
||||
|
@ -145,7 +146,7 @@ class crm_helpdesk(crm.crm_case, osv.osv):
|
|||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of update mail’s IDs
|
||||
@param ids: List of update mail’s IDs
|
||||
"""
|
||||
if isinstance(ids, (str, int, long)):
|
||||
ids = [ids]
|
||||
|
@ -177,18 +178,6 @@ class crm_helpdesk(crm.crm_case, osv.osv):
|
|||
res = self.write(cr, uid, [case.id], values, context=context)
|
||||
return res
|
||||
|
||||
def msg_send(self, cr, uid, id, *args, **argv):
|
||||
|
||||
""" Send The Message
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of email’s IDs
|
||||
@param *args: Return Tuple Value
|
||||
@param **args: Return Dictionary of Keyword Value
|
||||
"""
|
||||
return True
|
||||
|
||||
crm_helpdesk()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
<field name="history" invisible="1"/>
|
||||
<button
|
||||
string="Reply" attrs="{'invisible': [('history', '!=', True)]}"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action" />
|
||||
</tree>
|
||||
|
@ -120,7 +120,7 @@
|
|||
<group attrs="{'invisible': [('history', '!=', True)]}">
|
||||
<field name="description" colspan="4" nolabel="1" height="250"/>
|
||||
<button colspan="4" string="Reply"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action"/>
|
||||
</group>
|
||||
|
@ -139,7 +139,7 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'email_model':'crm.helpdesk', 'email_res_id': active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
-
|
||||
In order to test Forward Partner functionality, I create an opportunity and forward it to partner.
|
||||
-
|
||||
-
|
||||
I assign an email address to Administrator.
|
||||
-
|
||||
-
|
||||
!record {model: res.users, id: base.user_root}:
|
||||
user_email: admin@openerp.com
|
||||
-
|
||||
-
|
||||
I create some partner grades.
|
||||
-
|
||||
I create a grade 'First'.
|
||||
-
|
||||
-
|
||||
!record {model: res.partner.grade, id: res_partner_grade_first0}:
|
||||
name: First
|
||||
sequence: 1
|
||||
-
|
||||
-
|
||||
I create another grade 'Second'.
|
||||
-
|
||||
-
|
||||
!record {model: res.partner.grade, id: res_partner_grade_second0}:
|
||||
name: Second
|
||||
sequence: 2
|
||||
-
|
||||
-
|
||||
I create one more grade 'Third'.
|
||||
-
|
||||
-
|
||||
!record {model: res.partner.grade, id: res_partner_grade_third0}:
|
||||
name: Third
|
||||
sequence: 3
|
||||
-
|
||||
-
|
||||
I assign grade 'First' to the partner 'Axelor'.
|
||||
-
|
||||
-
|
||||
!record {model: res.partner, id: base.res_partner_desertic_hispafuentes}:
|
||||
grade_id: res_partner_grade_first0
|
||||
-
|
||||
I assgin a reply-to email address to Sales Team.
|
||||
-
|
||||
-
|
||||
!record {model: crm.case.section, id: crm.section_sales_department}:
|
||||
reply_to: sales_openerp@openerp.com
|
||||
-
|
||||
-
|
||||
I create an opportunity 'Questionnaire on OpenERP'.
|
||||
-
|
||||
-
|
||||
!record {model: crm.lead, id: crm_lead_questionnaireonopenerp0}:
|
||||
categ_id: crm.categ_oppor7
|
||||
section_id: crm.section_sales_department
|
||||
|
@ -62,7 +62,7 @@
|
|||
!python {model: crm.lead.forward.to.partner}: |
|
||||
import tools
|
||||
vals = {
|
||||
'name': 'email',
|
||||
'subject': 'email',
|
||||
'email_to': 'info@axelor.com',
|
||||
'email_from': 'Administrator <admin@openerp.com>',
|
||||
'reply_to': 'sales_openerp@openerp.com'
|
||||
|
@ -70,4 +70,4 @@
|
|||
ids = self.create(cr, uid, vals, context={'active_id': ref('crm_lead_questionnaireonopenerp0'), 'active_model': 'crm.lead'})
|
||||
assert tools.config.get('smtp_user', False), 'SMTP not configured !'
|
||||
self.action_forward(cr, uid, [ids], context={'active_id': ref('crm_lead_questionnaireonopenerp0'), 'active_model': 'crm.lead'})
|
||||
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ class crm_lead_forward_to_partner(osv.osv_memory):
|
|||
addr = partner_obj.address_get(cr, uid, [partner_id], ['contact'])
|
||||
data = {'address_id': addr['contact']}
|
||||
data.update(self.on_change_address(cr, uid, ids, addr['contact'])['value'])
|
||||
|
||||
|
||||
partner = partner_obj.browse(cr, uid, [partner_id])
|
||||
user_id = partner and partner[0].user_id or False
|
||||
email = user_id and user_id.user_email or ''
|
||||
|
@ -285,8 +285,8 @@ class crm_lead_forward_to_partner(osv.osv_memory):
|
|||
|
||||
body = self._get_case_history(cr, uid, defaults.get('history', 'latest'), lead.id, context=context)
|
||||
defaults.update({
|
||||
'name' : '%s: %s' % (_('Fwd'), lead.name),
|
||||
'description' : body,
|
||||
'subject' : '%s: %s' % (_('Fwd'), lead.name),
|
||||
'body' : body,
|
||||
'email_cc' : ''
|
||||
})
|
||||
return defaults
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
<record id="email_smtp_server_administrator0" model="email.smtp_server">
|
||||
<field name="name">Administrator</field>
|
||||
<field eval="1" name="default"/>
|
||||
<field eval="1" name="smtptls"/>
|
||||
<field name="email_id">example@test.com</field>
|
||||
<field name="state">draft</field>
|
||||
<field eval="25" name="smtpport"/>
|
||||
<field name="smtpserver">localhost</field>
|
||||
<field eval="0" name="smtpssl"/>
|
||||
</record>
|
||||
<record forcecreate="True" id="ir_cron_mail_scheduler_action" model="ir.cron">
|
||||
<field name="name">Email scheduler</field>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">hours</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
<field eval="'email.message'" name="model"/>
|
||||
<field eval="'run_mail_scheduler'" name="function"/>
|
||||
<field eval="'()'" name="args"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -26,7 +26,7 @@
|
|||
"author" : "Openlabs",
|
||||
"website" : "http://openerp.com",
|
||||
"category" : "Tools",
|
||||
"depends" : ['email'],
|
||||
"depends" : ['mail'],
|
||||
"description": """
|
||||
Email Template is extraction of Power Email basically just to send emails.
|
||||
==========================================================================
|
||||
|
|
|
@ -33,7 +33,7 @@ import pooler
|
|||
|
||||
class email_template(osv.osv):
|
||||
"Templates for sending Email"
|
||||
_inherit = 'email.message.template'
|
||||
_inherit = 'email.message.common'
|
||||
_name = "email.template"
|
||||
_description = 'Email Templates for Models'
|
||||
|
||||
|
@ -124,13 +124,6 @@ This is useful for CRM leads for example"),
|
|||
'Wizard Button',
|
||||
help="Button in the side bar of the form view of this Resource that will invoke the Window Action",
|
||||
readonly=True),
|
||||
'allowed_groups':fields.many2many(
|
||||
'res.groups',
|
||||
'template_group_rel',
|
||||
'templ_id', 'group_id',
|
||||
string="Allowed User Groups",
|
||||
help="Only users from these groups will be"
|
||||
" allowed to send mails from this Template"),
|
||||
'model_object_field':fields.many2one(
|
||||
'ir.model.fields',
|
||||
string="Field",
|
||||
|
@ -138,37 +131,36 @@ This is useful for CRM leads for example"),
|
|||
"\nIf it is a relationship field you will be able to "
|
||||
"choose the nested values in the box below\n(Note:If "
|
||||
"there are no values make sure you have selected the"
|
||||
" correct model)",
|
||||
store=False),
|
||||
" correct model)"),
|
||||
'sub_object':fields.many2one(
|
||||
'ir.model',
|
||||
'Sub-model',
|
||||
help='When a relation field is used this field'
|
||||
' will show you the type of field you have selected',
|
||||
store=False),
|
||||
' will show you the type of field you have selected'),
|
||||
'sub_model_object_field':fields.many2one(
|
||||
'ir.model.fields',
|
||||
'Sub Field',
|
||||
help="When you choose relationship fields "
|
||||
"this field will specify the sub value you can use.",
|
||||
store=False),
|
||||
"this field will specify the sub value you can use."),
|
||||
'null_value':fields.char(
|
||||
'Null Value',
|
||||
help="This Value is used if the field is empty",
|
||||
size=50, store=False),
|
||||
size=50),
|
||||
'copyvalue':fields.char(
|
||||
'Expression',
|
||||
size=100,
|
||||
help="Copy and paste the value in the "
|
||||
"location you want to use a system value.",
|
||||
store=False),
|
||||
'table_html':fields.text(
|
||||
'HTML code',
|
||||
help="Copy this html code to your HTML message"
|
||||
" body for displaying the info in your mail.",
|
||||
store=False),
|
||||
"location you want to use a system value."),
|
||||
'auto_delete': fields.boolean('Auto Delete', help="Permanently delete emails after sending"),
|
||||
'model': fields.related('model_id','model', type='char', size=128, string='Object'),
|
||||
'model': fields.related('model_id','model', type='char', size=128, string='Object', help="Placeholders can be used here."),
|
||||
'email_from': fields.char('From', size=128, help="Email From. Placeholders can be used here."),
|
||||
'email_to': fields.char('To', size=256, help="Email Recipients. Placeholders can be used here."),
|
||||
'email_cc': fields.char('Cc', size=256, help="Carbon Copy Email Recipients. Placeholders can be used here."),
|
||||
'email_bcc': fields.char('Bcc', size=256, help="Blind Carbon Copy Email Recipients. Placeholders can be used here."),
|
||||
'message_id': fields.char('Message Id', size=1024, select=1, help="Message Id on Email. Placeholders can be used here."),
|
||||
'reply_to':fields.char('Reply-To', size=250, help="Placeholders can be used here."),
|
||||
'body': fields.text('Description', translate=True, help="Placeholders can be used here."),
|
||||
'body_html': fields.text('HTML', help="Contains HTML version of email. Placeholders can be used here."),
|
||||
}
|
||||
|
||||
_sql_constraints = [
|
||||
|
@ -220,10 +212,6 @@ This is useful for CRM leads for example"),
|
|||
except:
|
||||
raise osv.except_osv(_("Warning"), _("Deletion of Record failed"))
|
||||
|
||||
def delete_action(self, cr, uid, ids, context=None):
|
||||
self.unlink_action(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
self.unlink_action(cr, uid, ids, context=context)
|
||||
return super(email_template, self).unlink(cr, uid, ids, context=context)
|
||||
|
@ -360,14 +348,14 @@ This is useful for CRM leads for example"),
|
|||
return {'value':result}
|
||||
|
||||
|
||||
def _generate_email(self, cr, uid, template_id, record_id, context=None):
|
||||
def generate_email(self, cr, uid, template_id, record_id, context=None):
|
||||
"""
|
||||
Generates an email from the template for
|
||||
record record_id of target object
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
smtp_pool = self.pool.get('email.smtp_server')
|
||||
smtp_pool = self.pool.get('ir.mail_server')
|
||||
email_message_pool = self.pool.get('email.message')
|
||||
report_xml_pool = self.pool.get('ir.actions.report.xml')
|
||||
template = self.get_email_template(cr, uid, template_id, record_id, context)
|
||||
|
@ -375,7 +363,7 @@ This is useful for CRM leads for example"),
|
|||
if not smtp_server_id and template.smtp_server_id:
|
||||
smtp_server_id = template.smtp_server_id.id
|
||||
else:
|
||||
smtp_ids = smtp_pool.search(cr, uid, [('default','=',True)])
|
||||
smtp_ids = smtp_pool.search(cr, uid, [])
|
||||
smtp_server_id = smtp_ids and smtp_ids[0]
|
||||
smtp_server = smtp_pool.browse(cr, uid, smtp_server_id, context=context)
|
||||
# determine name of sender, either it is specified in email_id
|
||||
|
@ -394,8 +382,9 @@ This is useful for CRM leads for example"),
|
|||
'email_cc': self.get_template_value(cr, uid, template.email_cc, model, record_id, context),
|
||||
'email_bcc': self.get_template_value(cr, uid, template.email_bcc, model, record_id, context),
|
||||
'reply_to': self.get_template_value(cr, uid, template.reply_to, model, record_id, context),
|
||||
'name': self.get_template_value(cr, uid, template.subject, model, record_id, context),
|
||||
'description': self.get_template_value(cr, uid, template.description, model, record_id, context),
|
||||
'subject': self.get_template_value(cr, uid, template.subject, model, record_id, context),
|
||||
'body': self.get_template_value(cr, uid, template.description, model, record_id, context),
|
||||
'auto_delete': self.get_template_value(cr, uid, template.auto_delete, model, record_id, context),
|
||||
#'body_html': self.get_template_value(cr, uid, template.body_html, model, record_id, context),
|
||||
}
|
||||
|
||||
|
@ -405,7 +394,7 @@ This is useful for CRM leads for example"),
|
|||
|
||||
elif template['track_campaign_item']:
|
||||
# get appropriate message-id
|
||||
values.update({'message_id': tools.misc.generate_tracking_message_id(record_id)})
|
||||
values.update({'message_id': smtp_pool.generate_tracking_message_id(record_id)})
|
||||
|
||||
#Use signatures if allowed
|
||||
if template.user_signature:
|
||||
|
@ -444,53 +433,14 @@ This is useful for CRM leads for example"),
|
|||
|
||||
#Send emails
|
||||
context.update({'notemplate':True})
|
||||
email_id = email_message_pool.email_send(cr, uid, values.get('email_from'), values.get('email_to'), values.get('name'), values.get('description'),
|
||||
model=model, email_cc=values.get('email_cc'), email_bcc=values.get('email_bcc'), reply_to=values.get('reply_to'),
|
||||
attach=attachment, message_id=values.get('message_id'), openobject_id=record_id, debug=True, subtype='plain', x_headers={}, priority='3', smtp_server_id=smtp_server.id, context=context)
|
||||
email_id = email_message_pool.schedule_with_attach(cr, uid, values.get('email_from'), values.get('email_to'), values.get('name'),
|
||||
values.get('description'), model=model, email_cc=values.get('email_cc'), email_bcc=values.get('email_bcc'),
|
||||
reply_to=values.get('reply_to'), attach=attachment, message_id=values.get('message_id'), openobject_id=record_id,
|
||||
debug=True, subtype='plain', x_headers={}, priority='3', smtp_server_id=smtp_server.id, auto_delete=values.get('auto_delete'), context=context)
|
||||
email_message_pool.write(cr, uid, email_id, {'template_id': context.get('template_id',template.id)})
|
||||
return email_id
|
||||
|
||||
|
||||
|
||||
def generate_email(self, cr, uid, template_id, record_id, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
email_id = self._generate_email(cr, uid, template_id, record_id, context)
|
||||
return email_id
|
||||
|
||||
email_template()
|
||||
|
||||
class email_message(osv.osv):
|
||||
_inherit = 'email.message'
|
||||
_columns = {
|
||||
'template_id': fields.many2one('email.template', 'Email-Template', readonly=True),
|
||||
}
|
||||
|
||||
def process_email_queue(self, cr, uid, ids=None, context=None):
|
||||
result = super(email_message, self).process_email_queue(cr, uid, ids, context)
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
for message in self.browse(cr, uid, result, context):
|
||||
if message.template_id and message.template_id.auto_delete:
|
||||
self.unlink(cr, uid, [id], context=context)
|
||||
attachment_ids = [x.id for x in message.attachments_ids]
|
||||
attachment_obj.unlink(cr, uid, attachment_ids, context=context)
|
||||
return result
|
||||
|
||||
def email_send(self, cr, uid, email_from, email_to, subject, body, model=False, email_cc=None, email_bcc=None, reply_to=False, attach=None,
|
||||
message_id=False, references=False, openobject_id=False, debug=False, subtype='plain', x_headers={}, priority='3', smtp_server_id=False, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
notemplate = context.get('notemplate', True)
|
||||
if (not notemplate) and model and openobject_id:
|
||||
template_pool = self.pool.get('email.template')
|
||||
template_ids = template_pool.search(cr, uid, [('model','=',model)])
|
||||
if template_ids and len(template_ids):
|
||||
template_id = template_ids[0]
|
||||
return template_pool.generate_email(cr, uid, template_id, openobject_id, context=context)
|
||||
|
||||
return super(email_message, self).email_send(cr, uid, email_from, email_to, subject, body, model=model, email_cc=email_cc, email_bcc=email_bcc, reply_to=reply_to, attach=attach,
|
||||
message_id=message_id, references=references, openobject_id=openobject_id, debug=debug, subtype=subtype, x_headers=x_headers, priority=priority, smtp_server_id=smtp_server_id, context=context)
|
||||
|
||||
email_message()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<field name="subject" colspan="4" required="1"/>
|
||||
<notebook>
|
||||
<page string="Body">
|
||||
<field name="description" colspan="4" nolabel="1"/>
|
||||
<field name="body" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<!-- <page string="Body (Raw HTML)">
|
||||
<field name="def_body_html" colspan="4" nolabel="1"/>
|
||||
|
@ -70,7 +70,7 @@
|
|||
<button name="create_action" string="Create Action" type="object" icon="gtk-execute" colspan="2" attrs="{'invisible':[('ref_ir_act_window','!=',False), ('ref_ir_value','!=',False)]}"/>
|
||||
<field name="ref_ir_act_window"/>
|
||||
<field name="ref_ir_value"/>
|
||||
<button name="delete_action" string="Delete Action" type="object" icon="gtk-delete" colspan="2" attrs="{'invisible':[('ref_ir_act_window','=',False), ('ref_ir_value','=',False)]}"/>
|
||||
<button name="unlink_action" string="Delete Action" type="object" icon="gtk-delete" colspan="2" attrs="{'invisible':[('ref_ir_act_window','=',False), ('ref_ir_value','=',False)]}"/>
|
||||
</group>
|
||||
<group colspan="2" col="2">
|
||||
<separator string="Advanced Options" colspan="2"/>
|
||||
|
@ -153,21 +153,7 @@
|
|||
</record>
|
||||
|
||||
<menuitem name="Templates" id="menu_email_template_all_tools"
|
||||
parent="email.menu_email_message_tools" action="action_email_template_tree_all" />
|
||||
|
||||
<!-- Inherit email.message view -->
|
||||
|
||||
<record model="ir.ui.view" id="view_email_message_template_form">
|
||||
<field name="name">email.message.template.form</field>
|
||||
<field name="model">email.message</field>
|
||||
<field name="inherit_id" ref="email.view_email_message_form"/>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="debug" position="after">
|
||||
<field name="template_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
parent="mail.menu_email_message_tools" action="action_email_template_tree_all" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -44,8 +44,8 @@ class email_compose_message(osv.osv_memory):
|
|||
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,
|
||||
'body' : _get_template_value('body') or False,
|
||||
'subject' : _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,
|
||||
|
@ -92,11 +92,11 @@ class email_compose_message(osv.osv_memory):
|
|||
if 'email_bcc' in fields:
|
||||
result.update({'email_bcc' : vals.get('email_bcc', False)})
|
||||
|
||||
if 'name' in fields:
|
||||
result.update({'name' : vals.get('name', False)})
|
||||
if 'subject' in fields:
|
||||
result.update({'subject' : vals.get('name', False)})
|
||||
|
||||
if 'description' in fields:
|
||||
result.update({'description' : vals.get('description', False)})
|
||||
if 'body' in fields:
|
||||
result.update({'body' : vals.get('body', False)})
|
||||
|
||||
if 'reply_to' in fields:
|
||||
result.update({'reply_to' : vals.get('reply_to', False)})
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<field name="name">email.compose.message.form</field>
|
||||
<field name="model">email.compose.message</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="email.email_compose_message_wizard_form"/>
|
||||
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="res_id" position="replace">
|
||||
<field name="template_id" colspan="4"
|
||||
|
|
|
@ -93,13 +93,14 @@ class email_template_preview(osv.osv_memory):
|
|||
if template.message_id:
|
||||
vals['message_id'] = self.get_template_value(cr, uid, message_id, model, res_id, context)
|
||||
elif template.track_campaign_item:
|
||||
vals['message_id'] = tools.misc.generate_tracking_message_id(res_id)
|
||||
smtp_server_obj = self.pool.get('ir.mail_server')
|
||||
vals['message_id'] = smtp_server_obj.generate_tracking_message_id(res_id)
|
||||
vals['subject'] = self.get_template_value(cr, uid, template.subject, model, res_id, context)
|
||||
description = self.get_template_value(cr, uid, template.description, model, res_id, context) or ''
|
||||
description = self.get_template_value(cr, uid, template.body, model, res_id, context) or ''
|
||||
if template.user_signature:
|
||||
signature = self.pool.get('res.users').browse(cr, uid, uid, context).signature
|
||||
description += '\n' + signature
|
||||
vals['description'] = description
|
||||
vals['body'] = description
|
||||
vals['report_name'] = self.get_template_value(cr, uid, template.report_name, model, res_id, context)
|
||||
return {'value':vals}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<separator string= "Body" colspan="2" />
|
||||
<!--<separator string= "Body(Html)" colspan="2" />-->
|
||||
<newline/>
|
||||
<field name="description" nolabel="1" colspan="2" readonly="1"/>
|
||||
<field name="body" nolabel="1" colspan="2" readonly="1"/>
|
||||
<!-- <field name="body_html" nolabel="1" colspan="2" readonly="1"/>-->
|
||||
</group>
|
||||
<field name="report_name" colspan="2" readonly="1"/>
|
||||
|
|
|
@ -91,8 +91,8 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
if 'subject' in fields:
|
||||
result['subject'] = _get_template_value('subject')
|
||||
|
||||
if 'description' in fields:
|
||||
result['description'] = _get_template_value('description')
|
||||
if 'body' in fields:
|
||||
result['body'] = _get_template_value('description')
|
||||
|
||||
#if 'body_html' in fields:
|
||||
# result['body_html'] = _get_template_value('body_html')
|
||||
|
@ -132,7 +132,7 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
mailid = self.save_to_mailbox(cr, uid, ids, context=context)
|
||||
self.pool.get('email.message').write(cr, uid, mailid, {'folder':'drafts', 'state': 'draft'}, context)
|
||||
self.pool.get('email.message').write(cr, uid, mailid, {'state': 'outgoing'}, context)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
def send_mail(self, cr, uid, ids, context=None):
|
||||
|
@ -170,7 +170,7 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
email_ids = []
|
||||
for template in self.browse(cr, uid, ids, context=context):
|
||||
for record_id in context.get('src_rec_ids',[]):
|
||||
email_id = self._generate_email(cr, uid, template.id, record_id, context)
|
||||
email_id = self.generate_email(cr, uid, template.id, record_id, context)
|
||||
email_ids.append(email_id)
|
||||
return email_ids
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ Note that:
|
|||
Association / Configuration / Types of Events
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['crm', 'base_contact', 'account', 'marketing', 'email'],
|
||||
'depends': ['crm', 'base_contact', 'account', 'marketing', 'mail'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'security/event_security.xml',
|
||||
|
|
|
@ -282,7 +282,7 @@ class event_registration(osv.osv):
|
|||
"""Event Registration"""
|
||||
_name= 'event.registration'
|
||||
_description = __doc__
|
||||
_inherit = 'mailgate.thread'
|
||||
_inherit = 'email.thread'
|
||||
|
||||
def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
|
||||
cur_obj = self.pool.get('res.currency')
|
||||
|
@ -547,7 +547,7 @@ class event_registration(osv.osv):
|
|||
subject = _('Auto Confirmation: [%s] %s') %(regestration.id, regestration.name)
|
||||
body = regestration.event_id.mail_confirm
|
||||
if subject or body:
|
||||
email_message_obj.email_send(cr, uid, src, email_to, subject, body, model='event.registration', email_cc=email_cc, openobject_id=regestration.id)
|
||||
email_message_obj.schedule_with_attach(cr, uid, src, email_to, subject, body, model='event.registration', email_cc=email_cc, openobject_id=regestration.id)
|
||||
self.history(cr, uid, [regestration], subject, history = True, \
|
||||
email=email_to, details=body, \
|
||||
subject=subject, email_from=src, \
|
||||
|
|
|
@ -393,7 +393,7 @@
|
|||
<field name="history" invisible="1"/>
|
||||
<button
|
||||
string="Reply" attrs="{'invisible': [('history', '!=', True)]}"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action" />
|
||||
</tree>
|
||||
|
@ -411,7 +411,7 @@
|
|||
<group attrs="{'invisible': [('history', '!=', True)]}">
|
||||
<field name="description" colspan="4" nolabel="1" height="250"/>
|
||||
<button colspan="4" string="Reply"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action"/>
|
||||
</group>
|
||||
|
@ -430,7 +430,7 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'email_model':'event.registration', 'email_res_id': active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
{
|
||||
"name" : "Fetchmail Server",
|
||||
"version" : "1.0",
|
||||
"depends" : ["base", 'email'],
|
||||
"depends" : ["base", 'mail'],
|
||||
"author" : "OpenERP SA",
|
||||
"category": 'Tools',
|
||||
"description": """
|
||||
|
|
|
@ -82,21 +82,9 @@ class email_server(osv.osv):
|
|||
return False
|
||||
return True
|
||||
|
||||
def check_model(self, cr, uid, ids, context = None):
|
||||
if context is None:
|
||||
context = {}
|
||||
current_rec = self.read(cr, uid, ids, context)
|
||||
if current_rec:
|
||||
current_rec = current_rec[0]
|
||||
model_name = self.pool.get('ir.model').browse(cr, uid, current_rec.get('object_id')[0]).model
|
||||
model = self.pool.get(model_name)
|
||||
if hasattr(model, 'message_new'):
|
||||
return True
|
||||
return False
|
||||
|
||||
_constraints = [
|
||||
(check_duplicate, 'Warning! Can\'t have duplicate server configuration!', ['user', 'password']),
|
||||
(check_model, 'Warning! Record for selected Model can not be created\nPlease choose valid Model', ['object_id'])
|
||||
|
||||
]
|
||||
|
||||
def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False):
|
||||
|
@ -146,7 +134,7 @@ class email_server(osv.osv):
|
|||
if context.get('get_server',False):
|
||||
return ret_server
|
||||
except Exception, e:
|
||||
logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (e))
|
||||
logger.notifyChannel(server.type, netsvc.LOG_ERROR, '%s' % (e))
|
||||
return True
|
||||
|
||||
def button_fetch_mail(self, cr, uid, ids, context=None):
|
||||
|
@ -161,7 +149,7 @@ class email_server(osv.osv):
|
|||
def fetch_mail(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
email_tool = self.pool.get('email.server.tools')
|
||||
thread_pool = self.pool.get('email.thread')
|
||||
action_pool = self.pool.get('ir.actions.server')
|
||||
context.update({'get_server': True})
|
||||
for server in self.browse(cr, uid, ids, context=context):
|
||||
|
@ -174,7 +162,7 @@ class email_server(osv.osv):
|
|||
result, data = imap_server.search(None, '(UNSEEN)')
|
||||
for num in data[0].split():
|
||||
result, data = imap_server.fetch(num, '(RFC822)')
|
||||
res_id = email_tool.process_email(cr, user, server.object_id.model, data[0][1], attach=server.attach, context=context)
|
||||
res_id = thread_pool.process_email(cr, user, server.object_id.model, data[0][1], attach=server.attach, context=context)
|
||||
if res_id and server.action_id:
|
||||
action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]})
|
||||
|
||||
|
@ -183,7 +171,7 @@ class email_server(osv.osv):
|
|||
logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name))
|
||||
|
||||
except Exception, e:
|
||||
logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e)))
|
||||
logger.notifyChannel(server.type, netsvc.LOG_ERROR, '%s' % (tools.ustr(e)))
|
||||
finally:
|
||||
if imap_server:
|
||||
imap_server.close()
|
||||
|
@ -196,14 +184,14 @@ class email_server(osv.osv):
|
|||
for num in range(1, numMsgs + 1):
|
||||
(header, msges, octets) = pop_server.retr(num)
|
||||
msg = '\n'.join(msges)
|
||||
res_id = email_tool.process_email(cr, user, server.object_id.model, msg, attach=server.attach, context=context)
|
||||
res_id = thread_pool.process_email(cr, user, server.object_id.model, msg, attach=server.attach, context=context)
|
||||
if res_id and server.action_id:
|
||||
action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]})
|
||||
|
||||
pop_server.dele(num)
|
||||
logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (numMsgs, server.name))
|
||||
except Exception, e:
|
||||
logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e)))
|
||||
logger.notifyChannel(server.type, netsvc.LOG_ERROR, '%s' % (tools.ustr(e)))
|
||||
finally:
|
||||
if pop_server:
|
||||
pop_server.quit()
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
</record>
|
||||
|
||||
<menuitem
|
||||
parent="email.menu_config_email"
|
||||
parent="mail.menu_config_email"
|
||||
id="menu_action_fetchmail_server_tree"
|
||||
action="action_email_server_tree"
|
||||
name="Incomming Servers"
|
||||
|
@ -112,7 +112,7 @@
|
|||
<field name="name">email.message.tree</field>
|
||||
<field name="model">email.message</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="inherit_id" ref="email.view_email_message_tree"/>
|
||||
<field name="inherit_id" ref="mail.view_email_message_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="user_id" position="after">
|
||||
<field name="server_id" select="1"/>
|
||||
|
@ -124,7 +124,7 @@
|
|||
<field name="name">email.message.inherit.search</field>
|
||||
<field name="model">email.message</field>
|
||||
<field name="type">search</field>
|
||||
<field name="inherit_id" ref="email.view_email_message_search"/>
|
||||
<field name="inherit_id" ref="mail.view_email_message_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/search/group/filter[@string='Thread']" position="before">
|
||||
<filter string="Mail Server" icon="terp-accessories-archiver" domain="[]" context="{'group_by':'server_id'}"/>
|
||||
|
@ -141,9 +141,9 @@
|
|||
<field name="search_view_id" ref="email_message_search_view"/>
|
||||
</record>
|
||||
|
||||
<act_window
|
||||
<act_window
|
||||
context="{'search_default_server_id': [active_id], 'default_server_id': active_id}"
|
||||
id="act_server_history" name="Emails"
|
||||
id="act_server_history" name="Messages" domain="[('history', '=', True), ('server_id', '=', active_id)]"
|
||||
res_model="email.message" src_model="email.server"/>
|
||||
|
||||
</data>
|
||||
|
|
|
@ -229,7 +229,7 @@ class hr_evaluation(osv.osv):
|
|||
sub = phase.email_subject
|
||||
dest = [child.work_email]
|
||||
if dest:
|
||||
email_message_obj.email_send(cr, uid, evaluation.employee_id.work_email, dest, sub, body, model='hr_evaluation.evaluation')
|
||||
email_message_obj.schedule_with_attach(cr, uid, evaluation.employee_id.work_email, dest, sub, body, model='hr_evaluation.evaluation')
|
||||
|
||||
self.write(cr, uid, ids, {'state':'wait'}, context=context)
|
||||
return True
|
||||
|
|
|
@ -35,7 +35,7 @@ class hr_evaluation_reminder(osv.osv_memory):
|
|||
current_interview = hr_evaluation_interview_obj.browse(cr, uid, evaluation_data.get('evaluation_id'))
|
||||
if current_interview.state == "waiting_answer" and current_interview.user_to_review_id.work_email :
|
||||
msg = " Hello %s, \n\n Kindly post your response for '%s' survey interview. \n\n Thanks," %(current_interview.user_to_review_id.name, current_interview.survey_id.title)
|
||||
email_message_obj.email_send(cr, uid, tools.config['email_from'], [current_interview.user_to_review_id.work_email],\
|
||||
email_message_obj.schedule_with_attach(cr, uid, tools.config['email_from'], [current_interview.user_to_review_id.work_email],\
|
||||
'Reminder to fill up Survey', msg, model='hr.evaluation.reminder')
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class hr_applicant(crm.crm_case, osv.osv):
|
|||
_name = "hr.applicant"
|
||||
_description = "Applicant"
|
||||
_order = "id desc"
|
||||
_inherit = ['mailgate.thread']
|
||||
_inherit = ['email.thread']
|
||||
|
||||
def _compute_day(self, cr, uid, ids, fields, args, context=None):
|
||||
"""
|
||||
|
@ -308,7 +308,7 @@ class hr_applicant(crm.crm_case, osv.osv):
|
|||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks
|
||||
"""
|
||||
mailgate_pool = self.pool.get('email.server.tools')
|
||||
thread_pool = self.pool.get('email.thread')
|
||||
attach_obj = self.pool.get('ir.attachment')
|
||||
|
||||
subject = msg.get('subject')
|
||||
|
@ -326,7 +326,7 @@ class hr_applicant(crm.crm_case, osv.osv):
|
|||
if msg.get('priority', False):
|
||||
vals['priority'] = priority
|
||||
|
||||
res = mailgate_pool.get_partner(cr, uid, msg.get('from'))
|
||||
res = thread_pool.get_partner(cr, uid, msg.get('from'))
|
||||
if res:
|
||||
vals.update(res)
|
||||
res = self.create(cr, uid, vals, context=context)
|
||||
|
@ -380,17 +380,6 @@ class hr_applicant(crm.crm_case, osv.osv):
|
|||
res = self.write(cr, uid, ids, vals, context=context)
|
||||
return res
|
||||
|
||||
def msg_send(self, cr, uid, id, *args, **argv):
|
||||
""" Send The Message
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of email’s IDs
|
||||
@param *args: Return Tuple Value
|
||||
@param **args: Return Dictionary of Keyword Value
|
||||
"""
|
||||
return True
|
||||
|
||||
def case_open(self, cr, uid, ids, *args):
|
||||
"""
|
||||
@param self: The object pointer
|
||||
|
|
|
@ -147,7 +147,7 @@
|
|||
<field name="history" invisible="1"/>
|
||||
<button
|
||||
string="Reply" attrs="{'invisible': [('history', '!=', True)]}"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action" />
|
||||
</tree>
|
||||
|
@ -165,7 +165,7 @@
|
|||
<group attrs="{'invisible': [('history', '!=', True)]}">
|
||||
<field name="description" colspan="4" nolabel="1" height="250"/>
|
||||
<button colspan="4" string="Reply"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action"/>
|
||||
</group>
|
||||
|
@ -184,7 +184,7 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'email_model': 'hr.applicant', 'email_res_id': active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"access_hr_recruitment_report","hr.recruitment.report","model_hr_recruitment_report","base.group_hr_manager",1,1,1,1
|
||||
"access_hr_recruitment_stage_user","hr.recruitment.stage.user","model_hr_recruitment_stage","base.group_hr_user",1,1,1,1
|
||||
"access_hr_recruitment_degree","hr.recruitment.degree","model_hr_recruitment_degree","base.group_hr_user",1,1,1,1
|
||||
"access_email_message_user","email.message.user","email.model_email_message","base.group_hr_user",1,1,1,1
|
||||
"access_email_message_user","email.message.user","mail.model_email_message","base.group_hr_user",1,1,1,1
|
||||
"access_res_partner_hr_user","res.partner.user","base.model_res_partner","base.group_hr_user",1,1,1,1
|
||||
"access_res_partner_address_hr_user","res.partner.address.user","base.model_res_partner_address","base.group_hr_user",1,1,1,1
|
||||
"access_survey_hr_user","survey.hr.user","survey.model_survey","base.group_hr_user",1,1,1,0
|
||||
|
|
|
|
@ -19,9 +19,8 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import email_smtp_server
|
||||
import email_message
|
||||
import email_gateway
|
||||
import email_thread
|
||||
import res_partner
|
||||
import wizard
|
||||
|
|
@ -37,7 +37,7 @@ The generic email system allows to send and receive emails.
|
|||
'update_xml': [
|
||||
"wizard/email_compose_message_view.xml",
|
||||
"email_view.xml",
|
||||
"email_gateway_view.xml",
|
||||
"email_thread_view.xml",
|
||||
"res_partner_view.xml",
|
||||
'security/ir.model.access.csv',
|
||||
'email_data.xml',
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
<record forcecreate="True" id="ir_cron_mail_scheduler_action" model="ir.cron">
|
||||
<field name="name">Email scheduler</field>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">hours</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
<field eval="'email.message'" name="model"/>
|
||||
<field eval="'process_email_queue'" name="function"/>
|
||||
<field eval="'()'" name="args"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -26,6 +26,10 @@ import tools
|
|||
import netsvc
|
||||
import base64
|
||||
import time
|
||||
import logging
|
||||
import re
|
||||
import email
|
||||
from email.header import decode_header
|
||||
#import binascii
|
||||
#import email
|
||||
#from email.header import decode_header
|
||||
|
@ -57,16 +61,18 @@ import time
|
|||
#]
|
||||
|
||||
LOGGER = netsvc.Logger()
|
||||
_logger = logging.getLogger('mail')
|
||||
|
||||
def format_date_tz(date, tz=None):
|
||||
if not date:
|
||||
return 'n/a'
|
||||
format = tools.DEFAULT_SERVER_DATETIME_FORMAT
|
||||
return tools.server_to_local_timestamp(date, format, format, tz)
|
||||
|
||||
class email_message_template(osv.osv_memory):
|
||||
_name = 'email.message.template'
|
||||
class email_message_common(osv.osv_memory):
|
||||
_name = 'email.message.common'
|
||||
_columns = {
|
||||
'name':fields.text('Subject', translate=True),
|
||||
'subject':fields.text('Subject', translate=True),
|
||||
'model': fields.char('Object Name', size=128, select=1),
|
||||
'res_id': fields.integer('Resource ID', select=1),
|
||||
'date': fields.datetime('Date'),
|
||||
|
@ -79,20 +85,22 @@ class email_message_template(osv.osv_memory):
|
|||
'references': fields.text('References', help="References emails."),
|
||||
'reply_to':fields.char('Reply-To', size=250),
|
||||
'sub_type': fields.char('Sub Type', size=32),
|
||||
'headers': fields.char('x_headers',size=256),
|
||||
'headers': fields.text('x_headers'),
|
||||
'priority':fields.integer('Priority'),
|
||||
'description': fields.text('Description', translate=True),
|
||||
'smtp_server_id':fields.many2one('email.smtp_server', 'SMTP Server'),
|
||||
'body': fields.text('Description', translate=True),
|
||||
'body_html': fields.text('HTML', help="Contains HTML version of email"),
|
||||
'smtp_server_id':fields.many2one('ir.mail_server', 'SMTP Server'),
|
||||
}
|
||||
_rec_name = 'subject'
|
||||
|
||||
_sql_constraints = []
|
||||
email_message_template()
|
||||
email_message_common()
|
||||
|
||||
class email_message(osv.osv):
|
||||
'''
|
||||
Email Message
|
||||
'''
|
||||
_inherit = 'email.message.template'
|
||||
_inherit = 'email.message.common'
|
||||
_name = 'email.message'
|
||||
_description = 'Email Message'
|
||||
_order = 'date desc'
|
||||
|
@ -160,59 +168,34 @@ class email_message(osv.osv):
|
|||
for message in self.browse(cr, uid, ids, context=context):
|
||||
msg_txt = ''
|
||||
if message.history:
|
||||
msg_txt += _('%s wrote on %s:\n\t') % (message.email_from or '/', format_date_tz(message.date, tz))
|
||||
if message.description:
|
||||
msg_txt += self.truncate_data(cr, uid, message.description, context=context)
|
||||
msg_txt += (message.email_from or '/') + _(' wrote on ') + format_date_tz(message.date, tz) + ':\n\t'
|
||||
if message.body:
|
||||
msg_txt += self.truncate_data(cr, uid, message.body, context=context)
|
||||
else:
|
||||
msg_txt = _('%s on %s:\n\t') % (message.user_id.name or '/', format_date_tz(message.date, tz))
|
||||
msg_txt += message.name
|
||||
msg_txt = (message.user_id.name or '/') + _(' on ') + format_date_tz(message.date, tz) + ':\n\t'
|
||||
msg_txt += message.subject
|
||||
result[message.id] = msg_txt
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'message': fields.text('Description'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'attachment_ids': fields.many2many('ir.attachment', 'message_attachment_rel', 'message_id', 'attachment_id', 'Attachments'),
|
||||
'display_text': fields.function(_get_display_text, method=True, type='text', size="512", string='Display Text'),
|
||||
'debug':fields.boolean('Debug', readonly=True),
|
||||
'history': fields.boolean('History', readonly=True),
|
||||
'folder':fields.selection([
|
||||
('drafts', 'Drafts'),
|
||||
('inbox', 'Inbox'),
|
||||
('outbox', 'Outbox'),
|
||||
('trash', 'Trash'),
|
||||
('sent', 'Sent Items'),
|
||||
], 'Folder'),
|
||||
'state':fields.selection([
|
||||
('draft', 'Draft'),
|
||||
('sending', 'Sending'),
|
||||
('waiting', 'Waiting'),
|
||||
('outgoing', 'Outgoing'),
|
||||
('sent', 'Sent'),
|
||||
('received', 'Received'),
|
||||
('exception', 'Exception'),
|
||||
('cancel', 'Cancelled'),
|
||||
], 'State', readonly=True),
|
||||
'auto_delete': fields.boolean('Auto Delete', help="Permanently delete emails after sending"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state': lambda * a: 'draft',
|
||||
'folder': lambda * a: 'outbox',
|
||||
}
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
It just changes the folder of the item to "Trash", if it is no in Trash folder yet,
|
||||
or completely deletes it if it is already in Trash.
|
||||
"""
|
||||
to_update = []
|
||||
to_remove = []
|
||||
for mail in self.browse(cr, uid, ids, context=context):
|
||||
if mail.folder == 'trash':
|
||||
to_remove.append(mail.id)
|
||||
else:
|
||||
to_update.append(mail.id)
|
||||
# Changes the folder to trash
|
||||
self.write(cr, uid, to_update, {'folder': 'trash'}, context=context)
|
||||
return super(email_message, self).unlink(cr, uid, to_remove, context=context)
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute("""SELECT indexname
|
||||
FROM pg_indexes
|
||||
|
@ -221,25 +204,8 @@ class email_message(osv.osv):
|
|||
cr.execute("""CREATE INDEX email_message_res_id_model_idx
|
||||
ON email_message (model, res_id)""")
|
||||
|
||||
def process_queue(self, cr, uid, ids, arg):
|
||||
self.process_email_queue(cr, uid, ids=ids)
|
||||
return True
|
||||
|
||||
def run_mail_scheduler(self, cursor, user, context=None):
|
||||
"""
|
||||
This method is called by OpenERP Scheduler
|
||||
to periodically send emails
|
||||
"""
|
||||
try:
|
||||
self.process_email_queue(cursor, user, context=context)
|
||||
except Exception, e:
|
||||
LOGGER.notifyChannel(
|
||||
"Email Template",
|
||||
netsvc.LOG_ERROR,
|
||||
_("Error sending mail: %s") % e)
|
||||
|
||||
def email_send(self, cr, uid, email_from, email_to, subject, body, model=False, email_cc=None, email_bcc=None, reply_to=False, attach=None,
|
||||
message_id=False, references=False, openobject_id=False, debug=False, subtype='plain', x_headers={}, priority='3', smtp_server_id=False, context=None):
|
||||
def schedule_with_attach(self, cr, uid, email_from, email_to, subject, body, model=False, email_cc=None, email_bcc=None, reply_to=False, attach=None,
|
||||
message_id=False, references=False, openobject_id=False, debug=False, subtype='plain', x_headers={}, priority='3', smtp_server_id=False, context=None, auto_delete=False):
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
if email_to and type(email_to) != list:
|
||||
email_to = [email_to]
|
||||
|
@ -249,11 +215,11 @@ class email_message(osv.osv):
|
|||
email_bcc = [email_bcc]
|
||||
|
||||
msg_vals = {
|
||||
'name': subject,
|
||||
'subject': subject,
|
||||
'model': model or '',
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'user_id': uid,
|
||||
'description': body,
|
||||
'body': body,
|
||||
'email_from': email_from,
|
||||
'email_to': email_to and ','.join(email_to) or '',
|
||||
'email_cc': email_cc and ','.join(email_cc) or '',
|
||||
|
@ -266,57 +232,188 @@ class email_message(osv.osv):
|
|||
'headers': x_headers or False,
|
||||
'priority': priority,
|
||||
'debug': debug,
|
||||
'folder': 'outbox',
|
||||
'history': True,
|
||||
'smtp_server_id': smtp_server_id,
|
||||
'state': 'waiting',
|
||||
'state': 'outgoing',
|
||||
'auto_delete': auto_delete
|
||||
}
|
||||
email_msg_id = self.create(cr, uid, msg_vals, context)
|
||||
if attach:
|
||||
attachment_ids = []
|
||||
for attachment in attach:
|
||||
attachment_data = {
|
||||
'name': (subject or '') + _(' (Email Attachment)'),
|
||||
'name': attachment[0],
|
||||
'subject': (subject or '') + _(' (Email Attachment)'),
|
||||
'datas': attachment[1],
|
||||
'datas_fname': attachment[0],
|
||||
'description': subject or _('No Description'),
|
||||
'body': subject or _('No Description'),
|
||||
'res_model':'email.message',
|
||||
'res_id': email_msg_id,
|
||||
}
|
||||
if context.has_key('default_type'):
|
||||
del context['default_type']
|
||||
attachment_ids.append(attachment_obj.create(cr, uid, attachment_data, context))
|
||||
self.write(cr, uid, email_msg_id,
|
||||
{ 'attachment_ids': [[6, 0, attachment_ids]] }, context)
|
||||
return email_msg_id
|
||||
|
||||
def process_retry(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'state':'waiting'}, context)
|
||||
return self.write(cr, uid, ids, {'state':'outgoing'}, context)
|
||||
|
||||
def process_email_queue(self, cr, uid, ids=None, context=None):
|
||||
if ids is None:
|
||||
ids = []
|
||||
if context is None:
|
||||
context = {}
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
smtp_server_obj = self.pool.get('email.smtp_server')
|
||||
if not ids:
|
||||
filters = [('folder', '=', 'outbox'), ('state', '=', 'waiting')]
|
||||
filters = [('state', '=', 'outgoing')]
|
||||
if 'filters' in context:
|
||||
filters.extend(context['filters'])
|
||||
ids = self.search(cr, uid, filters, context=context)
|
||||
self.write(cr, uid, ids, {'state':'sending', 'folder':'sent'}, context)
|
||||
try:
|
||||
res = self.send_email(cr, uid, ids, auto_commit=True, context=context)
|
||||
except Exception, error:
|
||||
logger = netsvc.Logger()
|
||||
msg = _("Sending of Mail failed. Error: %s") % (error)
|
||||
logger.notifyChannel("email", netsvc.LOG_ERROR, msg)
|
||||
return False
|
||||
return res
|
||||
|
||||
def _decode_header(self, text):
|
||||
"""Returns unicode() string conversion of the the given encoded smtp header"""
|
||||
if text:
|
||||
text = decode_header(text.replace('\r', ''))
|
||||
return ''.join([tools.ustr(x[0], x[1]) for x in text])
|
||||
|
||||
def to_email(self,text):
|
||||
return re.findall(r'([^ ,<@]+@[^> ,]+)',text)
|
||||
|
||||
def parse_message(self, message):
|
||||
"""Return Dictionary Object after parse EML Message String
|
||||
@param message: email.message.Message object or string or unicode object
|
||||
"""
|
||||
if isinstance(message, str):
|
||||
msg_txt = email.message_from_string(message)
|
||||
|
||||
# Warning: message_from_string doesn't always work correctly on unicode,
|
||||
# we must use utf-8 strings here :-(
|
||||
if isinstance(message, unicode):
|
||||
message = message.encode('utf-8')
|
||||
msg_txt = email.message_from_string(message)
|
||||
|
||||
msg_txt = message
|
||||
message_id = msg_txt.get('message-id', False)
|
||||
msg = {}
|
||||
|
||||
if not message_id:
|
||||
# Very unusual situation, be we should be fault-tolerant here
|
||||
message_id = time.time()
|
||||
msg_txt['message-id'] = message_id
|
||||
_logger.info('Parsing Message without message-id, generating a random one: %s', message_id)
|
||||
|
||||
|
||||
fields = msg_txt.keys()
|
||||
msg['id'] = message_id
|
||||
msg['message-id'] = message_id
|
||||
|
||||
if 'Subject' in fields:
|
||||
msg['subject'] = self._decode_header(msg_txt.get('Subject'))
|
||||
|
||||
if 'Content-Type' in fields:
|
||||
msg['content-type'] = msg_txt.get('Content-Type')
|
||||
|
||||
if 'From' in fields:
|
||||
msg['from'] = self._decode_header(msg_txt.get('From') or msg_txt.get_unixfrom())
|
||||
|
||||
if 'Delivered-To' in fields:
|
||||
msg['to'] = self._decode_header(msg_txt.get('Delivered-To'))
|
||||
|
||||
if 'CC' in fields:
|
||||
msg['cc'] = self._decode_header(msg_txt.get('CC'))
|
||||
|
||||
if 'Reply-to' in fields:
|
||||
msg['reply'] = self._decode_header(msg_txt.get('Reply-To'))
|
||||
|
||||
if 'Date' in fields:
|
||||
msg['date'] = self._decode_header(msg_txt.get('Date'))
|
||||
|
||||
if 'Content-Transfer-Encoding' in fields:
|
||||
msg['encoding'] = msg_txt.get('Content-Transfer-Encoding')
|
||||
|
||||
if 'References' in fields:
|
||||
msg['references'] = msg_txt.get('References')
|
||||
|
||||
if 'In-Reply-To' in fields:
|
||||
msg['in-reply-to'] = msg_txt.get('In-Reply-To')
|
||||
|
||||
if 'X-Priority' in fields:
|
||||
msg['priority'] = msg_txt.get('X-Priority', '3 (Normal)').split(' ')[0] #TOFIX:
|
||||
|
||||
if not msg_txt.is_multipart() or 'text/plain' in msg.get('content-type', ''):
|
||||
encoding = msg_txt.get_content_charset()
|
||||
body = msg_txt.get_payload(decode=True)
|
||||
if 'text/html' in msg.get('content-type', ''):
|
||||
body = tools.html2plaintext(body)
|
||||
msg['body'] = tools.ustr(body, encoding)
|
||||
|
||||
attachments = {}
|
||||
has_plain_text = False
|
||||
if msg_txt.is_multipart() or 'multipart/alternative' in msg.get('content-type', ''):
|
||||
body = ""
|
||||
for part in msg_txt.walk():
|
||||
if part.get_content_maintype() == 'multipart':
|
||||
continue
|
||||
|
||||
encoding = part.get_content_charset()
|
||||
filename = part.get_filename()
|
||||
if part.get_content_maintype()=='text':
|
||||
content = part.get_payload(decode=True)
|
||||
if filename:
|
||||
attachments[filename] = content
|
||||
elif not has_plain_text:
|
||||
# main content parts should have 'text' maintype
|
||||
# and no filename. we ignore the html part if
|
||||
# there is already a plaintext part without filename,
|
||||
# because presumably these are alternatives.
|
||||
content = tools.ustr(content, encoding)
|
||||
if part.get_content_subtype() == 'html':
|
||||
body = tools.ustr(tools.html2plaintext(content))
|
||||
elif part.get_content_subtype() == 'plain':
|
||||
body = content
|
||||
has_plain_text = True
|
||||
elif part.get_content_maintype() in ('application', 'image'):
|
||||
if filename :
|
||||
attachments[filename] = part.get_payload(decode=True)
|
||||
else:
|
||||
res = part.get_payload(decode=True)
|
||||
body += tools.ustr(res, encoding)
|
||||
|
||||
msg['body'] = body
|
||||
msg['attachments'] = attachments
|
||||
return msg
|
||||
|
||||
def send_email(self, cr, uid, ids, auto_commit=False, context=None):
|
||||
"""
|
||||
send email message
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
smtp_server_obj = self.pool.get('ir.mail_server')
|
||||
attachment_pool = self.pool.get('ir.attachment')
|
||||
self.write(cr, uid, ids, {'state':'outgoing'}, context)
|
||||
for message in self.browse(cr, uid, ids, context):
|
||||
try:
|
||||
attachments = []
|
||||
for attach in message.attachment_ids:
|
||||
attachments.append((attach.datas_fname ,base64.b64decode(attach.datas)))
|
||||
smtp_server = message.smtp_server_id
|
||||
if not smtp_server:
|
||||
smtp_ids = smtp_server_obj.search(cr, uid, [('default','=',True)])
|
||||
smtp_ids = smtp_server_obj.search(cr, uid, [])
|
||||
if smtp_ids:
|
||||
smtp_server = smtp_server_obj.browse(cr, uid, smtp_ids, context)[0]
|
||||
res = tools.email_send(message.email_from,
|
||||
message.email_to and message.email_to.split(',') or [],
|
||||
message.name, message.description,
|
||||
attachments = []
|
||||
for attach in message.attachment_ids:
|
||||
attachments.append((attach.datas_fname, base64.b64decode(attach.datas)))
|
||||
if message.state in ['outgoing', 'exception']:
|
||||
msg = smtp_server_obj.pack_message(cr, uid, message.email_from,
|
||||
message.email_to and message.email_to.split(',') or [], message.subject, message.body,
|
||||
email_cc=message.email_cc and message.email_cc.split(',') or [],
|
||||
email_bcc=message.email_bcc and message.email_bcc.split(',') or [],
|
||||
reply_to=message.reply_to,
|
||||
|
@ -324,22 +421,47 @@ class email_message(osv.osv):
|
|||
openobject_id=message.res_id,
|
||||
subtype=message.sub_type,
|
||||
x_headers=message.headers and eval(message.headers) or {},
|
||||
priority=message.priority, debug=message.debug,
|
||||
smtp_server=smtp_server and smtp_server.smtpserver or None,
|
||||
smtp_port=smtp_server and smtp_server.smtpport or None,
|
||||
ssl=smtp_server and smtp_server.smtpssl or False,
|
||||
smtp_user=smtp_server and smtp_server.smtpuname or None,
|
||||
smtp_password=smtp_server and smtp_server.smtppass or None)
|
||||
if res:
|
||||
self.write(cr, uid, [message.id], {'state':'sent', 'message_id': res}, context)
|
||||
priority=message.priority)
|
||||
res = smtp_server_obj.send_email(cr, uid,
|
||||
msg,
|
||||
mail_server_id = message.smtp_server_id.id or None,
|
||||
smtp_server=smtp_server and smtp_server.smtp_host or None,
|
||||
smtp_port=smtp_server and smtp_server.smtp_port or None,
|
||||
smtp_user=smtp_server and smtp_server.smtp_user or None,
|
||||
smtp_password=smtp_server and smtp_server.smtp_pass or None,
|
||||
ssl=smtp_server and smtp_server.smtp_ssl or False,
|
||||
tls=smtp_server and smtp_server.smtp_tls,
|
||||
debug=message.debug)
|
||||
if res:
|
||||
self.write(cr, uid, [message.id], {'state':'sent', 'message_id': res}, context)
|
||||
else:
|
||||
self.write(cr, uid, [message.id], {'state':'exception'}, context)
|
||||
else:
|
||||
self.write(cr, uid, [message.id], {'state':'exception'}, context)
|
||||
raise osv.except_osv(_('Error !'), _('No messages in outgoing or exception state!'))
|
||||
|
||||
#if auto_delete=True then delete that sent messages as well as attachments
|
||||
message_data = self.read(cr, uid, message.id, ['state', 'auto_delete', 'attachment_ids'])
|
||||
if message_data['state'] == 'sent' and message_data['auto_delete'] == True:
|
||||
self.unlink(cr, uid, [message.id], context=context)
|
||||
if message_data['attachment_ids']:
|
||||
attachment_pool.unlink(cr, uid, message_data['attachment_ids'], context=context)
|
||||
|
||||
if auto_commit == True:
|
||||
cr.commit()
|
||||
|
||||
except Exception, error:
|
||||
logger = netsvc.Logger()
|
||||
logger.notifyChannel("email-template", netsvc.LOG_ERROR, _("Sending of Mail %s failed. Probable Reason:Could not login to server\nError: %s") % (message.id, error))
|
||||
self.write(cr, uid, [message.id], {'state':'exception'}, context)
|
||||
return ids
|
||||
return False
|
||||
return True
|
||||
|
||||
def do_cancel(self, cr, uid, ids, context=None):
|
||||
'''
|
||||
Cancel the email to be send
|
||||
'''
|
||||
self.write(cr, uid, ids, {'state':'cancel'}, context)
|
||||
return True
|
||||
# OLD Code.
|
||||
# def send_all_mail(self, cr, uid, ids=None, context=None):
|
||||
# if ids is None:
|
|
@ -24,22 +24,22 @@ import time
|
|||
import tools
|
||||
import binascii
|
||||
import email
|
||||
from email.header import decode_header
|
||||
|
||||
from email.utils import parsedate
|
||||
import base64
|
||||
import re
|
||||
|
||||
from tools.translate import _
|
||||
import logging
|
||||
import xmlrpclib
|
||||
|
||||
_logger = logging.getLogger('mailgate')
|
||||
_logger = logging.getLogger('mail')
|
||||
|
||||
class mailgate_thread(osv.osv):
|
||||
class email_thread(osv.osv):
|
||||
'''
|
||||
Mailgateway Thread
|
||||
Email Thread
|
||||
'''
|
||||
_name = 'mailgate.thread'
|
||||
_description = 'Mailgateway Thread'
|
||||
_name = 'email.thread'
|
||||
_description = 'Email Thread'
|
||||
|
||||
_columns = {
|
||||
'message_ids': fields.one2many('email.message', 'res_id', 'Messages', readonly=True),
|
||||
|
@ -60,18 +60,95 @@ class mailgate_thread(osv.osv):
|
|||
|
||||
default.update({
|
||||
'message_ids': [],
|
||||
'date_closed': False,
|
||||
'date_open': False
|
||||
})
|
||||
return super(mailgate_thread, self).copy(cr, uid, id, default, context=context)
|
||||
return super(email_thread, self).copy(cr, uid, id, default, context=context)
|
||||
|
||||
def message_new(self, cr, uid, msg, context):
|
||||
raise Exception, _('Method is not implemented')
|
||||
"""
|
||||
Called by process_email() to create a new record
|
||||
corresponding to an incoming message for a new thread.
|
||||
@param msg: Dictionary Object to contain email message data
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
model = context.get('thread_model', False)
|
||||
if not model:
|
||||
model = self._name
|
||||
model_pool = self.pool.get(model)
|
||||
if hasattr(model_pool, 'message_new'):
|
||||
res_id = model_pool.message_new(cr, uid, msg, context)
|
||||
else:
|
||||
fields = model_pool.fields_get(cr, uid, context=context)
|
||||
data = model_pool.default_get(cr, uid, fields, context=context)
|
||||
if 'name' in fields and not data.get('name',False):
|
||||
data['name'] = msg.get('from','')
|
||||
res_id = model_pool.create(cr, uid, data, context=context)
|
||||
|
||||
def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context=None):
|
||||
raise Exception, _('Method is not implemented')
|
||||
attachments = msg.get('attachments', {})
|
||||
for attachment in attachments:
|
||||
data_attach = {
|
||||
'name': attachment,
|
||||
'datas': binascii.b2a_base64(str(attachments.get(attachment))),
|
||||
'datas_fname': attachment,
|
||||
'description': _('Mail attachment'),
|
||||
'res_model': self._name,
|
||||
'res_id': res_id,
|
||||
}
|
||||
self.pool.get('ir.attachment').create(cr, uid, data_attach)
|
||||
|
||||
def message_followers(self, cr, uid, ids, context=None):
|
||||
self.history(cr, uid, [res_id], _('receive'), history=True,
|
||||
subject = msg.get('subject'),
|
||||
email = msg.get('to'),
|
||||
details = msg.get('body'),
|
||||
email_from = msg.get('from'),
|
||||
email_cc = msg.get('cc'),
|
||||
message_id = msg.get('message-id'),
|
||||
references = msg.get('references', False) or msg.get('in-reply-to', False),
|
||||
attach = attachments.items(),
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
return res_id
|
||||
|
||||
def message_update(self, cr, uid, ids, msg, vals={}, default_act=None, context=None):
|
||||
"""
|
||||
Called by process_email() to add a new incoming message for an existing thread
|
||||
@param msg: Dictionary Object to contain email message data
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
model = context.get('thread_model', False)
|
||||
if not model:
|
||||
model = self._name
|
||||
model_pool = self.pool.get(model)
|
||||
if hasattr(model_pool, 'message_update'):
|
||||
model_pool.message_update(cr, uid, ids, msg, vals=vals, default_act=default_act, context=context)
|
||||
attachments = msg.get('attachments', {})
|
||||
for res_id in ids:
|
||||
for attachment in attachments:
|
||||
data_attach = {
|
||||
'name': attachment,
|
||||
'datas': binascii.b2a_base64(str(attachments.get(attachment))),
|
||||
'datas_fname': attachment,
|
||||
'description': _('Mail attachment'),
|
||||
'res_model': self._name,
|
||||
'res_id': res_id,
|
||||
}
|
||||
self.pool.get('ir.attachment').create(cr, uid, data_attach)
|
||||
|
||||
self.history(cr, uid, [res_id], _('receive'), history=True,
|
||||
subject = msg.get('subject'),
|
||||
email = msg.get('to'),
|
||||
details = msg.get('body'),
|
||||
email_from = msg.get('from'),
|
||||
email_cc = msg.get('cc'),
|
||||
message_id = msg.get('message-id'),
|
||||
references = msg.get('references', False) or msg.get('in-reply-to', False),
|
||||
attach = attachments.items(),
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
return True
|
||||
|
||||
def thread_followers(self, cr, uid, ids, context=None):
|
||||
""" Get a list of emails of the people following this thread
|
||||
"""
|
||||
res = {}
|
||||
|
@ -86,9 +163,6 @@ class mailgate_thread(osv.osv):
|
|||
res[thread.id] = l
|
||||
return res
|
||||
|
||||
def msg_send(self, cr, uid, id, *args, **argv):
|
||||
raise Exception, _('Method is not implemented')
|
||||
|
||||
def history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \
|
||||
email_from=False, message_id=False, references=None, attach=None, email_cc=None, \
|
||||
email_bcc=None, email_date=None, context=None):
|
||||
|
@ -112,6 +186,11 @@ class mailgate_thread(osv.osv):
|
|||
if attach is None:
|
||||
attach = []
|
||||
|
||||
model = context.get('thread_model', False)
|
||||
if not model:
|
||||
model = self._name
|
||||
model_pool = self.pool.get(model)
|
||||
|
||||
if email_date:
|
||||
edate = parsedate(email_date)
|
||||
if edate is not None:
|
||||
|
@ -120,7 +199,7 @@ class mailgate_thread(osv.osv):
|
|||
# The mailgate sends the ids of the cases and not the object list
|
||||
|
||||
if all(isinstance(case_id, (int, long)) for case_id in cases):
|
||||
cases = self.browse(cr, uid, cases, context=context)
|
||||
cases = model_pool.browse(cr, uid, cases, context=context)
|
||||
|
||||
att_obj = self.pool.get('ir.attachment')
|
||||
obj = self.pool.get('email.message')
|
||||
|
@ -134,14 +213,14 @@ class mailgate_thread(osv.osv):
|
|||
if not partner_id and case._name == 'res.partner':
|
||||
partner_id = case.id
|
||||
data = {
|
||||
'name': keyword,
|
||||
'subject': keyword,
|
||||
'user_id': uid,
|
||||
'model' : case._name,
|
||||
'partner_id': partner_id,
|
||||
'res_id': case.id,
|
||||
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'message_id': message_id,
|
||||
'description': details or (hasattr(case, 'description') and case.description or False),
|
||||
'body': details or (hasattr(case, 'description') and case.description or False),
|
||||
'attachment_ids': [(6, 0, attachments)]
|
||||
}
|
||||
|
||||
|
@ -151,13 +230,13 @@ class mailgate_thread(osv.osv):
|
|||
param = ", ".join(param)
|
||||
|
||||
data = {
|
||||
'name': subject or _('History'),
|
||||
'subject': subject or _('History'),
|
||||
'history': True,
|
||||
'user_id': uid,
|
||||
'model' : case._name,
|
||||
'res_id': case.id,
|
||||
'date': email_date or time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'description': details,
|
||||
'body': details,
|
||||
'email_to': email,
|
||||
'email_from': email_from or \
|
||||
(hasattr(case, 'user_id') and case.user_id and case.user_id.address_id and \
|
||||
|
@ -167,87 +246,33 @@ class mailgate_thread(osv.osv):
|
|||
'partner_id': partner_id,
|
||||
'references': references,
|
||||
'message_id': message_id,
|
||||
'folder': 'inbox',
|
||||
'attachment_ids': [(6, 0, attachments)]
|
||||
'attachment_ids': [(6, 0, attachments)],
|
||||
'state' : 'received',
|
||||
}
|
||||
obj.create(cr, uid, data, context=context)
|
||||
return True
|
||||
mailgate_thread()
|
||||
|
||||
def format_date_tz(date, tz=None):
|
||||
if not date:
|
||||
return 'n/a'
|
||||
format = tools.DEFAULT_SERVER_DATETIME_FORMAT
|
||||
return tools.server_to_local_timestamp(date, format, format, tz)
|
||||
|
||||
class mailgate_tool(osv.osv_memory):
|
||||
|
||||
_name = 'email.server.tools'
|
||||
_description = "Email Server Tools"
|
||||
|
||||
def _decode_header(self, text):
|
||||
"""Returns unicode() string conversion of the the given encoded smtp header"""
|
||||
if text:
|
||||
text = decode_header(text.replace('\r', ''))
|
||||
return ''.join([tools.ustr(x[0], x[1]) for x in text])
|
||||
|
||||
def to_email(self,text):
|
||||
return re.findall(r'([^ ,<@]+@[^> ,]+)',text)
|
||||
|
||||
def history(self, cr, uid, model, res_ids, msg, attach, context=None):
|
||||
"""This function creates history for mails fetched
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param model: OpenObject Model
|
||||
@param res_ids: Ids of the record of OpenObject model created
|
||||
@param msg: Email details
|
||||
@param attach: Email attachments
|
||||
"""
|
||||
if isinstance(res_ids, (int, long)):
|
||||
res_ids = [res_ids]
|
||||
|
||||
msg_pool = self.pool.get('email.message')
|
||||
for res_id in res_ids:
|
||||
case = self.pool.get(model).browse(cr, uid, res_id, context=context)
|
||||
partner_id = hasattr(case, 'partner_id') and (case.partner_id and case.partner_id.id or False) or False
|
||||
if not partner_id and model == 'res.partner':
|
||||
partner_id = res_id
|
||||
msg_data = {
|
||||
'name': msg.get('subject', 'No subject'),
|
||||
'date': msg.get('date'),
|
||||
'description': msg.get('body', msg.get('from')),
|
||||
'history': True,
|
||||
'partner_id': partner_id,
|
||||
'model': model,
|
||||
'email_cc': msg.get('cc'),
|
||||
'email_from': msg.get('from'),
|
||||
'email_to': msg.get('to'),
|
||||
'message_id': msg.get('message-id'),
|
||||
'references': msg.get('references') or msg.get('in-reply-to'),
|
||||
'res_id': res_id,
|
||||
'user_id': uid,
|
||||
'folder': 'inbox',
|
||||
'attachment_ids': [(6, 0, attach)]
|
||||
}
|
||||
msg_pool.create(cr, uid, msg_data, context=context)
|
||||
return True
|
||||
|
||||
|
||||
def email_forward(self, cr, uid, model, res_ids, msg, email_error=False, context=None):
|
||||
"""Sends an email to all people following the thread
|
||||
@param res_id: Id of the record of OpenObject model created from the email message
|
||||
@param msg: email.message.Message to forward
|
||||
@param msg: email.message.Message object to forward
|
||||
@param email_error: Default Email address in case of any Problem
|
||||
"""
|
||||
model_pool = self.pool.get(model)
|
||||
|
||||
smtp_server_obj = self.pool.get('ir.mail_server')
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
_decode_header = email_message_obj._decode_header
|
||||
for res in model_pool.browse(cr, uid, res_ids, context=context):
|
||||
message_followers = model_pool.message_followers(cr, uid, [res.id])[res.id]
|
||||
message_followers_emails = self.to_email(','.join(filter(None, message_followers)))
|
||||
message_recipients = self.to_email(','.join(filter(None,
|
||||
[self._decode_header(msg['from']),
|
||||
self._decode_header(msg['to']),
|
||||
self._decode_header(msg['cc'])])))
|
||||
if hasattr(model_pool, 'thread_followers'):
|
||||
self.thread_followers = model_pool.thread_followers
|
||||
thread_followers = self.thread_followers(cr, uid, [res.id])[res.id]
|
||||
message_followers_emails = email_message_obj.to_email(','.join(filter(None, thread_followers)))
|
||||
message_recipients = email_message_obj.to_email(','.join(filter(None,
|
||||
[_decode_header(msg['from']),
|
||||
_decode_header(msg['to']),
|
||||
_decode_header(msg['cc'])])))
|
||||
message_forward = [i for i in message_followers_emails if (i and (i not in message_recipients))]
|
||||
|
||||
if message_forward:
|
||||
|
@ -256,13 +281,17 @@ class mailgate_tool(osv.osv_memory):
|
|||
del msg['reply-to']
|
||||
msg['reply-to'] = res.section_id.reply_to
|
||||
|
||||
smtp_from = self.to_email(msg['from'])
|
||||
if not tools.misc._email_send(smtp_from, message_forward, msg, openobject_id=res.id) and email_error:
|
||||
smtp_from = email_message_obj.to_email(msg['from'])
|
||||
msg['from'] = smtp_from
|
||||
msg['to'] = message_forward
|
||||
msg['message-id'] = tools.generate_tracking_message_id(res.id)
|
||||
if not smtp_server_obj.send_email(cr, uid, msg) and email_error:
|
||||
subj = msg['subject']
|
||||
del msg['subject'], msg['to'], msg['cc'], msg['bcc']
|
||||
msg['subject'] = '[OpenERP-Forward-Failed] %s' % subj
|
||||
msg['subject'] = _('[OpenERP-Forward-Failed] %s') % subj
|
||||
msg['to'] = email_error
|
||||
tools.misc._email_send(smtp_from, self.to_email(email_error), msg, openobject_id=res.id)
|
||||
smtp_server_obj.send_email(cr, uid, msg)
|
||||
return True
|
||||
|
||||
def process_email(self, cr, uid, model, message, custom_values=None, attach=True, context=None):
|
||||
"""This function Processes email and create record for given OpenERP model
|
||||
|
@ -287,136 +316,29 @@ class mailgate_tool(osv.osv_memory):
|
|||
custom_values = {}
|
||||
|
||||
model_pool = self.pool.get(model)
|
||||
if self._name != model:
|
||||
context.update({'thread_model':model})
|
||||
|
||||
email_message_pool = self.pool.get('email.message')
|
||||
res_id = False
|
||||
|
||||
# Create New Record into particular model
|
||||
def create_record(msg):
|
||||
att_ids = []
|
||||
if hasattr(model_pool, 'message_new'):
|
||||
res_id = model_pool.message_new(cr, uid, msg, context=context)
|
||||
if custom_values:
|
||||
model_pool.write(cr, uid, [res_id], custom_values, context=context)
|
||||
else:
|
||||
data = {
|
||||
'name': msg.get('subject'),
|
||||
'email_from': msg.get('from'),
|
||||
'email_cc': msg.get('cc'),
|
||||
'user_id': False,
|
||||
'description': msg.get('body'),
|
||||
'state' : 'draft',
|
||||
}
|
||||
data.update(self.get_partner(cr, uid, msg.get('from'), context=context))
|
||||
res_id = model_pool.create(cr, uid, data, context=context)
|
||||
|
||||
if attach:
|
||||
for attachment in msg.get('attachments', []):
|
||||
data_attach = {
|
||||
'name': attachment,
|
||||
'datas': binascii.b2a_base64(str(attachments.get(attachment))),
|
||||
'datas_fname': attachment,
|
||||
'description': 'Mail attachment',
|
||||
'res_model': model,
|
||||
'res_id': res_id,
|
||||
}
|
||||
att_ids.append(self.pool.get('ir.attachment').create(cr, uid, data_attach))
|
||||
|
||||
return res_id, att_ids
|
||||
|
||||
# Parse Message
|
||||
# Warning: message_from_string doesn't always work correctly on unicode,
|
||||
# we must use utf-8 strings here :-(
|
||||
if isinstance(message, unicode):
|
||||
message = message.encode('utf-8')
|
||||
msg_txt = email.message_from_string(message)
|
||||
message_id = msg_txt.get('message-id', False)
|
||||
msg = {}
|
||||
msg = email_message_pool.parse_message(msg_txt)
|
||||
|
||||
if not message_id:
|
||||
# Very unusual situation, be we should be fault-tolerant here
|
||||
message_id = time.time()
|
||||
msg_txt['message-id'] = message_id
|
||||
_logger.info('Message without message-id, generating a random one: %s', message_id)
|
||||
# Create New Record into particular model
|
||||
def create_record(msg):
|
||||
new_res_id = self.message_new(cr, uid, msg, context=context)
|
||||
if custom_values:
|
||||
model_pool.write(cr, uid, [res_id], custom_values, context=context)
|
||||
return new_res_id
|
||||
|
||||
fields = msg_txt.keys()
|
||||
msg['id'] = message_id
|
||||
msg['message-id'] = message_id
|
||||
|
||||
if 'Subject' in fields:
|
||||
msg['subject'] = self._decode_header(msg_txt.get('Subject'))
|
||||
|
||||
if 'Content-Type' in fields:
|
||||
msg['content-type'] = msg_txt.get('Content-Type')
|
||||
|
||||
if 'From' in fields:
|
||||
msg['from'] = self._decode_header(msg_txt.get('From'))
|
||||
|
||||
if 'Delivered-To' in fields:
|
||||
msg['to'] = self._decode_header(msg_txt.get('Delivered-To'))
|
||||
|
||||
if 'CC' in fields:
|
||||
msg['cc'] = self._decode_header(msg_txt.get('CC'))
|
||||
|
||||
if 'Reply-to' in fields:
|
||||
msg['reply'] = self._decode_header(msg_txt.get('Reply-To'))
|
||||
|
||||
if 'Date' in fields:
|
||||
msg['date'] = self._decode_header(msg_txt.get('Date'))
|
||||
|
||||
if 'Content-Transfer-Encoding' in fields:
|
||||
msg['encoding'] = msg_txt.get('Content-Transfer-Encoding')
|
||||
|
||||
if 'References' in fields:
|
||||
msg['references'] = msg_txt.get('References')
|
||||
|
||||
if 'In-Reply-To' in fields:
|
||||
msg['in-reply-to'] = msg_txt.get('In-Reply-To')
|
||||
|
||||
if 'X-Priority' in fields:
|
||||
msg['priority'] = msg_txt.get('X-Priority', '3 (Normal)').split(' ')[0]
|
||||
|
||||
if not msg_txt.is_multipart() or 'text/plain' in msg.get('Content-Type', ''):
|
||||
encoding = msg_txt.get_content_charset()
|
||||
body = msg_txt.get_payload(decode=True)
|
||||
if 'text/html' in msg_txt.get('Content-Type', ''):
|
||||
body = tools.html2plaintext(body)
|
||||
msg['body'] = tools.ustr(body, encoding)
|
||||
|
||||
attachments = {}
|
||||
has_plain_text = False
|
||||
if msg_txt.is_multipart() or 'multipart/alternative' in msg.get('content-type', ''):
|
||||
body = ""
|
||||
for part in msg_txt.walk():
|
||||
if part.get_content_maintype() == 'multipart':
|
||||
continue
|
||||
|
||||
encoding = part.get_content_charset()
|
||||
filename = part.get_filename()
|
||||
if part.get_content_maintype()=='text':
|
||||
content = part.get_payload(decode=True)
|
||||
if filename:
|
||||
attachments[filename] = content
|
||||
elif not has_plain_text:
|
||||
# main content parts should have 'text' maintype
|
||||
# and no filename. we ignore the html part if
|
||||
# there is already a plaintext part without filename,
|
||||
# because presumably these are alternatives.
|
||||
content = tools.ustr(content, encoding)
|
||||
if part.get_content_subtype() == 'html':
|
||||
body = tools.ustr(tools.html2plaintext(content))
|
||||
elif part.get_content_subtype() == 'plain':
|
||||
body = content
|
||||
has_plain_text = True
|
||||
elif part.get_content_maintype() in ('application', 'image'):
|
||||
if filename :
|
||||
attachments[filename] = part.get_payload(decode=True)
|
||||
else:
|
||||
res = part.get_payload(decode=True)
|
||||
body += tools.ustr(res, encoding)
|
||||
|
||||
msg['body'] = body
|
||||
msg['attachments'] = attachments
|
||||
res_ids = []
|
||||
attachment_ids = []
|
||||
new_res_id = False
|
||||
res_id = False
|
||||
if msg.get('references') or msg.get('in-reply-to'):
|
||||
references = msg.get('references') or msg.get('in-reply-to')
|
||||
if '\r\n' in references:
|
||||
|
@ -425,45 +347,25 @@ class mailgate_tool(osv.osv_memory):
|
|||
references = references.split(' ')
|
||||
for ref in references:
|
||||
ref = ref.strip()
|
||||
res_id = tools.misc.reference_re.search(ref)
|
||||
res_id = tools.reference_re.search(ref)
|
||||
if res_id:
|
||||
res_id = res_id.group(1)
|
||||
else:
|
||||
res_id = tools.misc.res_re.search(msg['subject'])
|
||||
res_id = tools.res_re.search(msg['subject'])
|
||||
if res_id:
|
||||
res_id = res_id.group(1)
|
||||
if res_id:
|
||||
res_id = int(res_id)
|
||||
model_pool = self.pool.get(model)
|
||||
if model_pool.exists(cr, uid, res_id):
|
||||
res_ids.append(res_id)
|
||||
if hasattr(model_pool, 'message_update'):
|
||||
model_pool.message_update(cr, uid, [res_id], {}, msg, context=context)
|
||||
else:
|
||||
raise NotImplementedError('model %s does not support updating records, mailgate API method message_update() is missing'%model)
|
||||
self.message_update(cr, uid, [res_id], {}, msg, context=context)
|
||||
|
||||
|
||||
if not len(res_ids):
|
||||
new_res_id, attachment_ids = create_record(msg)
|
||||
res_ids = [new_res_id]
|
||||
if not res_id:
|
||||
res_id = create_record(msg)
|
||||
|
||||
# Store messages
|
||||
context.update({'model' : model})
|
||||
if hasattr(model_pool, 'history'):
|
||||
model_pool.history(cr, uid, res_ids, _('receive'), history=True,
|
||||
subject = msg.get('subject'),
|
||||
email = msg.get('to'),
|
||||
details = msg.get('body'),
|
||||
email_from = msg.get('from'),
|
||||
email_cc = msg.get('cc'),
|
||||
message_id = msg.get('message-id'),
|
||||
references = msg.get('references', False) or msg.get('in-reply-to', False),
|
||||
attach = attachments.items(),
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
else:
|
||||
self.history(cr, uid, model, res_ids, msg, attachment_ids, context=context)
|
||||
self.email_forward(cr, uid, model, res_ids, msg_txt)
|
||||
return new_res_id
|
||||
#To forward the email to other followers
|
||||
self.email_forward(cr, uid, model, [res_id], msg_txt)
|
||||
return res_id
|
||||
|
||||
def get_partner(self, cr, uid, from_email, context=None):
|
||||
"""This function returns partner Id based on email passed
|
||||
|
@ -473,11 +375,12 @@ class mailgate_tool(osv.osv_memory):
|
|||
@param from_email: email address based on that function will search for the correct
|
||||
"""
|
||||
address_pool = self.pool.get('res.partner.address')
|
||||
email_message_pool = self.pool.get('email.message')
|
||||
res = {
|
||||
'partner_address_id': False,
|
||||
'partner_id': False
|
||||
}
|
||||
from_email = self.to_email(from_email)[0]
|
||||
from_email = email_message_pool.to_email(from_email)[0]
|
||||
address_ids = address_pool.search(cr, uid, [('email', 'like', from_email)])
|
||||
if address_ids:
|
||||
address = address_pool.browse(cr, uid, address_ids[0])
|
||||
|
@ -486,6 +389,6 @@ class mailgate_tool(osv.osv_memory):
|
|||
|
||||
return res
|
||||
|
||||
mailgate_tool()
|
||||
|
||||
email_thread()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -3,8 +3,8 @@
|
|||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_mailgate_thread_form">
|
||||
<field name="name">mailgate.thread.form</field>
|
||||
<field name="model">mailgate.thread</field>
|
||||
<field name="name">email.thread.form</field>
|
||||
<field name="model">email.thread</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Mailgateway Thread">
|
||||
|
@ -14,7 +14,7 @@
|
|||
<field name="display_text"/>
|
||||
</tree>
|
||||
<form string="Mailgate History">
|
||||
<field name="name" widget="char"/>
|
||||
<field name="subject" widget="char"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id"/>
|
||||
<field name="message_id"/>
|
||||
|
@ -41,8 +41,8 @@
|
|||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_mailgate_thread_tree">
|
||||
<field name="name">mailgate.thread.tree</field>
|
||||
<field name="model">mailgate.thread</field>
|
||||
<field name="name">email.thread.tree</field>
|
||||
<field name="model">email.thread</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Mailgateway Thread">
|
||||
|
@ -54,7 +54,7 @@
|
|||
<!-- Emails action-->
|
||||
<record model="ir.actions.act_window" id="action_view_mailgate_thread">
|
||||
<field name="name">Mailgateway Threads</field>
|
||||
<field name="res_model">mailgate.thread</field>
|
||||
<field name="res_model">email.thread</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_mailgate_thread_tree"/>
|
||||
|
@ -87,4 +87,4 @@
|
|||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
|
@ -12,10 +12,11 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Email message">
|
||||
<group colspan="4" col="6">
|
||||
<field name="name" widget="char" size="512"/>
|
||||
<field name="subject" widget="char" size="512"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id" string="User"/>
|
||||
<field name="partner_id" readonly="1" />
|
||||
<field name="priority"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Details">
|
||||
|
@ -31,21 +32,24 @@
|
|||
<separator string="Message Details" colspan="4"/>
|
||||
<field name="model" readonly="1"/>
|
||||
<group col="3" colspan="2">
|
||||
<field name="res_id" readonly="1"/>
|
||||
<field name="res_id" readonly="1" groups="base.group_extended"/>
|
||||
<button name="open_document" string="Open Document" type="object" icon="gtk-jump-to"/>
|
||||
<field name="message_id"/>
|
||||
<button name="%(action_email_compose_message_wizard)d" string="Reply" type="action" icon="terp-mail-replied"
|
||||
context="{'mail':'reply', 'message_id':active_id}"/>
|
||||
<field name="message_id" groups="base.group_extended" colspan="4"/>
|
||||
</group>
|
||||
<field name="references" widget="char" size="4096"/>
|
||||
<field name="references" widget="char" size="4096" groups="base.group_extended"/>
|
||||
</group>
|
||||
<separator string="Description" colspan="4"/>
|
||||
<field name="description" nolabel="1" colspan="4"/>
|
||||
<group col="4" colspan="4" attrs="{'invisible':[('folder','not in',['drafts','outbox'])]}">
|
||||
<separator string="" colspan="4"/>
|
||||
<field name="state"/>
|
||||
<button name="process_queue" string="Send" type="object" icon="gtk-execute" states='draft,waiting,sending'/>
|
||||
<button name="process_retry" string="Re-Try" type="object" icon="gtk-execute" states='exception'/>
|
||||
<field name="body" nolabel="1" colspan="4"/>
|
||||
<separator string="" colspan="4"/>
|
||||
<group col="6" colspan="4">
|
||||
<field name="state" colspan="2"/>
|
||||
<group col="4" colspan="2">
|
||||
<button name="%(action_email_compose_message_wizard)d" string="Reply" type="action" icon="terp-mail-replied"
|
||||
context="{'mail':'reply', 'message_id':active_id}" states='received,outgoing,sent,exception,cancel'/>
|
||||
<button name="send_email" string="Force Send" type="object" icon="gtk-execute" states='outgoing'/>
|
||||
<button name="process_retry" string="Send Again" type="object" icon="gtk-execute" states='exception,cancel'/>
|
||||
<button name="do_cancel" string="Cancel" type="object" icon="terp-gtk-stop" states='outgoing'/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Attachments">
|
||||
|
@ -55,12 +59,12 @@
|
|||
<page string="Advanced">
|
||||
<group col="4" colspan="4">
|
||||
<field name="smtp_server_id"/>
|
||||
<field name="folder"/>
|
||||
<field name="sub_type"/>
|
||||
<field name="headers"/>
|
||||
<field name="priority"/>
|
||||
<field name="debug"/>
|
||||
<field name="debug" groups="base.group_extended"/>
|
||||
<field name="history"/>
|
||||
<field name="auto_delete"/>
|
||||
<separator string="xheaders" colspan="4"/>
|
||||
<field name="headers" colspan="4" nolabel="1" groups="base.group_extended"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
|
@ -73,14 +77,13 @@
|
|||
<field name="model">email.message</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="gray:folder in ('trash')" string="Emails">
|
||||
<tree string="Emails" colors="grey:state in ('sent', 'cancel');blue:state=='outgoing';red:state=='exception';black:state=='received'">
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="subject"/>
|
||||
<field name="email_from"/>
|
||||
<field name="user_id" string="User"/>
|
||||
<field name="message_id" string="Message" invisible="1"/>
|
||||
<field name="partner_id" invisible="1"/>
|
||||
<field name="folder"/>
|
||||
<field name="state"/>
|
||||
<button name="open_document" string="Open Document" type="object" icon="gtk-jump-to"/>
|
||||
<button name="open_attachment" string="Open Attachments" type="object" icon="gtk-jump-to"/>
|
||||
|
@ -94,16 +97,12 @@
|
|||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Email Search">
|
||||
<filter icon="terp-document-new" string="Draft" domain="[('folder','=','drafts')]"/>
|
||||
<filter icon="terp-personal" string="Inbox" domain="[('folder','=','inbox')]"/>
|
||||
<filter icon="terp-check" string="Outbox" domain="[('folder','=','outbox')]"/>
|
||||
<filter icon="terp-partner" string="Sent Items" domain="[('folder','=','sent')]"/>
|
||||
<filter icon="terp-mail_delete" string="Trash" domain="[('folder','=','trash')]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-call-start" string="Waiting" domain="[('state','=','waiting')]"/>
|
||||
<filter icon="terp-camera_test" string="Received" domain="[('state','=','received')]"/>
|
||||
<filter icon="terp-call-start" name="outgoing" string="Outgoing" domain="[('state','=','outgoing')]"/>
|
||||
<filter icon="terp-gtk-stop" string="Exception" domain="[('state','=','exception')]"/>
|
||||
<field name="email_from"/>
|
||||
<field name="name"/>
|
||||
<field name="subject"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id" string="User"/>
|
||||
<field name="partner_id" string="Partner Name"/>
|
||||
|
@ -127,6 +126,7 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('history', '=', True)]</field>
|
||||
<field name="context">{'search_default_outgoing':1}</field>
|
||||
<field name="search_view_id" ref="view_email_message_search"/>
|
||||
</record>
|
||||
|
||||
|
@ -136,12 +136,6 @@
|
|||
src_model="res.partner"
|
||||
view_id="view_email_message_tree"/>
|
||||
|
||||
<act_window
|
||||
id="act_res_partner_open_email" name="Attachments"
|
||||
res_model="ir.attachment"
|
||||
src_model="email.message"
|
||||
domain="[('res_id', '=', res_id),('res_model','=',model)]"/>
|
||||
|
||||
<menuitem name="Email" id="menu_email_message_tools"
|
||||
parent="base.menu_tools" />
|
||||
|
||||
|
@ -150,82 +144,8 @@
|
|||
parent="menu_email_message_tools"
|
||||
action="action_view_mail_message" />
|
||||
|
||||
<record model="ir.ui.view" id="email_smtp_server_form">
|
||||
<field name="name">email.smtp_server.form</field>
|
||||
<field name="model">email.smtp_server</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Smtp Server Configuration">
|
||||
<group colspan="4">
|
||||
<field name="name"/>
|
||||
<field name="default"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Configuration">
|
||||
<separator string="Server Information" colspan="4"/>
|
||||
<group colspan="4" col="8">
|
||||
<field name="smtpserver"/>
|
||||
<field name="smtpport"/>
|
||||
<field name="smtpssl"/>
|
||||
<field name="smtptls"/>
|
||||
</group>
|
||||
|
||||
<separator string="User Information" colspan="4"/>
|
||||
<group col="6" colspan="4">
|
||||
<field name="email_id"/>
|
||||
<field name="smtpuname"/>
|
||||
<field name="smtppass" password="True"/>
|
||||
|
||||
</group>
|
||||
<separator string="" colspan="4"/>
|
||||
<label string="" colspan="2"/>
|
||||
<button name="test_smtp_connection" type="object" string="Test Connection" icon="gtk-network" colspan="2"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="email_smtp_server_tree">
|
||||
<field name="name">email.smtp_server.tree</field>
|
||||
<field name="model">email.smtp_server</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="SMTP Server">
|
||||
<field name="name"/>
|
||||
<field name="email_id"/>
|
||||
<field name="smtpserver"/>
|
||||
<field name="default"/>
|
||||
<button name="test_smtp_connection" type="object" string="Test Connection" icon="gtk-network"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_email_smtp_server_search" model="ir.ui.view">
|
||||
<field name="name">email_smtp.server.search</field>
|
||||
<field name="model">email.smtp_server</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Smtp Server">
|
||||
<field name="name"/>
|
||||
<field name="email_id"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_email_smtp_server_tree_all">
|
||||
<field name="name">Outgoing Servers</field>
|
||||
<field name="res_model">email.smtp_server</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form,tree</field>
|
||||
<field name="view_id" ref="email_smtp_server_tree" />
|
||||
<field name="context">{'group_by': [], 'search_default_draft': 1, 'search_default_my': 1}</field>
|
||||
<field name="search_view_id" ref="view_email_smtp_server_search"/>
|
||||
</record>
|
||||
|
||||
<menuitem name="Email" id="menu_config_email" parent="base.menu_lunch_survey_root" sequence="20"/>
|
||||
|
||||
<menuitem name="Outgoing Servers" id="menu_email_smtp_server_all" parent="menu_config_email" action="action_email_smtp_server_tree_all"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -54,7 +54,7 @@ class email_parser(object):
|
|||
try:
|
||||
# pass message as bytes because we don't know its encoding until we parse its headers
|
||||
# and hence can't convert it to utf-8 for transport
|
||||
res_id = self.rpc('email.server.tools', 'process_email', self.model, xmlrpclib.Binary(message), custom_values)
|
||||
res_id = self.rpc('email.thread', 'process_email', self.model, xmlrpclib.Binary(message), custom_values)
|
||||
except Exception:
|
||||
logger = logging.getLogger('mail-gateway')
|
||||
logger.warning('Failed to process incoming email. Source of the failed mail is available at debug level.', exc_info=True)
|
|
@ -1,4 +1,3 @@
|
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_email_smtp_server","email.smtp_server","model_email_smtp_server",,1,0,0,0
|
||||
"access_email_message","email.message","model_email_message",,1,0,0,0
|
||||
"access_mailgate_thread","mailgate.thread","model_mailgate_thread",,1,0,0,0
|
||||
"access_mailgate_thread","email.thread","model_email_thread",,1,0,0,0
|
|
|
@ -25,7 +25,7 @@ import tools
|
|||
|
||||
class email_compose_message(osv.osv_memory):
|
||||
_name = 'email.compose.message'
|
||||
_inherit = 'email.message.template'
|
||||
_inherit = 'email.message.common'
|
||||
_description = 'This is the wizard for Compose E-mail'
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
|
@ -43,8 +43,8 @@ class email_compose_message(osv.osv_memory):
|
|||
if not vals:
|
||||
return result
|
||||
|
||||
if 'name' in fields:
|
||||
result.update({'name' : vals.get('name','')})
|
||||
if 'subject' in fields:
|
||||
result.update({'subject' : vals.get('name','')})
|
||||
|
||||
if 'email_to' in fields:
|
||||
result.update({'email_to' : vals.get('email_to','')})
|
||||
|
@ -52,8 +52,8 @@ class email_compose_message(osv.osv_memory):
|
|||
if 'email_from' in fields:
|
||||
result.update({'email_from' : vals.get('email_from','')})
|
||||
|
||||
if 'description' in fields:
|
||||
result.update({'description' : vals.get('description','')})
|
||||
if 'body' in fields:
|
||||
result.update({'body' : vals.get('description','')})
|
||||
|
||||
if 'model' in fields:
|
||||
result.update({'model' : vals.get('model','')})
|
||||
|
@ -135,11 +135,11 @@ 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)
|
||||
subject = tools.ustr(message_data and message_data.name or '')
|
||||
subject = tools.ustr(message_data and message_data.subject or '')
|
||||
if context.get('mail','') == 'reply':
|
||||
subject = "Re :- " + subject
|
||||
|
||||
description = message_data and message_data.description and message_data.description or ''
|
||||
description = message_data and message_data.body or ''
|
||||
message_body = False
|
||||
if context.get('mail','') == 'reply':
|
||||
header = '-------- Original Message --------'
|
||||
|
@ -150,8 +150,8 @@ class email_compose_message(osv.osv_memory):
|
|||
description = '\n'.join([header, sender, email_to, sentdate, desc])
|
||||
|
||||
result.update({
|
||||
'description' : description,
|
||||
'name' : subject,
|
||||
'body' : description,
|
||||
'subject' : 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,
|
||||
|
@ -183,25 +183,20 @@ class email_compose_message(osv.osv_memory):
|
|||
result.update({
|
||||
'email_from': vals.get('email_from',''),
|
||||
'email_to': vals.get('email_to',''),
|
||||
'name': vals.get('name',''),
|
||||
'description': vals.get('description',''),
|
||||
'subject': vals.get('name',''),
|
||||
'body': 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:
|
||||
email_smtp_server_pool = self.pool.get("email.smtp_server")
|
||||
email_from = email_smtp_server_pool.browse(cr, uid, smtp_server_id, context).email_id or False
|
||||
return {'value':{'email_from': email_from}}
|
||||
|
||||
def save_to_drafts(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
email_id = self.save_to_mailbox(cr, uid, ids, context=context)
|
||||
self.pool.get('email.message').write(cr, uid, email_id, {'folder':'drafts', 'state': 'draft'}, context)
|
||||
self.pool.get('email.message').write(cr, uid, email_id, {'state': 'outgoing'}, context)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
def send_mail(self, cr, uid, ids, context=None):
|
||||
|
@ -223,7 +218,7 @@ class email_compose_message(osv.osv_memory):
|
|||
references = mail.references and mail.references + "," + mail.message_id or mail.message_id
|
||||
else:
|
||||
message_id = mail.message_id
|
||||
email_id = email_message_pool.email_send(cr, uid, mail.email_from, mail.email_to, mail.name, mail.description,
|
||||
email_id = email_message_pool.schedule_with_attach(cr, uid, mail.email_from, mail.email_to, mail.subject, mail.body,
|
||||
model=mail.model, email_cc=mail.email_cc, email_bcc=mail.email_bcc, reply_to=mail.reply_to,
|
||||
attach=attachment, message_id=message_id, references=references, openobject_id=int(mail.res_id), debug=mail.debug,
|
||||
subtype=mail.sub_type, x_headers=mail.headers, priority=mail.priority, smtp_server_id=mail.smtp_server_id and mail.smtp_server_id.id, context=context)
|
|
@ -12,19 +12,18 @@
|
|||
<field name="model" invisible="1"/>
|
||||
<field name="res_id" invisible="context.get('active_model','') != 'ir.ui.menu'"
|
||||
colspan="4" on_change="on_change_referred_doc(model, res_id, context)"/>
|
||||
<field name="smtp_server_id" widget="selection" colspan="4"
|
||||
on_change="on_change_smtp_server(smtp_server_id, email_from)"/>
|
||||
<field name="smtp_server_id" widget="selection" colspan="4"/>
|
||||
<field name="email_from" colspan="4" required="1"/>
|
||||
<field name="email_to" colspan="4" required="1"/>
|
||||
<field name="email_cc" colspan="4"/>
|
||||
<field name="email_bcc" colspan="4"/>
|
||||
<field name="reply_to" colspan="4"/>
|
||||
<field name="name" colspan="4" widget="char" size="512"/>
|
||||
<field name="subject" colspan="4" widget="char" size="512"/>
|
||||
</group>
|
||||
<separator string="" colspan="4"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Body">
|
||||
<field name="description" colspan="4" nolabel="1"/>
|
||||
<field name="body" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Attachments">
|
||||
<label string="Add here all attachments of the current document you want to include in the Email." colspan="4"/>
|
|
@ -7,7 +7,7 @@
|
|||
"access_marketing_campaign_analysis_campaignadmin","campaign.analysis","model_campaign_analysis","marketing.group_marketing_user",1,1,0,0
|
||||
"access_marketing_campaign_workitem_all","marketing.campaign.workitem","model_marketing_campaign_workitem","base.group_user",1,0,0,0
|
||||
"access_email_template_user","email.template","model_email_template","marketing.group_marketing_user",1,1,0,0
|
||||
"access_email_template_account_user","email.smtp_server","email.model_email_smtp_server","marketing.group_marketing_user",1,1,0,0
|
||||
"access_email_template_account_user","ir.mail_server","base.model_ir_mail_server","marketing.group_marketing_user",1,1,0,0
|
||||
"access_marketing_campaign_system","marketing.campaign system","model_marketing_campaign","base.group_system",1,0,0,0
|
||||
"access_marketing_campaign_segment_system","marketing.campaign.segment system","model_marketing_campaign_segment","base.group_system",1,0,0,0
|
||||
"access_marketing_campaign_workitem_system","marketing.campaign.workitem system","model_marketing_campaign_workitem","base.group_system",1,0,0,0
|
||||
|
@ -18,4 +18,4 @@
|
|||
"access_marketing_campaign_transition_campaign_manager","marketing.campaign.transition","model_marketing_campaign_transition","marketing.group_marketing_manager",1,1,1,1
|
||||
"access_marketing_campaign_analysis_campaign_manager","campaign.analysis","model_campaign_analysis","marketing.group_marketing_manager",1,1,1,1
|
||||
"access_email_template_manager","email.template","model_email_template","marketing.group_marketing_manager",1,1,1,1
|
||||
"access_email_template_account_manager","email.smtp_server","email.model_email_smtp_server","marketing.group_marketing_manager",1,1,1,1
|
||||
"access_email_template_account_manager","ir.mail_server","base.model_ir_mail_server","marketing.group_marketing_manager",1,1,1,1
|
||||
|
|
|
|
@ -25,7 +25,7 @@
|
|||
'version' : '1.0',
|
||||
'author' : 'OpenERP SA',
|
||||
'website' : 'http://www.openerp.com/',
|
||||
'depends' : ['base', 'email'],
|
||||
'depends' : ['base', 'mail'],
|
||||
'category' : 'Tools',
|
||||
'description': '''
|
||||
This module provides the Outlook Plug-in.
|
||||
|
|
|
@ -208,7 +208,7 @@ class XMLRpcConn(object):
|
|||
if attachments:
|
||||
result = self.MakeAttachment([rec], mail)
|
||||
attachment_ids = result.get(model, {}).get(res_id, [])
|
||||
execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','history',model, res_id, msg, attachment_ids)
|
||||
execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.thread','history',model, res_id, msg, attachment_ids)
|
||||
new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2]))
|
||||
flag = True
|
||||
|
||||
|
@ -298,7 +298,7 @@ class XMLRpcConn(object):
|
|||
endCut = message_id.find(">")
|
||||
message_id = message_id[startCut:endCut+1]
|
||||
email.replace_header('Message-Id',message_id)
|
||||
id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','process_email',section, str(email))
|
||||
id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.thread','process_email',section, str(email))
|
||||
if id > 0:
|
||||
flag = True
|
||||
return flag
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
"website": "http://www.openerp.com",
|
||||
"category": "Project Management",
|
||||
"images": ["images/gantt.png", "images/project_dashboard.jpeg","images/project_task_tree.jpeg","images/project_task.jpeg","images/project.jpeg","images/task_analysis.jpeg"],
|
||||
"depends": ["product", "analytic", "board", "email"],
|
||||
"depends": ["product", "analytic", "board", "mail"],
|
||||
"description": """
|
||||
Project management module tracks multi-level projects, tasks, work done on tasks, eso.
|
||||
======================================================================================
|
||||
|
|
|
@ -113,7 +113,7 @@ class project_task_close(osv.osv_memory):
|
|||
to_adr.append(data.manager_email)
|
||||
if data.partner_warn and data.partner_email:
|
||||
to_adr.append(data.partner_email)
|
||||
mail_id = email_message_obj.email_send(cr, uid, from_adr, to_adr, subject, tools.ustr(body), model='project.task.close', email_bcc=[from_adr])
|
||||
mail_id = email_message_obj.schedule_with_attach(cr, uid, from_adr, to_adr, subject, tools.ustr(body), model='project.task.close', email_bcc=[from_adr])
|
||||
if not mail_id:
|
||||
raise osv.except_osv(_('Error'), _("Couldn't send mail! Check the email ids and smtp configuration settings"))
|
||||
return {}
|
||||
|
|
|
@ -46,7 +46,7 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
_name = "project.issue"
|
||||
_description = "Project Issue"
|
||||
_order = "priority, id desc"
|
||||
_inherit = ['mailgate.thread']
|
||||
_inherit = ['email.thread']
|
||||
|
||||
def case_open(self, cr, uid, ids, *args):
|
||||
"""
|
||||
|
@ -374,7 +374,7 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
mailgate_pool = self.pool.get('email.server.tools')
|
||||
thread_pool = self.pool.get('email.thread')
|
||||
|
||||
subject = msg.get('subject') or _('No Title')
|
||||
body = msg.get('body')
|
||||
|
@ -391,7 +391,7 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
if msg.get('priority', False):
|
||||
vals['priority'] = priority
|
||||
|
||||
res = mailgate_pool.get_partner(cr, uid, msg.get('from'))
|
||||
res = thread_pool.get_partner(cr, uid, msg.get('from'))
|
||||
if res:
|
||||
vals.update(res)
|
||||
context.update({'state_to' : 'draft'})
|
||||
|
@ -455,18 +455,6 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
res = self.write(cr, uid, ids, vals)
|
||||
return res
|
||||
|
||||
def msg_send(self, cr, uid, id, *args, **argv):
|
||||
|
||||
""" Send The Message
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of email’s IDs
|
||||
@param *args: Return Tuple Value
|
||||
@param **args: Return Dictionary of Keyword Value
|
||||
"""
|
||||
return True
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
issue = self.read(cr, uid, id, ['name'], context=context)
|
||||
if not default:
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
<field name="history" invisible="1"/>
|
||||
<button
|
||||
string="Reply" attrs="{'invisible': [('history', '!=', True)]}"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action" />
|
||||
</tree>
|
||||
|
@ -113,15 +113,15 @@
|
|||
<field name="date"/>
|
||||
<field name="email_to" widget="char" size="512"/>
|
||||
<field name="email_cc" widget="char" size="512"/>
|
||||
<field name="name" colspan="4" widget="char" size="512"/>
|
||||
<field name="subject" colspan="4" widget="char" size="512"/>
|
||||
<field name="history" invisible="1"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Details">
|
||||
<group attrs="{'invisible': [('history', '!=', True)]}">
|
||||
<field name="description" colspan="4" nolabel="1" height="250"/>
|
||||
<field name="body" colspan="4" nolabel="1" height="250"/>
|
||||
<button colspan="4" string="Reply"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'mail':'reply', 'message_id':active_id}"
|
||||
icon="terp-mail-replied" type="action"/>
|
||||
</group>
|
||||
|
@ -141,7 +141,7 @@
|
|||
context="{'model': 'crm.lead' }"
|
||||
icon="terp-document-new" type="action" />
|
||||
<button string="Send New Email"
|
||||
name="%(email.action_email_compose_message_wizard)d"
|
||||
name="%(mail.action_email_compose_message_wizard)d"
|
||||
context="{'email_model':'project.issue', 'email_res_id': active_id}"
|
||||
icon="terp-mail-message-new" type="action"/>
|
||||
</page>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"access_crm_case_categ_id","crm.case.categ","crm.model_crm_case_categ","project.group_project_manager",1,1,1,1
|
||||
"access_project_issue_version_project","project_issue_version manager","model_project_issue_version","project.group_project_manager",1,1,1,1
|
||||
"access_project_issue_version_project_user","project_issue_version user","model_project_issue_version","project.group_project_user",1,0,0,0
|
||||
"access_email_message_project_manager","email.message.manager","email.model_email_message","project.group_project_manager",1,1,1,1
|
||||
"access_email_message_project_manager","email.message.manager","mail.model_email_message","project.group_project_manager",1,1,1,1
|
||||
"access_resource_calendar_project_manager","resource.calendar.project.manager","resource.model_resource_calendar","project.group_project_manager",1,1,1,1
|
||||
"access_project_issue_report_user","project.issue.report user","model_project_issue_report","project.group_project_user",1,0,0,0
|
||||
"access_email_message_issue_project_user","project.mailgate.message.issue.user","email.model_email_message","project.group_project_user",1,1,1,0
|
||||
"access_email_message_issue_project_user","email.message.user","mail.model_email_message","project.group_project_user",1,1,1,0
|
||||
|
|
|
|
@ -27,7 +27,7 @@
|
|||
"website": "http://www.openerp.com",
|
||||
"category": "Project Management",
|
||||
"images": ["images/project_mailgate_task.jpeg"],
|
||||
"depends": ["project", "email"],
|
||||
"depends": ["project", "mail"],
|
||||
"description": """
|
||||
This module is an interface that synchronises mails with OpenERP Project Task.
|
||||
==============================================================================
|
||||
|
|
|
@ -25,7 +25,7 @@ import binascii
|
|||
|
||||
class project_tasks(osv.osv):
|
||||
_name = "project.task"
|
||||
_inherit = ['mailgate.thread','project.task']
|
||||
_inherit = ['email.thread','project.task']
|
||||
|
||||
_columns={
|
||||
'message_ids': fields.one2many('email.message', 'res_id', 'Messages', domain=[('model','=',_name)], readonly=True),
|
||||
|
@ -38,7 +38,7 @@ class project_tasks(osv.osv):
|
|||
# @param cr: the current row, from the database cursor,
|
||||
# @param uid: the current user’s ID for security checks
|
||||
# """
|
||||
mailgate_obj = self.pool.get('email.server.tools')
|
||||
thread_obj = self.pool.get('email.thread')
|
||||
subject = msg.get('subject')
|
||||
body = msg.get('body')
|
||||
msg_from = msg.get('from')
|
||||
|
@ -49,7 +49,7 @@ class project_tasks(osv.osv):
|
|||
'description': body,
|
||||
'planned_hours' : 0.0,
|
||||
}
|
||||
res = mailgate_obj.get_partner(cr, uid, msg_from)
|
||||
res = thread_obj.get_partner(cr, uid, msg_from)
|
||||
if res:
|
||||
data.update(res)
|
||||
res = self.create(cr, uid, data)
|
||||
|
@ -69,8 +69,8 @@ class project_tasks(osv.osv):
|
|||
return res
|
||||
|
||||
def message_update(self, cr, uid, id, msg, data={}, default_act='pending'):
|
||||
mailgate_obj = self.pool.get('email.server.tools')
|
||||
msg_actions, body_data = mailgate_obj.msg_act_get(msg)
|
||||
thread_obj = self.pool.get('email.thread')
|
||||
msg_actions, body_data = thread_obj.msg_act_get(msg)
|
||||
data.update({
|
||||
'description': body_data,
|
||||
})
|
||||
|
@ -93,7 +93,7 @@ class project_tasks(osv.osv):
|
|||
getattr(self,act)(cr, uid, [id])
|
||||
return True
|
||||
|
||||
def message_followers(self, cr, uid, ids, context=None):
|
||||
def thread_followers(self, cr, uid, ids, context=None):
|
||||
res = []
|
||||
if isinstance(ids, (str, int, long)):
|
||||
select = [ids]
|
||||
|
@ -106,12 +106,9 @@ class project_tasks(osv.osv):
|
|||
return len(res) and res[0] or False
|
||||
return res
|
||||
|
||||
def msg_send(self, cr, uid, id, *args, **argv):
|
||||
return True
|
||||
|
||||
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=[], context=None):
|
||||
mailgate_pool = self.pool.get('mailgate.thread')
|
||||
return mailgate_pool.history(cr, uid, cases, keyword, history=history,\
|
||||
thread_pool = self.pool.get('email.thread')
|
||||
return thread_pool.history(cr, uid, cases, keyword, history=history,\
|
||||
subject=subject, email=email, \
|
||||
details=details, email_from=email_from,\
|
||||
message_id=message_id, attach=attach, \
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_email_message_project_manager","project.mailgate.message.manager","email.model_email_message","project.group_project_manager",1,1,1,0
|
||||
"access_email_message_project_user","project.mailgate.message.user","email.model_email_message","project.group_project_user",1,1,1,0
|
||||
"access_email_message_project_manager","project.email.message.manager","mail.model_email_message","project.group_project_manager",1,1,1,0
|
||||
"access_email_message_project_user","project.email.message.user","mail.model_email_message","project.group_project_user",1,1,1,0
|
||||
|
|
|
|
@ -109,7 +109,7 @@
|
|||
<button name="do_reopen" states="done,cancelled" string="Reactivate" type="object" icon="gtk-convert"/>
|
||||
<button name="do_pending" states="open" string="Pending" type="object" icon="gtk-media-pause"/>
|
||||
<button groups="base.group_extended" name="%(project.action_project_task_delegate)d" states="pending,open" string="Delegate" type="action" icon="gtk-sort-descending"/>
|
||||
<button name="%(email.action_email_compose_message_wizard)d" context="{'email_model':'project.task', 'email_res_id': active_id}" states="pending,open" string="Done" type="action" icon="gtk-jump-to"/>
|
||||
<button name="%(mail.action_email_compose_message_wizard)d" context="{'email_model':'project.task', 'email_res_id': active_id}" states="pending,open" string="Done" type="action" icon="gtk-jump-to"/>
|
||||
</group>
|
||||
</page>
|
||||
<page groups="base.group_extended" string="Extra Info" attrs="{'readonly':[('state','=','done')]}">
|
||||
|
|
|
@ -49,7 +49,7 @@ More information on the methodology:
|
|||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'images': ['images/product_backlogs.jpeg', 'images/project_sprints.jpeg', 'images/scrum_dashboard.jpeg', 'images/scrum_meetings.jpeg'],
|
||||
'depends': ['project', 'process', 'email'],
|
||||
'depends': ['project', 'process', 'mail'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'security/ir.model.access.csv',
|
||||
|
|
|
@ -326,7 +326,7 @@ class project_scrum_meeting(osv.osv):
|
|||
body += _('\n*Tasks since yesterday:\n_______________________%s\n*Task for Today:\n_______________________ %s\n\n*Blocks encountered:\n_______________________ %s') %(meeting_id.question_yesterday,meeting_id.question_today, meeting_id.question_blocks or _('No Blocks'))
|
||||
body += _("\n\nThank you,\n%s") % user.name
|
||||
sub_name = meeting_id.name or _('Scrum Meeting of %s') % meeting_id.date
|
||||
flag = email_message_obj.email_send(cr, uid, user_email , [email], sub_name, body, model='project.scrum.meeting', reply_to=None, openobject_id=str(meeting_id.id))
|
||||
flag = email_message_obj.schedule_with_attach(cr, uid, user_email , [email], sub_name, body, model='project.scrum.meeting', reply_to=None, openobject_id=str(meeting_id.id))
|
||||
if not flag:
|
||||
return False
|
||||
return True
|
||||
|
|
|
@ -302,7 +302,7 @@
|
|||
</notebook>
|
||||
<group col="8" colspan="4">
|
||||
<field name="state" readonly="1"/>
|
||||
<button name="%(project_scrum.report_scrum_sprint_burndown_chart)d"
|
||||
<button name="%(project_scrum.report_scrum_sprint_burndown_chart)d"
|
||||
string="Burndown Chart" type="action" icon="gtk-print"/>
|
||||
<button type="object" string="Open" name="button_open" states="draft,pending" icon="terp-camera_test"/>
|
||||
<button type="object" string="Pending" name="button_pending" states="open" icon="gtk-media-pause"/>
|
||||
|
@ -396,7 +396,7 @@
|
|||
<field name="date"/>
|
||||
<field name="sprint_id" domain="[('state', '=', 'open')]"/>
|
||||
<field name="user_id"/>
|
||||
<button name="%(email.action_email_compose_message_wizard)d"
|
||||
<button name="%(mail.action_email_compose_message_wizard)d"
|
||||
string="Send Email" type="action" icon="terp-mail-message-new"
|
||||
context="{'email_model': 'project.scrum.meeting', 'email_res_id': active_id}"/>
|
||||
</group>
|
||||
|
|
|
@ -101,8 +101,8 @@ class project_scrum_email(osv.osv_memory):
|
|||
if data.scrum_master_email == data.product_owner_email:
|
||||
data.product_owner_email = False
|
||||
if data.scrum_master_email:
|
||||
email_message_obj.email_send(cr, uid, user_email, [data.scrum_master_email], data.subject, body, model='project.scrum.email', reply_to=user_email)
|
||||
email_message_obj.schedule_with_attach(cr, uid, user_email, [data.scrum_master_email], data.subject, body, model='project.scrum.email', reply_to=user_email)
|
||||
if data.product_owner_email:
|
||||
email_message_obj.email_send(cr, uid, user_email, [data.product_owner_email], data.subject, body, model='project.scrum.email', reply_to=user_email)
|
||||
email_message_obj.schedule_with_attach(cr, uid, user_email, [data.product_owner_email], data.subject, body, model='project.scrum.email', reply_to=user_email)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
project_scrum_email()
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
{
|
||||
"name" : "Sharing Tools",
|
||||
"version" : "1.3",
|
||||
"depends" : ["base", "email"],
|
||||
"depends" : ["base", "mail"],
|
||||
"author" : "OpenERP SA",
|
||||
"category": 'Tools',
|
||||
"description": """
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue