Merge with main branch

bzr revid: mra@tinyerp.com-20100322115529-e74miwjdolyba418
This commit is contained in:
mra (Open ERP)
2010-03-22 17:25:29 +05:30
20 changed files with 522 additions and 383 deletions
+1
View File
@@ -61,6 +61,7 @@ between mails and Open ERP.""",
],
'update_xml': [
'wizard/crm_send_email_view.xml',
'crm_wizard.xml',
'crm_view.xml',
'crm_action_rule_view.xml',
+3
View File
@@ -363,6 +363,8 @@ class crm_case(osv.osv):
data['email'] = email or \
(case.user_id and case.user_id.address_id and \
case.user_id.address_id.email) or False
data['email_from'] = (case.user_id and case.user_id.address_id and \
case.user_id.address_id.email) or tools.config.get('email_from',False)
res = obj.create(cr, uid, data, context)
return True
_history = __history
@@ -549,6 +551,7 @@ class crm_case_history(osv.osv):
'description': fields.text('Description'),
'note': fields.function(_note_get, method=True, string="Description", type="text"),
'email': fields.char('Email', size=84),
'email_from' : fields.char('From Email', size=84),
'log_id': fields.many2one('crm.case.log','Log',ondelete='cascade'),
}
crm_case_history()
+23 -16
View File
@@ -150,22 +150,29 @@
<field name="date"/>
<field name="email"/>
<field name="canal_id"/>
<button
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4" string="Reply to Last Email" name="%(crm.wizard_crm_send_mail)d" context="{'mail':'reply'}" icon="gtk-undo" type="action"/>
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email" name="%(crm.wizard_crm_new_send_mail)d" context="{'mail':'new'}" icon="gtk-go-forward" type="action"/>
<button
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4"
string="Reply to Last Email"
name="%(action_crm_reply_mail)d"
context="{'mail':'reply', 'model': 'crm.claim'}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.claim'}"
icon="gtk-go-forward" type="action" />
</page>
</notebook>
</group>
+22 -15
View File
@@ -149,21 +149,28 @@
<field name="email"/>
<field name="canal_id"/>
<button
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4" string="Reply to Last Email" name="%(crm.wizard_crm_send_mail)d" context="{'mail':'reply'}" icon="gtk-undo" type="action"/>
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email" name="%(crm.wizard_crm_new_send_mail)d" context="{'mail':'new'}" icon="gtk-go-forward" type="action"/>
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4"
string="Reply to Last Email"
name="%(action_crm_reply_mail)d"
context="{'mail':'reply', 'model': 'crm.fundraising'}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.fundraising'}"
icon="gtk-go-forward" type="action" />
</page>
</notebook>
</form>
+22 -15
View File
@@ -97,21 +97,28 @@
<field name="email"/>
<field name="canal_id"/>
<button
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4" string="Reply to Last Email" name="%(crm.wizard_crm_send_mail)d" context="{'mail':'reply'}" icon="gtk-undo" type="action"/>
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email" name="%(crm.wizard_crm_new_send_mail)d" context="{'mail':'new'}" icon="gtk-go-forward" type="action"/>
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4"
string="Reply to Last Email"
name="%(action_crm_reply_mail)d"
context="{'mail':'reply', 'model': 'crm.helpdesk'}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.helpdesk'}"
icon="gtk-go-forward" type="action" />
</page>
</notebook>
</form>
+22 -18
View File
@@ -119,24 +119,28 @@
<field name="email"/>
<field name="canal_id"/>
<button
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4" string="Reply to Last Email" name="%(crm.wizard_crm_send_mail)d" context="{'mail':'reply'}" icon="gtk-go-forward" type="action"/>
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(crm.wizard_crm_new_send_mail)d"
context="{'mail':'new'}" icon="gtk-go-forward"
type="action" />
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4"
string="Reply to Last Email"
name="%(action_crm_reply_mail)d"
context="{'mail':'reply', 'model': 'crm.lead'}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.lead'}"
icon="gtk-go-forward" type="action" />
</page>
<page string="Extra Info" groups="base.group_extended">
<group colspan="2" col="2">
+22 -15
View File
@@ -139,21 +139,28 @@
<field name="email"/>
<field name="canal_id"/>
<button
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4" string="Reply to Last Email" name="%(crm.wizard_crm_send_mail)d" context="{'mail':'reply'}" icon="gtk-undo" type="action"/>
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email" name="%(crm.wizard_crm_new_send_mail)d" context="{'mail':'new'}" icon="gtk-go-forward" type="action"/>
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4"
string="Reply to Last Email"
name="%(action_crm_reply_mail)d"
context="{'mail':'reply', 'model': 'crm.opportunity'}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.opportunity'}"
icon="gtk-go-forward" type="action" />
</page>
</notebook>
</form>
+10 -7
View File
@@ -2,11 +2,7 @@
<openerp>
<data>
<!-- <menuitem icon="terp-crm" id="menu_crm" name="CRM &amp; SRM"/>-->
<menuitem id="menu_crm_configuration" name="Cases" parent="base.menu_base_config" sequence="0"/>
<wizard id="wizard_crm_send_mail" model="crm.case.history" name="crm.send.mail" string="Send Mail" menu="False"/>
<wizard id="wizard_crm_new_send_mail" model="crm.case" name="crm.new.send.mail" string="Send New Mail" menu="False"/>
<menuitem id="menu_crm_configuration" name="Cases" parent="base.menu_base_config" sequence="0"/>
<!-- Case Sections -->
<record id="crm_case_section_view_form" model="ir.ui.view">
<field name="name">crm.case.section.form</field>
@@ -351,7 +347,11 @@
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4" string="Reply to Last Email" name="%(wizard_crm_send_mail)d" context="{'mail':'reply'}" icon="gtk-undo" type="action"/>
<button colspan="4"
string="Reply to Last Email"
name="%(action_crm_reply_mail)d"
context="{'mail':'reply', 'model': 'crm.case'}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="description"/>
@@ -359,7 +359,10 @@
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email" name="%(wizard_crm_new_send_mail)d" context="{'mail':'new'}" icon="gtk-go-forward" type="action"/>
<button colspan="4" string="Send New Email"
name="%(action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.case'}"
icon="gtk-go-forward" type="action" />
</page>
</notebook>
</form>
@@ -206,7 +206,7 @@ class email_parser(object):
# 'file_name':'file data',
# }
# }
# #
def msg_body_get(self, msg):
message = {};
message['body'] = '';
@@ -215,7 +215,7 @@ class email_parser(object):
counter = 1;
def replace(match):
return ''
for part in msg.walk():
if part.get_content_maintype() == 'multipart':
continue
@@ -264,7 +264,7 @@ class email_parser(object):
body['body'] = body_data
data = {
'description': body['body'],
# 'description': body['body'],
}
act = 'case_pending'
if 'state' in actions:
@@ -291,7 +291,7 @@ class email_parser(object):
self.rpc(self.model, act, [id])
self.rpc(self.model, 'write', [id], data)
self.rpc(self.model, 'history', [id], 'Send', True, msg['From'], message['body'])
self.rpc(self.model, 'history', [id], 'Send', True, msg['From'], body['body'])
return id
def msg_send(self, msg, emails, priority=None):
@@ -318,11 +318,11 @@ class email_parser(object):
body = message['body']
act = 'case_open'
self.rpc(self.model, act, [id])
body2 = '\n'.join(map(lambda l: '> '+l, (body or '').split('\n')))
data = {
'description':body,
}
self.rpc(self.model, 'write', [id], data)
#body2 = '\n'.join(map(lambda l: '> '+l, (body or '').split('\n')))
#data = {
# 'description':body,
#}
#self.rpc(self.model, 'write', [id], data)
self.rpc(self.model, 'history', [id], 'Send', True, msg['From'], message['body'])
return id
@@ -375,7 +375,7 @@ class email_parser(object):
if __name__ == '__main__':
import sys, optparse
parser = optparse.OptionParser( usage='usage: %prog [options]', version='%prog v1.0')
parser = optparse.OptionParser(usage='usage: %prog [options]', version='%prog v1.0')
group = optparse.OptionGroup(parser, "Note",
"This program parse a mail from standard input and communicate "
"with the Open ERP server for case management in the CRM module.")
+1 -2
View File
@@ -23,8 +23,7 @@ import crm_opportunity_wizard
import crm_lead_wizard
import crm_phonecall_wizard
import wizard_crm_send_email
import wizard_crm_new_send_email
import crm_send_email
import wizard_history_event
+226
View File
@@ -0,0 +1,226 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
from tools.translate import _
import base64
import tools
class crm_send_new_email(osv.osv_memory):
""" Sends new email for the case"""
_name = "crm.send.mail"
_description = "Case Send new email"
_columns = {
'to' : fields.char('To', size=64, required=True),
'cc' : fields.char('CC', size=128),
'subject': fields.char('Subject', size=128, required=True),
'text': fields.text('Message', required=True),
'state': fields.selection([('done', 'Done'), ('pending', 'Pending'), ('unchanged', 'Unchanged')], string='State', required=True),
'doc1': fields.binary("Attachment1"),
'doc2': fields.binary("Attachment2"),
'doc3': fields.binary("Attachment3"),
}
def action_cancel(self, cr, uid, ids, context=None):
"""
Closes Phonecall to Opportunity form
@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 Phonecall to Opportunity's IDs
@param context: A standard dictionary for contextual values
"""
return {'type':'ir.actions.act_window_close'}
def action_send(self, cr, uid, ids, context=None):
""" This sends an email to ALL the addresses of the selected partners.
@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 Phonecall to Opportunity's IDs
@param context: A standard dictionary for contextual values
"""
if not context:
context = {}
if not context.get('model'):
raise osv.except_osv(_('Error'), _('Can not send mail!'))
model = context.get('model')
case_pool = self.pool.get(model)
res_id = context and context.get('active_id', False) or False
for data in self.read(cr, uid, ids, context=context):
attach = filter(lambda x: x, [data['doc1'], data['doc2'], data['doc3']])
attach = map(lambda x: x and ('Attachment'+str(attach.index(x)+1), base64.decodestring(x)), attach)
if context.get('mail', 'new') == 'new':
case = case_pool.browse(cr, uid, res_id)
else:
hist_obj = self.pool.get('crm.case.history')
hist = hist_obj.browse(cr, uid, res_id)
model = hist.log_id.model_id.model
model_pool = self.pool.get(model)
case = model_pool.browse(cr, uid, hist.log_id.res_id)
emails = [data['to']] + (data['cc'] or '').split(',')
emails = filter(None, emails)
body = data['text']
if case.user_id.signature:
body += '\n\n%s' % (case.user_id.signature)
case_pool._history(cr, uid, [case], _('Send'), history=True, email=data['to'], details=body)
email_from = (case.user_id and case.user_id.address_id and \
case.user_id.address_id.email) or tools.config.get('email_from',False)
flag = tools.email_send(
email_from,
emails,
data['subject'],
case_pool.format_body(body),
attach=attach,
reply_to=case.section_id.reply_to,
openobject_id=str(case.id),
)
if flag:
if data['state'] == 'unchanged':
pass
elif data['state'] == 'done':
case_pool.case_close(cr, uid, [case.id])
elif data['state'] == 'pending':
case_pool.case_pending(cr, uid, [case.id])
cr.commit()
# Commented because form does not close due to raise
# raise osv.except_osv(_('Email!'), ("Email Successfully Sent"))
# else:
# raise osv.except_osv(_('Warning!'), _("Email not sent !"))
return {}
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
@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 fields: List of fields for default value
@param context: A standard dictionary for contextual values
@return : default values of fields.
"""
if not context:
context = {}
if not context.get('model'):
raise osv.except_osv(_('Error'), _('Can not send mail!'))
res = super(crm_send_new_email, self).default_get(cr, uid, fields, context=context)
if context.get('mail') == 'reply':
res.update(self.get_reply_defaults(cr, uid, fields, context=context))
return res
model = context.get('model')
mod_obj = self.pool.get(model)
res_id = context and context.get('active_ids', []) or []
for case in mod_obj.browse(cr, uid, res_id):
if 'to' in fields:
res.update({'to': case.email_from})
if 'subject' in fields:
res.update({'subject': '[%s] %s' %(str(case.id), case.name or '')})
if 'cc' in fields:
res.update({'cc': case.email_cc or ''})
if 'text' in fields:
res.update({'text': case.description or ''})
if 'state' in fields:
res.update({'state': 'pending'})
return res
def get_reply_defaults(self, cr, uid, fields, context=None):
"""
This function gets default values for reply mail
@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 fields: List of fields for default value
@param context: A standard dictionary for contextual values
@return : default values of fields.
"""
hist_obj = self.pool.get('crm.case.history')
res_ids = context and context.get('active_ids', []) or []
res = {}
for hist in hist_obj.browse(cr, uid, res_ids):
model = hist.log_id.model_id.model
model_pool = self.pool.get(model)
case = model_pool.browse(cr, uid, hist.log_id.res_id)
if 'to' in fields and hist.email:
res.update({'to': hist.email})
if 'text' in fields:
header = '-------- Original Message --------'
sender = 'From: %s' %(hist.email_from or tools.config.get('email_from',False))
to = 'To: %s' % (hist.email)
sentdate = 'Sent: %s' % (hist.date)
desc = '\n%s'%(hist.description)
original = [header, sender, to, sentdate, desc]
original = '\n'.join(original)
res.update({'text': '\n\n%s'%(original)})
if 'subject' in fields:
res.update({'subject': '[%s] %s' %(str(case.id), case.name or '')})
#if 'state' in fields:
# res.update({'state': 'pending'})
return res
def view_init(self, cr, uid, fields_list, context=None):
"""
This function checks for precondition before wizard executes
@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 fields: List of fields for default value
@param context: A standard dictionary for contextual values
"""
if not context:
context = {}
if not context.get('model'):
raise osv.except_osv(_('Error'), _('Can not send mail!'))
model = context.get('model')
mod_obj = self.pool.get(model)
if context.get('mail') == 'reply':
return True
if tools.config.get('email_from'):
return True
for case in mod_obj.browse(cr, uid, context.get('active_ids', [])):
if not case.user_id:
raise osv.except_osv(_('Error'), _('You must define a responsible user for this case in order to use this action!'))
if not case.user_id.address_id.email:
raise osv.except_osv(_('Warning!'), _("Please specify user's email address !"))
return True
crm_send_new_email()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+83
View File
@@ -0,0 +1,83 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Send New Mail view -->
<record model="ir.ui.view" id="crm_send_new_mail_view">
<field name="name">crm.new.send.mail.form</field>
<field name="model">crm.send.mail</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Send New Mail" col="2">
<field name="to" />
<field name="cc" />
<field name="subject" />
<field name="doc1" />
<field name="doc2" />
<field name="doc3" />
<separator string="" colspan="4"/>
<field name="text" nolabel="1" colspan="4"/>
<separator colspan="4" string="Set case state to" />
<field name="state" />
<separator string=" " colspan="4"/>
<group colspan="4" col="3" >
<label string=" " />
<button name="action_cancel" string="_Cancel" icon="gtk-cancel" special="cancel" />
<button name="action_send" type="object" string="_Send" icon="gtk-go-forward" />
</group>
</form>
</field>
</record>
<!-- Send New Mail action -->
<record model="ir.actions.act_window" id="action_crm_send_mail">
<field name="name">Send New Mail</field>
<field name="res_model">crm.send.mail</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_send_new_mail_view"/>
<field name="target">new</field>
</record>
<!-- Reply to Mail view -->
<record model="ir.ui.view" id="crm_reply_mail_view">
<field name="name">crm.mail.reply.form</field>
<field name="model">crm.send.mail</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Reply to last Mail" col="2">
<field name="to" />
<field name="cc" />
<field name="subject" />
<field name="doc1" />
<field name="doc2" />
<field name="doc3" />
<separator string="" colspan="4"/>
<field name="text" nolabel="1" colspan="4"/>
<separator string=" " colspan="4"/>
<group colspan="4" col="3" >
<label string=" " />
<button name="action_cancel" string="_Cancel" icon="gtk-cancel" special="cancel" />
<button name="action_send" type="object" string="_Send Reply" icon="gtk-go-forward" />
</group>
</form>
</field>
</record>
<!-- Reply to Mail action -->
<record model="ir.actions.act_window" id="action_crm_reply_mail">
<field name="name">Reply to last Mail</field>
<field name="res_model">crm.send.mail</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_reply_mail_view"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -1,135 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from mx.DateTime import now
import wizard
import netsvc
import ir
import pooler
import tools
import base64
from tools.translate import _
email_send_form = '''<?xml version="1.0"?>
<form string="Mass Mailing">
<field name="to"/>
<newline/>
<field name="cc"/>
<newline/>
<field name="subject"/>
<newline/>
<field name="text" />
<newline/>
<field name="doc1" />
<newline/>
<field name="doc2" />
<newline/>
<field name="doc3" />
<separator colspan="4" string="Set case state to"/>
<newline/>
<field name="state" />
</form>'''
email_send_fields = {
'to': {'string':"To", 'type':'char', 'size':64, 'required':True},
'cc': {'string':"CC", 'type':'char', 'size':128,},
'subject': {'string':'Subject', 'type':'char', 'size':128, 'required':True},
'text': {'string':'Message', 'type':'text_tag', 'required':True},
'state':{'string':'State', 'type':'selection', 'selection':[('done','Done'),('pending','Pending'),('unchanged','Unchanged')]},
'doc1' : {'string':"Attachment1", 'type':'binary'},
'doc2' : {'string':"Attachment2", 'type':'binary'},
'doc3' : {'string':"Attachment3", 'type':'binary'},
'state' : {'string':"Set State to", 'type':'selection', 'required' : True, 'default' :'done',\
'selection': [('unchanged','Unchanged'),('done','Done'),('pending','Pending')]},
}
# this sends an email to ALL the addresses of the selected partners.
def _mass_mail_send(self, cr, uid, data, context):
attach = filter(lambda x: x, [data['form']['doc1'], data['form']['doc2'], data['form']['doc3']])
attach = map(lambda x: x and ('Attachment'+str(attach.index(x)+1), base64.decodestring(x)), attach)
pool = pooler.get_pool(cr.dbname)
case_pool=pool.get(data.get('model'))
case = case_pool.browse(cr,uid,data['ids'])[0]
emails = [data['form']['to']] + (data['form']['cc'] or '').split(',')
emails = filter(None, emails)
body = data['form']['text']
if case.user_id.signature:
body += '\n\n%s' % (case.user_id.signature)
case_pool._history(cr, uid, [case], _('Send'), history=True, email=data['form']['to'], details=body)
flag = tools.email_send(
case.user_id.address_id.email,
emails,
data['form']['subject'],
case_pool.format_body(body),
attach=attach,
reply_to=case.section_id.reply_to,
openobject_id=str(case.id),
subtype="html"
)
if flag:
if data['form']['state'] == 'unchanged':
pass
elif data['form']['state'] == 'done':
case_pool.case_close(cr, uid, data['ids'])
elif data['form']['state'] == 'pending':
case_pool.case_pending(cr, uid, data['ids'])
cr.commit()
raise wizard.except_wizard(_('Email!'),("Email Successfully Sent"))
else:
raise wizard.except_wizard(_('Warning!'),_("Email not sent !"))
return {}
def _get_info(self, cr, uid, data, context):
if not data['id']:
return {}
pool = pooler.get_pool(cr.dbname)
case = pool.get(data.get('model')).browse(cr, uid, data['id'])
if not case.user_id:
raise wizard.except_wizard(_('Error'),_('You must define a responsible user for this case in order to use this action!'))
if not case.user_id.address_id.email:
raise wizard.except_wizard(_('Warning!'),_("Please specify user's email address !"))
return {
'to': case.email_from,
'subject': case.name,
'cc': case.email_cc or ''
}
class wizard_send_mail(wizard.interface):
states = {
'init': {
'actions': [_get_info],
'result': {'type': 'form', 'arch': email_send_form, 'fields': email_send_fields, 'state':[('end','Cancel','gtk-cancel'), ('send','Send Email','gtk-go-forward')]}
},
'send': {
'actions': [_mass_mail_send],
'result': {'type': 'state', 'state':'end'}
}
}
wizard_send_mail('crm.new.send.mail')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-103
View File
@@ -1,103 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from mx.DateTime import now
import wizard
import netsvc
import ir
import pooler
import tools
from tools.translate import _
email_send_form = '''<?xml version="1.0"?>
<form string="Mass Mailing">
<field name="to"/>
<newline/>
<field name="cc"/>
<newline/>
<field name="subject"/>
<newline/>
<field name="text" />
</form>'''
email_send_fields = {
'to': {'string':"To", 'type':'char', 'size':64, 'required':True},
'cc': {'string':"CC", 'type':'char', 'size':128,},
'subject': {'string':'Subject', 'type':'char', 'size':128, 'required':True},
'text': {'string':'Message', 'type':'text_tag', 'required':True}
}
# this sends an email to ALL the addresses of the selected partners.
def _mass_mail_send(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
hist_obj = pool.get('crm.case.history').browse(cr,uid,data['ids'])[0]
model = hist_obj.log_id.model_id.model
model_pool = pool.get(model)
case = model_pool.browse(cr, uid, hist_obj.log_id.res_id)
model_pool._history(cr, uid, [case], _('Send'), history=True, email=False)
emails = [data['form']['to']] + (data['form']['cc'] or '').split(',')
emails = filter(None, emails)
body = data['form']['text']
if case.user_id.signature:
body += '\n\n%s' % (case.user_id.signature)
tools.email_send(
case.user_id.address_id.email,
emails,
data['form']['subject'],
model_pool.format_body(body),
reply_to=case.section_id.reply_to,
openobject_id=str(case.id),
subtype="html"
)
return {}
def _get_info(self, cr, uid, data, context):
if not data['id']:
raise wizard.except_wizard(_('Error'),_('There is no mail to reply!'))
pool = pooler.get_pool(cr.dbname)
hist_obj = pool.get('crm.case.history').browse(cr,uid,data['ids'])[0]
model = hist_obj.log_id.model_id.model
model_pool = pool.get(model)
case = model_pool.browse(cr, uid, hist_obj.log_id.res_id)
if not case.email_from:
raise wizard.except_wizard(_('Error'),_('You must put a Partner eMail to use this action!'))
if not case.user_id:
raise wizard.except_wizard(_('Error'),_('You must define a responsible user for this case in order to use this action!'))
return {'to': case.email_from,'subject': '['+str(case.id)+'] '+case.name,'cc': case.email_cc or '', 'text': '> ' + hist_obj.description.replace('\n','\n> ')}
class wizard_send_mail(wizard.interface):
states = {
'init': {
'actions': [_get_info],
'result': {'type': 'form', 'arch': email_send_form, 'fields': email_send_fields, 'state':[('end','Cancel','gtk-cancel'), ('send','Send Email','gtk-go-forward')]}
},
'send': {
'actions': [_mass_mail_send],
'result': {'type': 'state', 'state':'end'}
}
}
wizard_send_mail('crm.send.mail')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+2 -2
View File
@@ -69,8 +69,8 @@ class hr_holidays_status(osv.osv):
_columns = {
'name' : fields.char('Name', size=64, required=True, translate=True),
'categ_id': fields.many2one('crm.case.categ', 'Meeting Category', domain="[('object_id.model', '=', 'crm.meeting')]", help='If you link this type of leave with a category in the CRM, it will synchronize each leave asked with a case in this category, to display it in the company shared calendar for example.'),
'color_name' : fields.selection([('red', 'Red'), ('lightgreen', 'Light Green'), ('lightblue','Light Blue'), ('lightyellow', 'Light Yellow'), ('magenta', 'Magenta'),('lightcyan', 'Light Cyan'),('black', 'Black'),('lightpink', 'Light Pink'),('brown', 'Brown'),('violet', 'Violet'),('lightcoral', 'Light Coral'),('lightsalmon', 'Light Salmon'),('lavender', 'Lavender'),('wheat', 'Wheat'),('ivory', 'Ivory')],'Color of the status', required=True, help='This color will be used in the leaves summary located in Reporting\Print Summary of Leaves'),
'limit' : fields.boolean('Allow to override Limit', help='If you thick this checkbox, the system will allow, for this section, the employees to take more leaves than the available ones.'),
'color_name' : fields.selection([('red', 'Red'), ('lightgreen', 'Light Green'), ('lightblue','Light Blue'), ('lightyellow', 'Light Yellow'), ('magenta', 'Magenta'),('lightcyan', 'Light Cyan'),('black', 'Black'),('lightpink', 'Light Pink'),('brown', 'Brown'),('violet', 'Violet'),('lightcoral', 'Light Coral'),('lightsalmon', 'Light Salmon'),('lavender', 'Lavender'),('wheat', 'Wheat'),('ivory', 'Ivory')],'Color in Report', required=True, help='This color will be used in the leaves summary located in Reporting\Leaves by Departement'),
'limit' : fields.boolean('Allow to Override Limit', help='If you thick this checkbox, the system will allow, for this section, the employees to take more leaves than the available ones.'),
'active' : fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the leave type without removing it."),
'max_leaves' : fields.function(_user_left_days, method=True, string='Maximum Leaves Allowed', help='This value is given by the sum of all holidays requests with a positive value.', multi='user_left_days'),
'leaves_taken' : fields.function(_user_left_days, method=True, string='Leaves Already Taken', help='This value is given by the sum of all holidays requests with a negative value.', multi='user_left_days'),
+2 -2
View File
@@ -255,10 +255,10 @@
<field name="arch" type="xml">
<form string="Leave Type">
<field colspan="4" name="name" select="1"/>
<field name="color_name" select="2"/>
<field name="categ_id" select="1" widget="selection"/>
<field name="limit" select="2"/>
<field name="active" select="2"/>
<field name="categ_id" select="1" widget="selection"/>
<field name="color_name" select="2"/>
</form>
</field>
</record>
+1 -1
View File
@@ -14,7 +14,7 @@
<wizard string="Holidays by Departement"
name="hr.holidays.summary"
id="holidays_summary"/>
<menuitem name="Holidays by Departement" parent="menu_hr_reporting_holidays"
<menuitem name="Leaves by Departement" parent="menu_hr_reporting_holidays"
icon="STOCK_PRINT"
action="holidays_summary"
type="wizard"
+22 -15
View File
@@ -150,21 +150,28 @@
<field name="date"/>
<field name="email"/>
<button
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4" string="Reply to Last Email" name="%(crm.wizard_crm_send_mail)d" context="{'mail':'reply'}" icon="gtk-undo" type="action"/>
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email" name="%(crm.wizard_crm_new_send_mail)d" context="{'mail':'new'}" icon="gtk-go-forward" type="action"/>
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4"
string="Reply to Last Email"
name="%(crm.action_crm_reply_mail)d"
context="{'mail':'reply', 'model': 'hr.applicant'}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(crm.action_crm_send_mail)d"
context="{'mail':'new', 'model': 'hr.applicant'}"
icon="gtk-go-forward" type="action" />
</page>
</notebook>
</form>
+28 -12
View File
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<!--
((((((((((( Demo Cases )))))))))))
<!--
((((((((((( Demo Cases )))))))))))
-->
<!--For Issue Tracking-->
<record id="crm_case_buginaccountsmodule0" model="project.issue">
@@ -18,6 +18,7 @@
<field name="categ_id" ref="bug_categ"/>
<field name="stage_id" ref="stage1"/>
<field name="project_id" ref="project.project_project_22"/>
<field name="analytic_account_id" ref="account.analytic_agrolait"/>
<field eval="15.0" name="duration"/>
<field eval="&quot;Bug in Accounts module&quot;" name="name"/>
<field eval="&quot;agr@agrolait.com&quot;" name="email_from"/>
@@ -37,6 +38,7 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_asus"/>
<field name="analytic_account_id" ref="account.analytic_asustek"/>
<field eval="&quot;done&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -53,7 +55,8 @@
<field name="type_id" ref="type1"/>
<field eval="&quot;4&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field name="partner_id" ref="base.res_partner_2"/>
<field name="partner_id" ref="account.analytic_project_1"/>
<field name="analytic_account_id" ref="account.analytic_asustek"/>
<field eval="&quot;cancel&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -71,6 +74,7 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_14"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;cancel&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -87,6 +91,7 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_desertic_hispafuentes"/>
<field name="analytic_account_id" ref="account.analytic_desertic_hispafuentes"/>
<field eval="&quot;draft&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -104,6 +109,7 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_5"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;pending&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -121,6 +127,7 @@
<field eval="&quot;2&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_6"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;pending&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -138,6 +145,7 @@
<field eval="&quot;2&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_6"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;pending&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -147,7 +155,7 @@
<field name="project_id" ref="project.project_project_9"/>
<field eval="&quot;Constraint Error&quot;" name="name"/>
</record>
<record id="crm_case_errorinprogram0" model="project.issue">
<field name="partner_address_id" ref="base.res_partner_address_10"/>
<field eval="time.strftime('%Y-%m-28 15:40:00')" name="date"/>
@@ -155,6 +163,7 @@
<field eval="&quot;2&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field name="partner_id" ref="base.res_partner_5"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="1" name="active"/>
<field eval="1.3" name="duration"/>
@@ -163,7 +172,7 @@
<field name="project_id" ref="project.project_project_22"/>
<field eval="&quot;Error in Program&quot;" name="name"/>
</record>
<record id="crm_case_patcheserrorinprogram0" model="project.issue">
<field name="partner_address_id" ref="base.res_partner_address_9"/>
<field eval="time.strftime('%Y-%m-28 16:30:00')" name="date"/>
@@ -171,6 +180,7 @@
<field eval="&quot;2&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_2"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;open&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -180,7 +190,7 @@
<field name="project_id" ref="project.project_project_9"/>
<field eval="&quot;Patches Error in Program&quot;" name="name"/>
</record>
<record id="crm_case_newfeaturestobeadded0" model="project.issue">
<field name="partner_address_id" ref="base.res_partner_address_wong"/>
<field eval="time.strftime('%Y-%m-01 12:15:10')" name="date"/>
@@ -188,6 +198,7 @@
<field eval="&quot;4&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_maxtor"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;open&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -197,7 +208,7 @@
<field name="project_id" ref="project.project_project_21"/>
<field eval="&quot;New Features To Be Added&quot;" name="name"/>
</record>
<record id="crm_case_addmenustothemodule0" model="project.issue">
<field name="partner_address_id" ref="base.res_partner_address_1"/>
<field eval="time.strftime('%Y-%m-05 18:00:00')" name="date"/>
@@ -205,6 +216,7 @@
<field eval="&quot;1&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field name="partner_id" ref="base.res_partner_9"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;done&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -215,7 +227,7 @@
<field eval="&quot;Add menus to the module&quot;" name="name"/>
<field eval="&quot;info@opensides.be&quot;" name="email_from"/>
</record>
<record id="crm_case_includeattendancesheetinproject0" model="project.issue">
<field name="partner_address_id" ref="base.res_partner_address_2"/>
<field eval="time.strftime('%Y-%m-10 17:05:30')" name="date"/>
@@ -223,6 +235,7 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_10"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;cancel&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -233,7 +246,7 @@
<field eval="&quot;Include Attendance sheet in Project&quot;" name="name"/>
<field eval="&quot;contact@tecsas.fr&quot;" name="email_from"/>
</record>
<record id="crm_case_createnewobject0" model="project.issue">
<field model="res.partner.canal" name="canal_id" search="[('name','=','phone')]"/>
<field name="partner_address_id" ref="base.res_partner_address_6"/>
@@ -243,6 +256,7 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_6"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;draft&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -252,7 +266,7 @@
<field name="project_id" ref="project.project_project_22"/>
<field eval="&quot;Create new object&quot;" name="name"/>
</record>
<record id="crm_case_improvereportsinhrms0" model="project.issue">
<field name="partner_address_id" ref="base.res_partner_address_15"/>
<field eval="time.strftime('%Y-%m-19 12:15:00')" name="date"/>
@@ -260,6 +274,7 @@
<field eval="&quot;4&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_11"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;pending&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -269,7 +284,7 @@
<field name="project_id" ref="project.project_project_22"/>
<field eval="&quot;Improve Reports in HRMS&quot;" name="name"/>
</record>
<record id="crm_case_improvereportsinpms0" model="project.issue">
<field name="partner_address_id" ref="base.res_partner_address_15"/>
<field eval="time.strftime('%Y-%m-21 14:30:00')" name="date"/>
@@ -277,6 +292,7 @@
<field eval="&quot;2&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field name="partner_id" ref="base.res_partner_11"/>
<field name="analytic_account_id" ref="account.analytic_project_1"/>
<field eval="&quot;pending&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
@@ -286,6 +302,6 @@
<field name="project_id" ref="project.project_project_22"/>
<field eval="&quot;Improve Reports in PMS&quot;" name="name"/>
</record>
</data>
</openerp>
+22 -15
View File
@@ -104,21 +104,28 @@
<field name="email"/>
<field name="canal_id"/>
<button
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4" string="Reply to Last Email" name="%(crm.wizard_crm_send_mail)d" context="{'mail':'reply'}" icon="gtk-undo" type="action"/>
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email" name="%(crm.wizard_crm_new_send_mail)d" context="{'mail':'new'}" icon="gtk-go-forward" type="action"/>
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4"
string="Reply to Last Email"
name="%(crm.action_crm_reply_mail)d"
context="{'mail':'reply', 'model': 'project.issue'}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(crm.action_crm_send_mail)d"
context="{'mail':'new', 'model': 'project.issue'}"
icon="gtk-go-forward" type="action" />
</page>
<page string="Worklogs">
<separator string="Timesheets" colspan="4" />