[IMP] Improve email, email_template and email_gateway module.
bzr revid: ysa@tinyerp.com-20110201120349-30hvqiiwbvvbam98
This commit is contained in:
parent
1513a9ae77
commit
06b5ce2287
|
@ -5,104 +5,6 @@
|
|||
<menuitem id="base.menu_mail_gateway" name="Emails"
|
||||
parent="base.menu_base_config" sequence="1" />
|
||||
|
||||
<record model="ir.ui.view" id="view_mailgate_message_form">
|
||||
<field name="name">mailgate.message.form</field>
|
||||
<field name="model">mailgate.message</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="mailgate message">
|
||||
<group colspan="4" col="6">
|
||||
<field name="name" string="Subject" required="1" select="1" widget="char" size="512"/>
|
||||
<field name="date" required="1" select="1"/>
|
||||
<field name="user_id" string="Owner" select="1"/>
|
||||
<field name="partner_id" readonly="1" />
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Details">
|
||||
<group col="2" colspan="2">
|
||||
<separator string="Email Followers" colspan="4"/>
|
||||
<field name="email_from" />
|
||||
<field name="email_to" widget="char" size="512"/>
|
||||
<field name="email_cc" widget="char" size="512"/>
|
||||
<field name="email_bcc" widget="char" size="512" groups="base.group_extended"/>
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<separator string="Message Details" colspan="4"/>
|
||||
<field name="model" readonly="1"/>
|
||||
<group col="3" colspan="2">
|
||||
<field name="res_id" readonly="1"/>
|
||||
<button name="open_document" string="Open Document" type="object" icon="gtk-jump-to"/>
|
||||
</group>
|
||||
<field name="message_id" />
|
||||
<field name="ref_id" />
|
||||
</group>
|
||||
<separator string="Description" colspan="4"/>
|
||||
<field name="description" nolabel="1" colspan="4" />
|
||||
</page>
|
||||
<page string="Attachments">
|
||||
<separator string="Attachments" colspan="4"/>
|
||||
<field name="attachment_ids" nolabel="1" colspan="4" readonly="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_mailgate_message_tree">
|
||||
<field name="name">mailgate.message.tree</field>
|
||||
<field name="model">mailgate.message</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Emails">
|
||||
<field name="date" />
|
||||
<field name="name" string="Subject"/>
|
||||
<field name="email_from" string="From"/>
|
||||
<field name="user_id" string="Owner"/>
|
||||
<field name="message_id" string="Message" invisible="1"/>
|
||||
<field name="partner_id" invisible="1"/>
|
||||
<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"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_mailgate_message_search">
|
||||
<field name="name">mailgate.message.search</field>
|
||||
<field name="model">mailgate.message</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Email Search">
|
||||
<field name="name" string="Subject"/>
|
||||
<field name="date" />
|
||||
<field name="user_id" string="Owner"/>
|
||||
<field name="partner_id" string="Partner Name"/>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." groups="base.group_extended">
|
||||
<filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
|
||||
<filter string="Owner" name="User" icon="terp-personal" context="{'group_by':'user_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Thread" icon="terp-mail-" domain="[]" context="{'group_by':'message_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Month" help="Creation Month" icon="terp-go-month" domain="[]" context="{'group_by':'date'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
|
||||
<record id="action_view_mail_message" model="ir.actions.act_window">
|
||||
<field name="name">Messages</field>
|
||||
<field name="res_model">mailgate.message</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="view_mailgate_message_search"/>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_mailgate_thread_form">
|
||||
<field name="name">mailgate.thread.form</field>
|
||||
<field name="model">mailgate.thread</field>
|
||||
|
@ -177,16 +79,6 @@
|
|||
<field name="act_window_id" ref="action_view_mailgate_thread"/>
|
||||
</record>
|
||||
|
||||
<!-- Emailsaction-->
|
||||
<record model="ir.actions.act_window" id="action_view_mailgate_message">
|
||||
<field name="name">Emails</field>
|
||||
<field name="res_model">mailgate.message</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[('history', '=', True)]</field>
|
||||
<field name="view_id" ref="view_mailgate_message_tree"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window.view" id="action_view_mailgate_thread_view1">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">tree</field>
|
||||
|
@ -200,21 +92,5 @@
|
|||
<field name="act_window_id" ref="action_view_mailgate_thread"/>
|
||||
</record>
|
||||
|
||||
<act_window domain="[('partner_id', '=', active_id), ('history', '=', True)]"
|
||||
id="act_res_partner_emails" name="Emails"
|
||||
res_model="mailgate.message"
|
||||
src_model="res.partner"
|
||||
view_id="view_mailgate_message_tree"
|
||||
/>
|
||||
|
||||
<act_window
|
||||
id="act_res_partner_open_email" name="Attachments"
|
||||
res_model="ir.attachment"
|
||||
src_model="mailgate.message"
|
||||
domain="[('res_id', '=', res_id),('res_model','=',model)]"/>
|
||||
|
||||
<menuitem id="base.menu_email_gateway_form"
|
||||
parent="base.menu_mail_gateway" action="action_view_mail_message" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -179,124 +179,6 @@ def format_date_tz(date, tz=None):
|
|||
format = tools.DEFAULT_SERVER_DATETIME_FORMAT
|
||||
return tools.server_to_local_timestamp(date, format, format, tz)
|
||||
|
||||
class mailgate_message(osv.osv):
|
||||
'''
|
||||
Mailgateway Message
|
||||
'''
|
||||
def open_document(self, cr, uid, ids, context=None):
|
||||
""" To Open Document
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param ids: the ID of messages
|
||||
@param context: A standard dictionary
|
||||
"""
|
||||
action_data = False
|
||||
if ids:
|
||||
message_id = ids[0]
|
||||
mailgate_data = self.browse(cr, uid, message_id, context=context)
|
||||
model = mailgate_data.model
|
||||
res_id = mailgate_data.res_id
|
||||
|
||||
action_pool = self.pool.get('ir.actions.act_window')
|
||||
action_ids = action_pool.search(cr, uid, [('res_model', '=', model)])
|
||||
if action_ids:
|
||||
action_data = action_pool.read(cr, uid, action_ids[0], context=context)
|
||||
action_data.update({
|
||||
'domain' : "[('id','=',%d)]"%(res_id),
|
||||
'nodestroy': True,
|
||||
'context': {}
|
||||
})
|
||||
return action_data
|
||||
|
||||
def open_attachment(self, cr, uid, ids, context=None):
|
||||
""" To Open attachments
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param ids: the ID of messages
|
||||
@param context: A standard dictionary
|
||||
"""
|
||||
action_data = False
|
||||
action_pool = self.pool.get('ir.actions.act_window')
|
||||
message_pool = self.browse(cr ,uid, ids, context=context)[0]
|
||||
att_ids = [x.id for x in message_pool.attachment_ids]
|
||||
action_ids = action_pool.search(cr, uid, [('res_model', '=', 'ir.attachment')])
|
||||
if action_ids:
|
||||
action_data = action_pool.read(cr, uid, action_ids[0], context=context)
|
||||
action_data.update({
|
||||
'domain': [('id','in',att_ids)],
|
||||
'nodestroy': True
|
||||
})
|
||||
return action_data
|
||||
|
||||
def truncate_data(self, cr, uid, data, context=None):
|
||||
data_list = data and data.split('\n') or []
|
||||
if len(data_list) > 3:
|
||||
res = '\n\t'.join(data_list[:3]) + '...'
|
||||
else:
|
||||
res = '\n\t'.join(data_list)
|
||||
return res
|
||||
|
||||
def _get_display_text(self, cr, uid, ids, name, arg, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
tz = context.get('tz')
|
||||
result = {}
|
||||
for message in self.browse(cr, uid, ids, context=context):
|
||||
msg_txt = ''
|
||||
if message.history:
|
||||
msg_txt += (message.email_from or '/') + _(' wrote on ') + format_date_tz(message.date, tz) + ':\n\t'
|
||||
if message.description:
|
||||
msg_txt += self.truncate_data(cr, uid, message.description, context=context)
|
||||
else:
|
||||
msg_txt = (message.user_id.name or '/') + _(' on ') + format_date_tz(message.date, tz) + ':\n\t'
|
||||
if message.name == _('Opportunity'):
|
||||
msg_txt += _("Converted to Opportunity")
|
||||
elif message.name == _('Note'):
|
||||
msg_txt = (message.user_id.name or '/') + _(' added note on ') + format_date_tz(message.date, tz) + ':\n\t'
|
||||
msg_txt += self.truncate_data(cr, uid, message.description, context=context)
|
||||
elif message.name == _('Stage'):
|
||||
msg_txt += _("Changed Stage to: ") + message.description
|
||||
else:
|
||||
msg_txt += _("Changed Status to: ") + message.name
|
||||
result[message.id] = msg_txt
|
||||
return result
|
||||
|
||||
_name = 'mailgate.message'
|
||||
_description = 'Mailgateway Message'
|
||||
_order = 'date desc'
|
||||
_columns = {
|
||||
'name':fields.text('Subject', readonly=True),
|
||||
'model': fields.char('Object Name', size=128, select=1, readonly=True),
|
||||
'res_id': fields.integer('Resource ID', select=1, readonly=True),
|
||||
'ref_id': fields.char('Reference Id', size=256, readonly=True, help="Message Id in Email Server.", select=True),
|
||||
'date': fields.datetime('Date', readonly=True),
|
||||
'history': fields.boolean('Is History?', readonly=True),
|
||||
'user_id': fields.many2one('res.users', 'User Responsible', readonly=True),
|
||||
'message': fields.text('Description', readonly=True),
|
||||
'email_from': fields.char('From', size=128, help="Email From", readonly=True),
|
||||
'email_to': fields.char('To', help="Email Recipients", size=256, readonly=True),
|
||||
'email_cc': fields.char('Cc', help="Carbon Copy Email Recipients", size=256, readonly=True),
|
||||
'email_bcc': fields.char('Bcc', help='Blind Carbon Copy Email Recipients', size=256, readonly=True),
|
||||
'message_id': fields.char('Message Id', size=1024, readonly=True, help="Message Id on Email.", select=True),
|
||||
'references': fields.text('References', readonly=True, help="References emails."),
|
||||
'description': fields.text('Description', readonly=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', required=False),
|
||||
'attachment_ids': fields.many2many('ir.attachment', 'message_attachment_rel', 'message_id', 'attachment_id', 'Attachments', readonly=True),
|
||||
'display_text': fields.function(_get_display_text, method=True, type='text', size="512", string='Display Text'),
|
||||
}
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute("""SELECT indexname
|
||||
FROM pg_indexes
|
||||
WHERE indexname = 'mailgate_message_res_id_model_idx'""")
|
||||
if not cr.fetchone():
|
||||
cr.execute("""CREATE INDEX mailgate_message_res_id_model_idx
|
||||
ON mailgate_message (model, res_id)""")
|
||||
|
||||
mailgate_message()
|
||||
|
||||
class mailgate_tool(osv.osv_memory):
|
||||
|
||||
_name = 'email.server.tools'
|
||||
|
|
|
@ -1,5 +1,2 @@
|
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"mail_gateway_mailgate_message","mail_gateway.mailgate.message","model_mailgate_message","base.group_system",1,1,1,1
|
||||
"mail_gateway_mailgate_thread","mail_gateway.mailgate.thread","model_mailgate_thread","base.group_system",1,1,1,1
|
||||
"mail_gateway_message_internal_user","mail_gateway.mailgate.message.internal","model_mailgate_message","base.group_user",1,0,0,0
|
||||
"mail_gateway_mailgate_message_partner_manager","mail_gateway.mailgate.message.partner.manager","model_mailgate_message","base.group_partner_manager",1,1,1,1
|
||||
|
|
|
|
@ -152,10 +152,10 @@ class email_message(osv.osv):
|
|||
def init(self, cr):
|
||||
cr.execute("""SELECT indexname
|
||||
FROM pg_indexes
|
||||
WHERE indexname = 'mailgate_message_res_id_model_idx'""")
|
||||
WHERE indexname = 'email_message_res_id_model_idx'""")
|
||||
if not cr.fetchone():
|
||||
cr.execute("""CREATE INDEX mailgate_message_res_id_model_idx
|
||||
ON mailgate_message (model, res_id)""")
|
||||
cr.execute("""CREATE INDEX email_message_res_id_model_idx
|
||||
ON email_message (model, res_id)""")
|
||||
|
||||
# def run_mail_scheduler(self, cursor, user, context=None):
|
||||
# """
|
||||
|
|
|
@ -97,14 +97,14 @@
|
|||
|
||||
<act_window domain="[('partner_id', '=', active_id), ('history', '=', True)]"
|
||||
id="act_res_partner_emails" name="Emails"
|
||||
res_model="mailgate.message"
|
||||
res_model="email.message"
|
||||
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="mailgate.message"
|
||||
src_model="email.message"
|
||||
domain="[('res_id', '=', res_id),('res_model','=',model)]"/>
|
||||
|
||||
<menuitem name="Email Template" id="menu_email_template_tools"
|
||||
|
|
|
@ -30,12 +30,12 @@
|
|||
"description": """
|
||||
Email Template is extraction of Power Email basically just to send the emails.
|
||||
""",
|
||||
"init_xml": ['email_template_scheduler_data.xml'],
|
||||
"init_xml": [],
|
||||
"update_xml": [
|
||||
'security/email_template_security.xml',
|
||||
'wizard/email_template_preview_view.xml',
|
||||
'email_template_view.xml',
|
||||
'wizard/email_template_send_wizard_view.xml',
|
||||
'wizard/email_template_preview_view.xml',
|
||||
'security/ir.model.access.csv'
|
||||
],
|
||||
"installable": True,
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<?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 Template 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_template.mailbox'" name="model"/>
|
||||
<field eval="'run_mail_scheduler'" name="function"/>
|
||||
<field eval="'()'" name="args"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,7 +1,4 @@
|
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_email_template","email.template","model_email_template","marketing.group_marketing_user",1,0,0,0
|
||||
"access_email_template_mailbox","email_template.mailbox","model_email_template_mailbox","marketing.group_marketing_user",1,1,1,1
|
||||
"access_email_template_system","email.template system","model_email_template","base.group_system",1,1,1,1
|
||||
"access_email_template_mailbox_system","email_template.mailbox system","model_email_template_mailbox","base.group_system",1,0,0,0
|
||||
"access_email_template_manager","email.template","model_email_template","marketing.group_marketing_manager",1,1,1,1
|
||||
"access_email_template_mailbox_manager","email_template.mailbox","model_email_template_mailbox","marketing.group_marketing_manager",1,1,1,1
|
||||
|
|
|
Loading…
Reference in New Issue