[MERGE] merged work from ysa-addons branch
bzr revid: hmo@tinyerp.com-20110214060627-z3lnvmp02dkhw374
This commit is contained in:
commit
6eaf481c6c
|
@ -43,7 +43,7 @@
|
|||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'depends': ['account'],
|
||||
'depends': ['account', 'emails'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'security/ir.model.access.csv',
|
||||
|
|
|
@ -205,6 +205,7 @@ class account_followup_print_all(osv.osv_memory):
|
|||
move_obj = self.pool.get('account.move.line')
|
||||
user_obj = self.pool.get('res.users')
|
||||
line_obj = self.pool.get('account_followup.stat')
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
|
@ -276,7 +277,7 @@ class account_followup_print_all(osv.osv_memory):
|
|||
msg = ''
|
||||
if dest:
|
||||
try:
|
||||
tools.email_send(src, dest, sub, body)
|
||||
email_message_obj.email_send(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 )
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -26,12 +26,12 @@
|
|||
'description': "This module allows to implement action rules for any object.",
|
||||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'depends': ['base'],
|
||||
'depends': ['base', 'emails'],
|
||||
'init_xml': [
|
||||
'base_action_rule_data.xml'
|
||||
],
|
||||
'update_xml': [
|
||||
'base_action_rule_view.xml',
|
||||
'base_action_rule_view.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'demo_xml': [],
|
||||
|
|
|
@ -24,7 +24,7 @@ from tools.translate import _
|
|||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
from tools.safe_eval import safe_eval
|
||||
import pooler
|
||||
import pooler
|
||||
import re
|
||||
import time
|
||||
import tools
|
||||
|
@ -39,7 +39,7 @@ class base_action_rule(osv.osv):
|
|||
|
||||
_name = 'base.action.rule'
|
||||
_description = 'Action Rules'
|
||||
|
||||
|
||||
def _state_get(self, cr, uid, context=None):
|
||||
""" Get State
|
||||
@param self: The object pointer
|
||||
|
@ -55,7 +55,7 @@ class base_action_rule(osv.osv):
|
|||
@param uid: the current user’s ID for security checks,
|
||||
@param context: A standard dictionary for contextual values """
|
||||
return [('', '')]
|
||||
|
||||
|
||||
def priority_get(self, cr, uid, context=None):
|
||||
""" Get Priority
|
||||
@param self: The object pointer
|
||||
|
@ -65,57 +65,57 @@ class base_action_rule(osv.osv):
|
|||
return [('', '')]
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Rule Name', size=64, required=True),
|
||||
'model_id': fields.many2one('ir.model', 'Object', required=True),
|
||||
'create_date': fields.datetime('Create Date', readonly=1),
|
||||
'name': fields.char('Rule Name', size=64, required=True),
|
||||
'model_id': fields.many2one('ir.model', 'Object', required=True),
|
||||
'create_date': fields.datetime('Create Date', readonly=1),
|
||||
'active': fields.boolean('Active', help="If the active field is set to False,\
|
||||
it will allow you to hide the rule without removing it."),
|
||||
it will allow you to hide the rule without removing it."),
|
||||
'sequence': fields.integer('Sequence', help="Gives the sequence order \
|
||||
when displaying a list of rules."),
|
||||
when displaying a list of rules."),
|
||||
'trg_date_type': fields.selection([
|
||||
('none', 'None'),
|
||||
('create', 'Creation Date'),
|
||||
('action_last', 'Last Action Date'),
|
||||
('date', 'Date'),
|
||||
('deadline', 'Deadline'),
|
||||
], 'Trigger Date', size=16),
|
||||
('none', 'None'),
|
||||
('create', 'Creation Date'),
|
||||
('action_last', 'Last Action Date'),
|
||||
('date', 'Date'),
|
||||
('deadline', 'Deadline'),
|
||||
], 'Trigger Date', size=16),
|
||||
'trg_date_range': fields.integer('Delay after trigger date', \
|
||||
help="Delay After Trigger Date,\
|
||||
specifies you can put a negative number. If you need a delay before the \
|
||||
trigger date, like sending a reminder 15 minutes before a meeting."),
|
||||
trigger date, like sending a reminder 15 minutes before a meeting."),
|
||||
'trg_date_range_type': fields.selection([('minutes', 'Minutes'), ('hour', 'Hours'), \
|
||||
('day', 'Days'), ('month', 'Months')], 'Delay type'),
|
||||
'trg_user_id': fields.many2one('res.users', 'Responsible'),
|
||||
'trg_partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'trg_partner_categ_id': fields.many2one('res.partner.category', 'Partner Category'),
|
||||
'trg_state_from': fields.selection(_state_get, 'State', size=16),
|
||||
'trg_state_to': fields.selection(_state_get, 'Button Pressed', size=16),
|
||||
('day', 'Days'), ('month', 'Months')], 'Delay type'),
|
||||
'trg_user_id': fields.many2one('res.users', 'Responsible'),
|
||||
'trg_partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'trg_partner_categ_id': fields.many2one('res.partner.category', 'Partner Category'),
|
||||
'trg_state_from': fields.selection(_state_get, 'State', size=16),
|
||||
'trg_state_to': fields.selection(_state_get, 'Button Pressed', size=16),
|
||||
|
||||
'act_method': fields.char('Call Object Method', size=64),
|
||||
'act_user_id': fields.many2one('res.users', 'Set Responsible to'),
|
||||
'act_state': fields.selection(_state_get, 'Set State to', size=16),
|
||||
'act_method': fields.char('Call Object Method', size=64),
|
||||
'act_user_id': fields.many2one('res.users', 'Set Responsible to'),
|
||||
'act_state': fields.selection(_state_get, 'Set State to', size=16),
|
||||
'act_email_cc': fields.char('Add Watchers (Cc)', size=250, help="\
|
||||
These people will receive a copy of the future communication between partner \
|
||||
and users by email"),
|
||||
and users by email"),
|
||||
'act_remind_partner': fields.boolean('Remind Partner', help="Check \
|
||||
this if you want the rule to send a reminder by email to the partner."),
|
||||
this if you want the rule to send a reminder by email to the partner."),
|
||||
'act_remind_user': fields.boolean('Remind Responsible', help="Check \
|
||||
this if you want the rule to send a reminder by email to the user."),
|
||||
'act_reply_to': fields.char('Reply-To', size=64),
|
||||
'act_remind_attach': fields.boolean('Remind with Attachment', help="Check this if you want that all documents attached to the object be attached to the reminder email sent."),
|
||||
this if you want the rule to send a reminder by email to the user."),
|
||||
'act_reply_to': fields.char('Reply-To', size=64),
|
||||
'act_remind_attach': fields.boolean('Remind with Attachment', help="Check this if you want that all documents attached to the object be attached to the reminder email sent."),
|
||||
'act_mail_to_user': fields.boolean('Mail to Responsible', help="Check\
|
||||
this if you want the rule to send an email to the responsible person."),
|
||||
'act_mail_to_watchers': fields.boolean('Mail to Watchers (CC)',
|
||||
this if you want the rule to send an email to the responsible person."),
|
||||
'act_mail_to_watchers': fields.boolean('Mail to Watchers (CC)',
|
||||
help="Check this if you want \
|
||||
the rule to mark CC(mail to any other person defined in actions)."),
|
||||
the rule to mark CC(mail to any other person defined in actions)."),
|
||||
'act_mail_to_email': fields.char('Mail to these Emails', size=128, \
|
||||
help="Email-id of the persons whom mail is to be sent"),
|
||||
'act_mail_body': fields.text('Mail body', help="Content of mail"),
|
||||
help="Email-id of the persons whom mail is to be sent"),
|
||||
'act_mail_body': fields.text('Mail body', help="Content of mail"),
|
||||
'regex_name': fields.char('Regex on Resource Name', size=128, help="Regular expression for matching name of the resource\
|
||||
\ne.g.: 'urgent.*' will search for records having name starting with the string 'urgent'\
|
||||
\nNote: This is case sensitive search."),
|
||||
'server_action_id': fields.many2one('ir.actions.server', 'Server Action', help="Describes the action name.\neg:on which object which action to be taken on basis of which condition"),
|
||||
'filter_id':fields.many2one('ir.filters', 'Filter', required=False),
|
||||
\nNote: This is case sensitive search."),
|
||||
'server_action_id': fields.many2one('ir.actions.server', 'Server Action', help="Describes the action name.\neg:on which object which action to be taken on basis of which condition"),
|
||||
'filter_id':fields.many2one('ir.filters', 'Filter', required=False),
|
||||
'act_email_from' : fields.char('Email From', size=64, required=False,
|
||||
help="Use a python expression to specify the right field on which one than we will use for the 'From' field of the header"),
|
||||
'act_email_to' : fields.char('Email To', size=64, required=False,
|
||||
|
@ -124,17 +124,17 @@ the rule to mark CC(mail to any other person defined in actions)."),
|
|||
}
|
||||
|
||||
_defaults = {
|
||||
'active': lambda *a: True,
|
||||
'trg_date_type': lambda *a: 'none',
|
||||
'trg_date_range_type': lambda *a: 'day',
|
||||
'act_mail_to_user': lambda *a: 0,
|
||||
'act_remind_partner': lambda *a: 0,
|
||||
'act_remind_user': lambda *a: 0,
|
||||
'act_mail_to_watchers': lambda *a: 0,
|
||||
'active': lambda *a: True,
|
||||
'trg_date_type': lambda *a: 'none',
|
||||
'trg_date_range_type': lambda *a: 'day',
|
||||
'act_mail_to_user': lambda *a: 0,
|
||||
'act_remind_partner': lambda *a: 0,
|
||||
'act_remind_user': lambda *a: 0,
|
||||
'act_mail_to_watchers': lambda *a: 0,
|
||||
}
|
||||
|
||||
|
||||
_order = 'sequence'
|
||||
|
||||
|
||||
def onchange_model_id(self, cr, uid, ids, name):
|
||||
#This is not a good solution as it will affect the domain only on onchange
|
||||
res = {'domain':{'filter_id':[]}}
|
||||
|
@ -174,7 +174,7 @@ the rule to mark CC(mail to any other person defined in actions)."),
|
|||
self.pre_action(cr, uid, [new_id], model, context=context)
|
||||
return new_id
|
||||
return make_call_old
|
||||
|
||||
|
||||
def _write(self, old_write, model, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
@ -202,9 +202,9 @@ the rule to mark CC(mail to any other person defined in actions)."),
|
|||
return True
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
res_id = super(base_action_rule, self).create(cr, uid, vals, context=context)
|
||||
self._register_hook(cr, uid, [res_id], context=context)
|
||||
self._register_hook(cr, uid, [res_id], context=context)
|
||||
return res_id
|
||||
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
res = super(base_action_rule, self).write(cr, uid, ids, vals, context=context)
|
||||
self._register_hook(cr, uid, ids, context=context)
|
||||
|
@ -272,18 +272,18 @@ the rule to mark CC(mail to any other person defined in actions)."),
|
|||
@param self: The object pointer """
|
||||
|
||||
data = {
|
||||
'object_id': obj.id,
|
||||
'object_subject': hasattr(obj, 'name') and obj.name or False,
|
||||
'object_date': hasattr(obj, 'date') and obj.date or False,
|
||||
'object_description': hasattr(obj, 'description') and obj.description or False,
|
||||
'object_user': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.name) or '/',
|
||||
'object_id': obj.id,
|
||||
'object_subject': hasattr(obj, 'name') and obj.name or False,
|
||||
'object_date': hasattr(obj, 'date') and obj.date or False,
|
||||
'object_description': hasattr(obj, 'description') and obj.description or False,
|
||||
'object_user': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.name) or '/',
|
||||
'object_user_email': hasattr(obj, 'user_id') and (obj.user_id and \
|
||||
obj.user_id.address_id and obj.user_id.address_id.email) or '/',
|
||||
obj.user_id.address_id and obj.user_id.address_id.email) or '/',
|
||||
'object_user_phone': hasattr(obj, 'user_id') and (obj.user_id and\
|
||||
obj.user_id.address_id and obj.user_id.address_id.phone) or '/',
|
||||
'partner': hasattr(obj, 'partner_id') and (obj.partner_id and obj.partner_id.name) or '/',
|
||||
obj.user_id.address_id and obj.user_id.address_id.phone) or '/',
|
||||
'partner': hasattr(obj, 'partner_id') and (obj.partner_id and obj.partner_id.name) or '/',
|
||||
'partner_email': hasattr(obj, 'partner_address_id') and (obj.partner_address_id and\
|
||||
obj.partner_address_id.email) or '/',
|
||||
obj.partner_address_id.email) or '/',
|
||||
}
|
||||
return self.format_body(body % data)
|
||||
|
||||
|
@ -302,6 +302,7 @@ the rule to mark CC(mail to any other person defined in actions)."),
|
|||
if context is None:
|
||||
context = {}
|
||||
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
body = self.format_mail(obj, body)
|
||||
if not emailfrom:
|
||||
if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and\
|
||||
|
@ -312,9 +313,9 @@ the rule to mark CC(mail to any other person defined in actions)."),
|
|||
emailfrom = tools.ustr(emailfrom)
|
||||
reply_to = emailfrom
|
||||
if not emailfrom:
|
||||
raise osv.except_osv(_('Error!'),
|
||||
raise osv.except_osv(_('Error!'),
|
||||
_("No E-Mail ID Found for your Company address!"))
|
||||
return tools.email_send(emailfrom, emails, name, body, reply_to=reply_to, openobject_id=str(obj.id))
|
||||
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))
|
||||
|
||||
|
||||
def do_check(self, cr, uid, action, obj, context=None):
|
||||
|
@ -325,7 +326,7 @@ the rule to mark CC(mail to any other person defined in actions)."),
|
|||
@param context: A standard dictionary for contextual values """
|
||||
if context is None:
|
||||
context = {}
|
||||
ok = True
|
||||
ok = True
|
||||
if action.filter_id:
|
||||
if action.model_id.model == action.filter_id.model_id:
|
||||
context.update(eval(action.filter_id.context))
|
||||
|
@ -480,15 +481,15 @@ the rule to mark CC(mail to any other person defined in actions)."),
|
|||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_mail, 'Error: The mail is not well formated', ['act_mail_body']),
|
||||
(_check_mail, 'Error: The mail is not well formated', ['act_mail_body']),
|
||||
]
|
||||
|
||||
base_action_rule()
|
||||
|
||||
|
||||
class ir_cron(osv.osv):
|
||||
_inherit = 'ir.cron'
|
||||
|
||||
_inherit = 'ir.cron'
|
||||
|
||||
def _poolJobs(self, db_name, check=False):
|
||||
try:
|
||||
db = pooler.get_db(db_name)
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
##############################################################################
|
||||
|
||||
{
|
||||
"name" : "Basic Calendar Functionality",
|
||||
"version" : "1.0",
|
||||
"depends" : ["base"],
|
||||
"name" : "Basic Calendar Functionality",
|
||||
"version" : "1.0",
|
||||
"depends" : ["base", "emails"],
|
||||
'description': """Full featured calendar system that supports:
|
||||
- Calendar of events
|
||||
- Alerts (create requests)
|
||||
|
|
|
@ -411,7 +411,7 @@ property or property parameter."),
|
|||
cal = vobject.iCalendar()
|
||||
event = cal.add('vevent')
|
||||
if not event_obj.date_deadline or not event_obj.date:
|
||||
raise osv.except_osv(_('Warning !'),_("Couldn't Invite because date is not specified!"))
|
||||
raise osv.except_osv(_('Warning !'),_("Couldn't Invite because date is not specified!"))
|
||||
event.add('created').value = ics_datetime(time.strftime('%Y-%m-%d %H:%M:%S'))
|
||||
event.add('dtstart').value = ics_datetime(event_obj.date)
|
||||
event.add('dtend').value = ics_datetime(event_obj.date_deadline)
|
||||
|
@ -456,7 +456,7 @@ property or property parameter."),
|
|||
trigger.value = delta
|
||||
# Compute other details
|
||||
valarm.add('DESCRIPTION').value = alarm_data['name'] or 'OpenERP'
|
||||
|
||||
|
||||
for attendee in event_obj.attendee_ids:
|
||||
attendee_add = event.add('attendee')
|
||||
attendee_add.params['CUTYPE'] = [str(attendee.cutype)]
|
||||
|
@ -480,6 +480,7 @@ property or property parameter."),
|
|||
context = {}
|
||||
|
||||
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.name
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
for att in self.browse(cr, uid, ids, context=context):
|
||||
sign = att.sent_by_uid and att.sent_by_uid.signature or ''
|
||||
sign = '<br>'.join(sign and sign.split('\n') or [])
|
||||
|
@ -506,11 +507,12 @@ 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)
|
||||
tools.email_send(
|
||||
email_message_obj.email_send(cr, uid,
|
||||
email_from,
|
||||
mail_to,
|
||||
sub,
|
||||
body,
|
||||
model='calendar.attendee',
|
||||
attach=attach and [('invitation.ics', attach)] or None,
|
||||
subtype='html',
|
||||
reply_to=email_from
|
||||
|
@ -674,7 +676,7 @@ true, it will allow you to hide the event alarm information without removing it.
|
|||
new_res_alarm = alarm_ids[0]
|
||||
cr.execute('UPDATE %s ' % model_obj._table + \
|
||||
' SET base_calendar_alarm_id=%s, alarm_id=%s ' \
|
||||
' WHERE id=%s',
|
||||
' WHERE id=%s',
|
||||
(cal_alarm.id, new_res_alarm, data.id))
|
||||
|
||||
self.do_alarm_unlink(cr, uid, [data.id], model)
|
||||
|
@ -809,6 +811,7 @@ class calendar_alarm(osv.osv):
|
|||
return True # XXX FIXME REMOVE THIS AFTER FIXING get_recurrent_dates!!
|
||||
if context is None:
|
||||
context = {}
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
current_datetime = datetime.now()
|
||||
request_obj = self.pool.get('res.request')
|
||||
alarm_ids = self.search(cr, uid, [('state', '!=', 'done')], context=context)
|
||||
|
@ -890,11 +893,12 @@ From:
|
|||
for att in alarm.attendee_ids:
|
||||
mail_to.append(att.user_id.address_id.email)
|
||||
if mail_to:
|
||||
tools.email_send(
|
||||
email_message_obj.email_send(cr, uid,
|
||||
tools.config.get('email_from', False),
|
||||
mail_to,
|
||||
sub,
|
||||
body
|
||||
body,
|
||||
model='calendar.alarm'
|
||||
)
|
||||
if next_trigger_date:
|
||||
update_vals.update({'trigger_date': next_trigger_date})
|
||||
|
@ -966,7 +970,7 @@ class calendar_event(osv.osv):
|
|||
value['date_deadline'] = end.strftime("%Y-%m-%d %H:%M:%S")
|
||||
elif end_date and duration and not allday:
|
||||
# we have both, keep them synchronized:
|
||||
# set duration based on end_date (arbitrary decision: this avoid
|
||||
# set duration based on end_date (arbitrary decision: this avoid
|
||||
# getting dates like 06:31:48 instead of 06:32:00)
|
||||
end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S")
|
||||
diff = end - start
|
||||
|
@ -1130,7 +1134,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
FREQ=MONTHLY;INTERVAL=2;COUNT=10;BYDAY=-1SU'),
|
||||
'rrule_type': fields.selection([('none', ''), ('daily', 'Daily'), \
|
||||
('weekly', 'Weekly'), ('monthly', 'Monthly'), \
|
||||
('yearly', 'Yearly'),],
|
||||
('yearly', 'Yearly'),],
|
||||
'Recurrency', states={'done': [('readonly', True)]},
|
||||
help="Let the event automatically repeat at that interval"),
|
||||
'alarm_id': fields.many2one('res.alarm', 'Alarm', states={'done': [('readonly', True)]},
|
||||
|
@ -1148,7 +1152,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
('weekly', 'Weeks'),
|
||||
('monthly', 'Months'),
|
||||
('yearly', 'Years'), ], 'Frequency'),
|
||||
|
||||
|
||||
'end_type' : fields.selection([('forever', 'Forever'), ('count', 'Fix amout of times'), ('end_date','End date')], 'Way to end reccurency'),
|
||||
'interval': fields.integer('Repeat every', help="Repeat every (Days/Week/Month/Year)"),
|
||||
'count': fields.integer('Repeat', help="Repeat x times"),
|
||||
|
@ -1159,7 +1163,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
'fr': fields.boolean('Fri'),
|
||||
'sa': fields.boolean('Sat'),
|
||||
'su': fields.boolean('Sun'),
|
||||
'select1': fields.selection([('date', 'Date of month'),
|
||||
'select1': fields.selection([('date', 'Date of month'),
|
||||
('day', 'Day of month')], 'Option'),
|
||||
'day': fields.integer('Date of month'),
|
||||
'week_list': fields.selection([('MO', 'Monday'), ('TU', 'Tuesday'), \
|
||||
|
@ -1176,8 +1180,8 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
'allday': fields.boolean('All Day', states={'done': [('readonly', True)]}),
|
||||
'active': fields.boolean('Active', help="If the active field is set to \
|
||||
true, it will allow you to hide the event alarm information without removing it."),
|
||||
'recurrency': fields.boolean('Recurrent', help="Recurrent Meeting"),
|
||||
'edit_all': fields.boolean('Edit All', help="Edit all Occurrences of recurrent Meeting."),
|
||||
'recurrency': fields.boolean('Recurrent', help="Recurrent Meeting"),
|
||||
'edit_all': fields.boolean('Edit All', help="Edit all Occurrences of recurrent Meeting."),
|
||||
}
|
||||
def default_organizer(self, cr, uid, context=None):
|
||||
user_pool = self.pool.get('res.users')
|
||||
|
@ -1204,12 +1208,12 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
def onchange_edit_all(self, cr, uid, ids, rrule_type,edit_all, context=None):
|
||||
if not context:
|
||||
context = {}
|
||||
|
||||
|
||||
value = {}
|
||||
if edit_all and rrule_type:
|
||||
for id in ids:
|
||||
base_calendar_id2real_id(id)
|
||||
return value
|
||||
return value
|
||||
|
||||
def modify_all(self, cr, uid, event_ids, defaults, context=None, *args):
|
||||
"""
|
||||
|
@ -1342,7 +1346,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
freq=datas.get('rrule_type')
|
||||
if freq == 'none':
|
||||
return ''
|
||||
|
||||
|
||||
interval_srting = datas.get('interval') and (';INTERVAL=' + str(datas.get('interval'))) or ''
|
||||
|
||||
if freq == 'weekly':
|
||||
|
@ -1358,7 +1362,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
elif datas.get('select1')=='date':
|
||||
monthstring = ';BYMONTHDAY=' + str(datas.get('day'))
|
||||
|
||||
|
||||
|
||||
if datas.get('end_date'):
|
||||
datas['end_date'] = ''.join((re.compile('\d')).findall(datas.get('end_date'))) + 'T235959Z'
|
||||
enddate = (datas.get('count') and (';COUNT=' + str(datas.get('count'))) or '') +\
|
||||
|
@ -1403,7 +1407,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
|
||||
res = self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def get_edit_all(self, cr, uid, id, vals=None):
|
||||
"""
|
||||
|
@ -1414,10 +1418,10 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
if(vals and 'edit_all' in vals): #we jsut check edit_all
|
||||
return vals['edit_all']
|
||||
else: #it's a recurrent event and edit_all is already check
|
||||
return meeting['recurrency'] and meeting['edit_all']
|
||||
return meeting['recurrency'] and meeting['edit_all']
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
|
||||
"""
|
||||
|
@ -1440,12 +1444,12 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
res = False
|
||||
for event_id in select:
|
||||
real_event_id = base_calendar_id2real_id(event_id)
|
||||
|
||||
|
||||
|
||||
if(self.get_edit_all(cr, uid, event_id, vals=vals)):
|
||||
event_id = real_event_id
|
||||
|
||||
|
||||
|
||||
|
||||
if len(str(event_id).split('-')) > 1:
|
||||
data = self.read(cr, uid, event_id, ['date', 'date_deadline', \
|
||||
'rrule', 'duration', 'exdate'])
|
||||
|
@ -1459,15 +1463,15 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
'edit_all': False,
|
||||
'recurrency' : False,
|
||||
})
|
||||
|
||||
|
||||
new_id = self.copy(cr, uid, real_event_id, default=data, context=context)
|
||||
|
||||
|
||||
date_new = event_id.split('-')[1]
|
||||
date_new = time.strftime("%Y%m%dT%H%M%S", \
|
||||
time.strptime(date_new, "%Y%m%d%H%M%S"))
|
||||
exdate = (data['exdate'] and (data['exdate'] + ',') or '') + date_new
|
||||
res = self.write(cr, uid, [real_event_id], {'exdate': exdate})
|
||||
|
||||
|
||||
context.update({'active_id': new_id, 'active_ids': [new_id]})
|
||||
continue
|
||||
if not real_event_id in new_ids:
|
||||
|
@ -1590,10 +1594,10 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
|
|||
res = False
|
||||
for event_datas in self.read(cr, uid, ids, ['date', 'rrule', 'exdate'], context=context):
|
||||
event_id = event_datas['id']
|
||||
|
||||
|
||||
if self.get_edit_all(cr, uid, event_id, vals=None):
|
||||
event_id = base_calendar_id2real_id(event_id)
|
||||
|
||||
|
||||
if isinstance(event_id, (int, long)):
|
||||
res = super(calendar_event, self).unlink(cr, uid, event_id, context=context)
|
||||
self.pool.get('res.alarm').do_alarm_unlink(cr, uid, [event_id], self._name)
|
||||
|
@ -1711,7 +1715,7 @@ class calendar_todo(osv.osv):
|
|||
@param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...].
|
||||
@param context: A standard dictionary for contextual values
|
||||
"""
|
||||
|
||||
|
||||
assert name == 'date'
|
||||
return self.write(cr, uid, id, { 'date_start': value }, context=context)
|
||||
|
||||
|
@ -1743,9 +1747,9 @@ class ir_attachment(osv.osv):
|
|||
for arg in args:
|
||||
args1.append(map(lambda x:str(x).split('-')[0], arg))
|
||||
return super(ir_attachment, self).search_count(cr, user, args1, context)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if context:
|
||||
id = context.get('default_res_id', False)
|
||||
|
|
|
@ -56,7 +56,7 @@ Create dashboard for CRM that includes:
|
|||
'base',
|
||||
'base_action_rule',
|
||||
'process',
|
||||
'mail_gateway',
|
||||
'email_gateway',
|
||||
'base_calendar',
|
||||
'resource',
|
||||
'board'
|
||||
|
|
|
@ -49,7 +49,7 @@ class crm_case(object):
|
|||
|
||||
def _find_lost_stage(self, cr, uid, type, section_id):
|
||||
return self._find_percent_stage(cr, uid, 0.0, type, section_id)
|
||||
|
||||
|
||||
def _find_won_stage(self, cr, uid, type, section_id):
|
||||
return self._find_percent_stage(cr, uid, 100.0, type, section_id)
|
||||
|
||||
|
@ -60,14 +60,14 @@ class crm_case(object):
|
|||
stage_pool = self.pool.get('crm.case.stage')
|
||||
if section_id :
|
||||
ids = stage_pool.search(cr, uid, [("probability", '=', percent), ("type", 'like', type), ("section_ids", 'in', [section_id])])
|
||||
else :
|
||||
else :
|
||||
ids = stage_pool.search(cr, uid, [("probability", '=', percent), ("type", 'like', type)])
|
||||
|
||||
|
||||
if ids:
|
||||
return ids[0]
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
def _find_first_stage(self, cr, uid, type, section_id):
|
||||
"""
|
||||
return the first stage that has a sequence number equal or higher than sequence
|
||||
|
@ -75,9 +75,9 @@ class crm_case(object):
|
|||
stage_pool = self.pool.get('crm.case.stage')
|
||||
if section_id :
|
||||
ids = stage_pool.search(cr, uid, [("sequence", '>', 0), ("type", 'like', type), ("section_ids", 'in', [section_id])])
|
||||
else :
|
||||
else :
|
||||
ids = stage_pool.search(cr, uid, [("sequence", '>', 0), ("type", 'like', type)])
|
||||
|
||||
|
||||
if ids:
|
||||
stages = stage_pool.browse(cr, uid, ids)
|
||||
stage_min = stages[0]
|
||||
|
@ -85,9 +85,9 @@ class crm_case(object):
|
|||
if stage_min.sequence > stage.sequence:
|
||||
stage_min = stage
|
||||
return stage_min.id
|
||||
else :
|
||||
else :
|
||||
return False
|
||||
|
||||
|
||||
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
|
||||
|
||||
""" @param self: The object pointer
|
||||
|
@ -95,7 +95,7 @@ class crm_case(object):
|
|||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of stage’s IDs
|
||||
@stage_id: change state id on run time """
|
||||
|
||||
|
||||
if not stage_id:
|
||||
return {'value':{}}
|
||||
|
||||
|
@ -151,19 +151,19 @@ class crm_case(object):
|
|||
default = {}
|
||||
|
||||
default.update({
|
||||
'message_ids': [],
|
||||
'message_ids': [],
|
||||
})
|
||||
if hasattr(self, '_columns'):
|
||||
if self._columns.get('date_closed'):
|
||||
default.update({
|
||||
'date_closed': False,
|
||||
'date_closed': False,
|
||||
})
|
||||
if self._columns.get('date_open'):
|
||||
default.update({
|
||||
'date_open': False
|
||||
})
|
||||
return super(osv.osv, self).copy(cr, uid, id, default, context=context)
|
||||
|
||||
|
||||
def _get_default_email(self, cr, uid, context=None):
|
||||
"""Gives default email address for current user
|
||||
@param self: The object pointer
|
||||
|
@ -214,7 +214,7 @@ class crm_case(object):
|
|||
return next_stage
|
||||
else :
|
||||
return self._find_next_stage(cr, uid, stage_list, index + 1, current_seq, stage_pool)
|
||||
|
||||
|
||||
def stage_change(self, cr, uid, ids, context=None, order='sequence'):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
@ -226,12 +226,12 @@ class crm_case(object):
|
|||
for case in self.browse(cr, uid, ids, context=context):
|
||||
next_stage = False
|
||||
value = {}
|
||||
if case.section_id.id :
|
||||
if case.section_id.id :
|
||||
domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)]
|
||||
else :
|
||||
domain = [('type', '=', stage_type)]
|
||||
|
||||
|
||||
|
||||
stages = stage_pool.search(cr, uid, domain, order=order)
|
||||
current_seq = case.stage_id.sequence
|
||||
index = -1
|
||||
|
@ -239,18 +239,18 @@ class crm_case(object):
|
|||
index = stages.index(case.stage_id.id)
|
||||
|
||||
next_stage = self._find_next_stage(cr, uid, stages, index, current_seq, stage_pool, context=context)
|
||||
|
||||
|
||||
if next_stage:
|
||||
next_stage_id = next_stage.id
|
||||
value.update({'stage_id': next_stage.id})
|
||||
if next_stage.on_change:
|
||||
value.update({'probability': next_stage.probability})
|
||||
self.write(cr, uid, [case.id], value, context=context)
|
||||
|
||||
|
||||
|
||||
|
||||
return next_stage_id #FIXME should return a list of all id
|
||||
|
||||
|
||||
|
||||
|
||||
def stage_next(self, cr, uid, ids, context=None):
|
||||
"""This function computes next stage for case from its current stage
|
||||
using available stage for that case type
|
||||
|
@ -259,9 +259,9 @@ class crm_case(object):
|
|||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of case IDs
|
||||
@param context: A standard dictionary for contextual values"""
|
||||
|
||||
|
||||
return self.stage_change(cr, uid, ids, context=context, order='sequence')
|
||||
|
||||
|
||||
def stage_previous(self, cr, uid, ids, context=None):
|
||||
"""This function computes previous stage for case from its current stage
|
||||
using available stage for that case type
|
||||
|
@ -283,7 +283,7 @@ class crm_case(object):
|
|||
"""
|
||||
if not part:
|
||||
return {'value': {'partner_address_id': False,
|
||||
'email_from': False,
|
||||
'email_from': False,
|
||||
'phone': False
|
||||
}}
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['contact'])
|
||||
|
@ -321,7 +321,7 @@ class crm_case(object):
|
|||
@param ids: List of case Ids
|
||||
@param *args: Tuple Value for additional Params
|
||||
"""
|
||||
|
||||
|
||||
cases = self.browse(cr, uid, ids)
|
||||
self._history(cr, uid, cases, _('Open'))
|
||||
for case in cases:
|
||||
|
@ -329,9 +329,9 @@ class crm_case(object):
|
|||
if not case.user_id:
|
||||
data['user_id'] = uid
|
||||
self.write(cr, uid, case.id, data)
|
||||
|
||||
|
||||
self._action(cr, uid, cases, 'open')
|
||||
|
||||
|
||||
self._action(cr, uid, cases, 'open')
|
||||
return True
|
||||
|
||||
def case_close(self, cr, uid, ids, *args):
|
||||
|
@ -450,6 +450,7 @@ class crm_case(object):
|
|||
@param context: A standard dictionary for contextual values
|
||||
|
||||
"""
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
for case in self.browse(cr, uid, ids, context=context):
|
||||
if not case.section_id.reply_to:
|
||||
raise osv.except_osv(_('Error!'), ("Reply To is not specified in the sales team"))
|
||||
|
@ -480,11 +481,12 @@ class crm_case(object):
|
|||
|
||||
# Send an email
|
||||
subject = "Reminder: [%s] %s" % (str(case.id), case.name, )
|
||||
tools.email_send(
|
||||
email_message_obj.email_send(cr, uid,
|
||||
src,
|
||||
[dest],
|
||||
subject,
|
||||
subject,
|
||||
body,
|
||||
model='crm.case',
|
||||
reply_to=case.section_id.reply_to,
|
||||
openobject_id=str(case.id),
|
||||
attach=attach_to_send
|
||||
|
@ -550,9 +552,9 @@ class crm_case_stage(osv.osv):
|
|||
_description = "Stage of case"
|
||||
_rec_name = 'name'
|
||||
_order = "sequence"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def _get_type_value(self, cr, user, context):
|
||||
return [('lead','Lead'),('opportunity','Opportunity')]
|
||||
|
||||
|
@ -566,8 +568,8 @@ class crm_case_stage(osv.osv):
|
|||
'requirements': fields.text('Requirements'),
|
||||
'type': fields.selection(_get_type_value, 'Type'),
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
def _find_stage_type(self, cr, uid, context=None):
|
||||
"""Finds type of stage according to object.
|
||||
@param self: The object pointer
|
||||
|
@ -612,7 +614,7 @@ class crm_case_section(osv.osv):
|
|||
'child_ids': fields.one2many('crm.case.section', 'parent_id', 'Child Teams'),
|
||||
'resource_calendar_id': fields.many2one('resource.calendar', "Working Time"),
|
||||
'note': fields.text('Description'),
|
||||
'working_hours': fields.float('Working Hours', digits=(16,2 )),
|
||||
'working_hours': fields.float('Working Hours', digits=(16,2 )),
|
||||
'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'),
|
||||
}
|
||||
|
||||
|
@ -708,7 +710,7 @@ class crm_case_stage(osv.osv):
|
|||
_columns = {
|
||||
'section_ids':fields.many2many('crm.case.section', 'section_stage_rel', 'stage_id', 'section_id', 'Sections'),
|
||||
}
|
||||
|
||||
|
||||
crm_case_stage()
|
||||
|
||||
|
||||
|
|
|
@ -37,25 +37,26 @@ class base_action_rule(osv.osv):
|
|||
""" Base Action Rule """
|
||||
_inherit = 'base.action.rule'
|
||||
_description = 'Action Rules'
|
||||
|
||||
|
||||
_columns = {
|
||||
'trg_section_id': fields.many2one('crm.case.section', 'Sales Team'),
|
||||
'trg_max_history': fields.integer('Maximum Communication History'),
|
||||
'trg_categ_id': fields.many2one('crm.case.categ', 'Category'),
|
||||
'regex_history' : fields.char('Regular Expression on Case History', size=128),
|
||||
'act_section_id': fields.many2one('crm.case.section', 'Set Team to'),
|
||||
'act_categ_id': fields.many2one('crm.case.categ', 'Set Category to'),
|
||||
'trg_section_id': fields.many2one('crm.case.section', 'Sales Team'),
|
||||
'trg_max_history': fields.integer('Maximum Communication History'),
|
||||
'trg_categ_id': fields.many2one('crm.case.categ', 'Category'),
|
||||
'regex_history' : fields.char('Regular Expression on Case History', size=128),
|
||||
'act_section_id': fields.many2one('crm.case.section', 'Set Team to'),
|
||||
'act_categ_id': fields.many2one('crm.case.categ', 'Set Category to'),
|
||||
'act_mail_to_partner': fields.boolean('Mail to Partner', help="Check \
|
||||
this if you want the rule to send an email to the partner."),
|
||||
this if you want the rule to send an email to the partner."),
|
||||
}
|
||||
|
||||
|
||||
|
||||
def email_send(self, cr, uid, obj, emails, body, emailfrom=tools.config.get('email_from', False), context=None):
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
body = self.format_mail(obj, body)
|
||||
if not emailfrom:
|
||||
if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and obj.user_id.address_id.email:
|
||||
emailfrom = obj.user_id.address_id.email
|
||||
|
||||
|
||||
name = '[%d] %s' % (obj.id, tools.ustr(obj.name))
|
||||
emailfrom = tools.ustr(emailfrom)
|
||||
if hasattr(obj, 'section_id') and obj.section_id and obj.section_id.reply_to:
|
||||
|
@ -63,10 +64,10 @@ this if you want the rule to send an email to the partner."),
|
|||
else:
|
||||
reply_to = emailfrom
|
||||
if not emailfrom:
|
||||
raise osv.except_osv(_('Error!'),
|
||||
raise osv.except_osv(_('Error!'),
|
||||
_("No E-Mail ID Found for your Company address!"))
|
||||
return tools.email_send(emailfrom, emails, name, body, reply_to=reply_to, openobject_id=str(obj.id))
|
||||
|
||||
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))
|
||||
|
||||
def do_check(self, cr, uid, action, obj, context=None):
|
||||
""" @param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
|
@ -79,7 +80,7 @@ this if you want the rule to send an email to the partner."),
|
|||
if hasattr(obj, 'categ_id'):
|
||||
ok = ok and (not action.trg_categ_id or action.trg_categ_id.id==obj.categ_id.id)
|
||||
|
||||
#Cheking for history
|
||||
#Cheking for history
|
||||
regex = action.regex_history
|
||||
result_history = True
|
||||
if regex:
|
||||
|
@ -109,7 +110,7 @@ this if you want the rule to send an email to the partner."),
|
|||
@param context: A standard dictionary for contextual values """
|
||||
res = super(base_action_rule, self).do_action(cr, uid, action, model_obj, obj, context=context)
|
||||
write = {}
|
||||
|
||||
|
||||
if hasattr(action, 'act_section_id') and action.act_section_id:
|
||||
obj.section_id = action.act_section_id
|
||||
write['section_id'] = action.act_section_id.id
|
||||
|
|
|
@ -100,7 +100,7 @@ class crm_lead(crm_case, osv.osv):
|
|||
|
||||
_columns = {
|
||||
# Overridden from res.partner.address:
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', ondelete='set null',
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', ondelete='set null',
|
||||
select=True, help="Optional linked partner, usually after conversion of the lead"),
|
||||
|
||||
# From crm.case
|
||||
|
@ -124,7 +124,7 @@ class crm_lead(crm_case, osv.osv):
|
|||
domain="['|',('section_id','=',section_id),('section_id','=',False)]"),
|
||||
'channel_id': fields.many2one('res.partner.canal', 'Channel'),
|
||||
|
||||
'contact_name': fields.char('Contact Name', size=64),
|
||||
'contact_name': fields.char('Contact Name', size=64),
|
||||
'partner_name': fields.char("Customer Name", size=64,help='The name of the future partner that will be created while converting the into opportunity'),
|
||||
'optin': fields.boolean('Opt-In', help="If opt-in is checked, this contact has accepted to receive emails."),
|
||||
'optout': fields.boolean('Opt-Out', help="If opt-out is checked, this contact has refused to receive emails or unsubscribed to a campaign."),
|
||||
|
@ -147,10 +147,10 @@ class crm_lead(crm_case, osv.osv):
|
|||
help='The state is set to \'Draft\', when a case is created.\
|
||||
\nIf the case is in progress the state is set to \'Open\'.\
|
||||
\nWhen the case is over, the state is set to \'Done\'.\
|
||||
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
|
||||
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
\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)]),
|
||||
}
|
||||
|
||||
|
||||
|
||||
_defaults = {
|
||||
'active': lambda *a: 1,
|
||||
|
@ -163,8 +163,8 @@ class crm_lead(crm_case, osv.osv):
|
|||
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
|
||||
#'stage_id': _get_stage_id,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def onchange_partner_address_id(self, cr, uid, ids, add, email=False):
|
||||
"""This function returns value of partner email based on Partner Address
|
||||
|
@ -189,10 +189,10 @@ class crm_lead(crm_case, osv.osv):
|
|||
@param *args: Give Tuple Value
|
||||
"""
|
||||
leads = self.browse(cr, uid, ids)
|
||||
|
||||
|
||||
|
||||
for i in xrange(0, len(ids)):
|
||||
|
||||
|
||||
|
||||
for i in xrange(0, len(ids)):
|
||||
if leads[i].state == 'draft':
|
||||
value = {}
|
||||
if not leads[i].stage_id :
|
||||
|
@ -203,7 +203,7 @@ class crm_lead(crm_case, osv.osv):
|
|||
self.log_open( cr, uid, leads[i])
|
||||
res = super(crm_lead, self).case_open(cr, uid, ids, *args)
|
||||
return res
|
||||
|
||||
|
||||
def log_open(self, cr, uid, case):
|
||||
if case.type == 'lead':
|
||||
message = _("The lead '%s' has been opened.") % case.name
|
||||
|
@ -291,11 +291,11 @@ class crm_lead(crm_case, osv.osv):
|
|||
def write(self, cr, uid, ids, vals, context=None):
|
||||
if not context:
|
||||
context = {}
|
||||
|
||||
|
||||
if 'date_closed' in vals:
|
||||
return super(crm_lead,self).write(cr, uid, ids, vals, context=context)
|
||||
return super(crm_lead,self).write(cr, uid, ids, vals, context)
|
||||
|
||||
|
||||
def stage_historize(self, cr, uid, ids, stage, context=None):
|
||||
stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, stage, context=context)
|
||||
self.history(cr, uid, ids, _('Stage'), details=stage_obj.name)
|
||||
|
@ -306,20 +306,20 @@ class crm_lead(crm_case, osv.osv):
|
|||
message = _("The stage of opportunity '%s' has been changed to '%s'.") % (case.name, stage_obj.name)
|
||||
self.log(cr, uid, case.id, message)
|
||||
return True
|
||||
|
||||
|
||||
def stage_next(self, cr, uid, ids, context=None):
|
||||
stage = super(crm_lead, self).stage_next(cr, uid, ids, context=context)
|
||||
if stage:
|
||||
self.stage_historize(cr, uid, ids, stage, context=context)
|
||||
return stage
|
||||
|
||||
|
||||
def stage_previous(self, cr, uid, ids, context=None):
|
||||
stage = super(crm_lead, self).stage_previous(cr, uid, ids, context)
|
||||
if stage:
|
||||
self.stage_historize(cr, uid, ids, stage, context=context)
|
||||
self.stage_historize(cr, uid, ids, stage, context=context)
|
||||
return stage
|
||||
|
||||
|
||||
|
||||
|
||||
def message_new(self, cr, uid, msg, context=None):
|
||||
"""
|
||||
Automatically calls when new email message arrives
|
||||
|
@ -369,7 +369,7 @@ 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 ids: List of update mail’s IDs
|
||||
@param ids: List of update mail’s IDs
|
||||
"""
|
||||
if isinstance(ids, (str, int, long)):
|
||||
ids = [ids]
|
||||
|
|
|
@ -45,12 +45,12 @@ class crm_meeting(crm_case, osv.osv):
|
|||
_inherit = ['mailgate.thread',"calendar.event"]
|
||||
_columns = {
|
||||
# From crm.case
|
||||
'name': fields.char('Summary', size=124, required=True, states={'done': [('readonly', True)]}),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', states={'done': [('readonly', True)]}),
|
||||
'name': fields.char('Summary', size=124, required=True, states={'done': [('readonly', True)]}),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', states={'done': [('readonly', True)]}),
|
||||
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
|
||||
domain="[('partner_id','=',partner_id)]", states={'done': [('readonly', True)]}),
|
||||
domain="[('partner_id','=',partner_id)]", states={'done': [('readonly', True)]}),
|
||||
'section_id': fields.many2one('crm.case.section', 'Sales Team', states={'done': [('readonly', True)]}, \
|
||||
select=True, help='Sales team to which Case belongs to.'),
|
||||
select=True, help='Sales team to which Case belongs to.'),
|
||||
'email_from': fields.char('Email', size=128, states={'done': [('readonly', True)]}, help="These people will receive email."),
|
||||
'id': fields.integer('ID'),
|
||||
'create_date': fields.datetime('Creation Date' , readonly=True),
|
||||
|
@ -67,7 +67,7 @@ class crm_meeting(crm_case, osv.osv):
|
|||
'event_id', 'attendee_id', 'Attendees', states={'done': [('readonly', True)]}),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
'date_deadline': fields.datetime('Deadline', states={'done': [('readonly', True)]}),
|
||||
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
'message_ids': fields.one2many('email.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
'state': fields.selection([('open', 'Confirmed'),
|
||||
('draft', 'Unconfirmed'),
|
||||
('cancel', 'Cancelled'),
|
||||
|
@ -75,7 +75,7 @@ class crm_meeting(crm_case, osv.osv):
|
|||
size=16, readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'state': 'draft',
|
||||
'state': 'draft',
|
||||
'active': 1,
|
||||
'user_id': lambda self, cr, uid, ctx: uid,
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class res_users(osv.osv):
|
|||
except:
|
||||
# Tolerate a missing shortcut. See product/product.py for similar code.
|
||||
logging.getLogger('orm').debug('Skipped meetings shortcut for user "%s"', data.get('name','<new'))
|
||||
|
||||
|
||||
return user_id
|
||||
|
||||
res_users()
|
||||
|
|
|
@ -37,60 +37,60 @@ class crm_phonecall(crm_case, osv.osv):
|
|||
# From crm.case
|
||||
'id': fields.integer('ID'),
|
||||
'name': fields.char('Call Summary', size=64),
|
||||
'active': fields.boolean('Active', required=False),
|
||||
'active': fields.boolean('Active', required=False),
|
||||
'date_action_last': fields.datetime('Last Action', readonly=1),
|
||||
'date_action_next': fields.datetime('Next Action', readonly=1),
|
||||
'date_action_next': fields.datetime('Next Action', readonly=1),
|
||||
'create_date': fields.datetime('Creation Date' , readonly=True),
|
||||
'section_id': fields.many2one('crm.case.section', 'Sales Team', \
|
||||
select=True, help='Sales team to which Case belongs to.'),
|
||||
'user_id': fields.many2one('res.users', 'Responsible'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
select=True, help='Sales team to which Case belongs to.'),
|
||||
'user_id': fields.many2one('res.users', 'Responsible'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
|
||||
domain="[('partner_id','=',partner_id)]"),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'description': fields.text('Description'),
|
||||
domain="[('partner_id','=',partner_id)]"),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'description': fields.text('Description'),
|
||||
'state': fields.selection([
|
||||
('draft', 'Draft'),
|
||||
('open', 'Todo'),
|
||||
('cancel', 'Cancelled'),
|
||||
('done', 'Done'),
|
||||
('draft', 'Draft'),
|
||||
('open', 'Todo'),
|
||||
('cancel', 'Cancelled'),
|
||||
('done', 'Done'),
|
||||
('pending', 'Pending'),
|
||||
], 'State', size=16, readonly=True,
|
||||
], 'State', size=16, readonly=True,
|
||||
help='The state is set to \'Draft\', when a case is created.\
|
||||
\nIf the case is in progress the state is set to \'Open\'.\
|
||||
\nWhen the case is over, the state is set to \'Done\'.\
|
||||
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
|
||||
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
||||
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
|
||||
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
||||
'date_open': fields.datetime('Opened', readonly=True),
|
||||
# phonecall fields
|
||||
'duration': fields.float('Duration', help="Duration in Minutes"),
|
||||
'duration': fields.float('Duration', help="Duration in Minutes"),
|
||||
'categ_id': fields.many2one('crm.case.categ', 'Category', \
|
||||
domain="['|',('section_id','=',section_id),('section_id','=',False),\
|
||||
('object_id.model', '=', 'crm.phonecall')]"),
|
||||
'partner_phone': fields.char('Phone', size=32),
|
||||
('object_id.model', '=', 'crm.phonecall')]"),
|
||||
'partner_phone': fields.char('Phone', size=32),
|
||||
'partner_contact': fields.related('partner_address_id', 'name', \
|
||||
type="char", string="Contact", size=128),
|
||||
'partner_mobile': fields.char('Mobile', size=32),
|
||||
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
|
||||
type="char", string="Contact", size=128),
|
||||
'partner_mobile': fields.char('Mobile', size=32),
|
||||
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
|
||||
'canal_id': fields.many2one('res.partner.canal', 'Channel', \
|
||||
help="The channels represent the different communication\
|
||||
modes available with the customer." \
|
||||
" With each commercial opportunity, you can indicate\
|
||||
the canall which is this opportunity source."),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
'date': fields.datetime('Date'),
|
||||
'opportunity_id': fields.many2one ('crm.lead', 'Opportunity'),
|
||||
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
the canall which is this opportunity source."),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
'date': fields.datetime('Date'),
|
||||
'opportunity_id': fields.many2one ('crm.lead', 'Opportunity'),
|
||||
'message_ids': fields.one2many('email.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'priority': crm.AVAILABLE_PRIORITIES[2][0],
|
||||
'state': 'open',
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'priority': crm.AVAILABLE_PRIORITIES[2][0],
|
||||
'state': 'open',
|
||||
'user_id': lambda self,cr,uid,ctx: uid,
|
||||
'active': 1,
|
||||
'active': 1,
|
||||
}
|
||||
|
||||
|
||||
# From crm.case
|
||||
|
||||
def onchange_partner_address_id(self, cr, uid, ids, add, email=False):
|
||||
|
@ -174,23 +174,23 @@ class crm_phonecall(crm_case, osv.osv):
|
|||
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
|
||||
|
||||
context = {
|
||||
'default_phonecall_id': phonecall.id,
|
||||
'default_partner_id': phonecall.partner_id and phonecall.partner_id.id or False,
|
||||
'default_email': phonecall.email_from ,
|
||||
'default_phonecall_id': phonecall.id,
|
||||
'default_partner_id': phonecall.partner_id and phonecall.partner_id.id or False,
|
||||
'default_email': phonecall.email_from ,
|
||||
'default_name': phonecall.name
|
||||
}
|
||||
|
||||
value = {
|
||||
'name': _('Meetings'),
|
||||
'domain' : "[('user_id','=',%s)]" % (uid),
|
||||
'context': context,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'calendar,form,tree',
|
||||
'res_model': 'crm.meeting',
|
||||
'view_id': False,
|
||||
'views': [(id1, 'calendar'), (id2, 'form'), (id3, 'tree')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'search_view_id': res['res_id'],
|
||||
'name': _('Meetings'),
|
||||
'domain' : "[('user_id','=',%s)]" % (uid),
|
||||
'context': context,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'calendar,form,tree',
|
||||
'res_model': 'crm.meeting',
|
||||
'view_id': False,
|
||||
'views': [(id1, 'calendar'), (id2, 'form'), (id3, 'tree')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'search_view_id': res['res_id'],
|
||||
'nodestroy': True
|
||||
}
|
||||
|
||||
|
|
|
@ -107,9 +107,9 @@ class crm_lead_report(osv.osv):
|
|||
c.partner_id,
|
||||
c.country_id,
|
||||
c.planned_revenue,
|
||||
c.planned_revenue*(c.probability/100) as probable_revenue,
|
||||
c.planned_revenue*(c.probability/100) as probable_revenue,
|
||||
1 as nbr,
|
||||
(SELECT count(id) FROM mailgate_message WHERE model='crm.lead' AND res_id=c.id AND history=True) AS email,
|
||||
(SELECT count(id) FROM email_message WHERE model='crm.lead' AND res_id=c.id AND history=True) AS email,
|
||||
date_trunc('day',c.create_date) as create_date,
|
||||
extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as delay_close,
|
||||
abs(extract('epoch' from (c.date_deadline - c.date_closed))/(3600*24)) as delay_expected,
|
||||
|
|
|
@ -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
|
||||
"mail_gateway_mailgate_message_manager","mail_gateway.mailgate.message.manager","mail_gateway.model_mailgate_message","base.group_sale_manager",1,0,0,0
|
||||
"mail_gateway_mailgate_thread_manager","mail_gateway.mailgate.thread.manager","mail_gateway.model_mailgate_thread","base.group_sale_manager",1,1,1,1
|
||||
"email_email_message_manager","emails.email.message.manager","emails.model_email_message","base.group_sale_manager",1,0,0,0
|
||||
"email_mailgate_thread_manager","email_gateway.mailgate.thread.manager","email_gateway.model_mailgate_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
|
||||
"mail_gateway_mailgate_thread","mail_gateway.mailgate.thread","mail_gateway.model_mailgate_thread","base.group_sale_salesman",1,1,1,1
|
||||
"mail_gateway_mailgate_message_user","mail_gateway.mailgate.message.user","mail_gateway.model_mailgate_message","base.group_sale_salesman",1,1,1,1
|
||||
"email_gateway_mailgate_thread","email_gateway.mailgate.thread","email_gateway.model_mailgate_thread","base.group_sale_salesman",1,1,1,1
|
||||
"email_gateway_email_message_user","emails.email.message.user","emails.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
|
||||
|
|
|
|
@ -88,7 +88,7 @@ class crm_lead2opportunity(osv.osv_memory):
|
|||
leads.history(cr, uid, [lead], _('Opportunity'), details='Converted to Opportunity', context=context)
|
||||
if lead.partner_id:
|
||||
msg_ids = [ x.id for x in lead.message_ids]
|
||||
self.pool.get('mailgate.message').write(cr, uid, msg_ids, {
|
||||
self.pool.get('email.message').write(cr, uid, msg_ids, {
|
||||
'partner_id': lead.partner_id.id
|
||||
}, context=context)
|
||||
leads.log(cr, uid, lead.id,
|
||||
|
|
|
@ -68,7 +68,7 @@ class crm_merge_opportunity(osv.osv_memory):
|
|||
record_id = context and context.get('active_id', False) or False
|
||||
if record_id:
|
||||
opp_obj = self.pool.get('crm.lead')
|
||||
message_obj = self.pool.get('mailgate.message')
|
||||
message_obj = self.pool.get('email.message')
|
||||
current_opp = opp_obj.browse(cr, uid, record_id, context=context)
|
||||
|
||||
for this in self.browse(cr, uid, ids, context=context):
|
||||
|
|
|
@ -57,14 +57,13 @@ 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'),
|
||||
'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):
|
||||
""" This sends an email to ALL the addresses of the selected partners.
|
||||
"""
|
||||
hist_obj = self.pool.get('mailgate.message')
|
||||
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
|
@ -103,7 +102,7 @@ class crm_send_new_email(osv.osv_memory):
|
|||
attach += attach_all
|
||||
|
||||
else:
|
||||
hist = hist_obj.browse(cr, uid, res_id, context=context)
|
||||
hist = email_message_obj.browse(cr, uid, res_id, context=context)
|
||||
message_id = hist.message_id
|
||||
model = hist.model
|
||||
case_pool = self.pool.get(model)
|
||||
|
@ -124,11 +123,12 @@ class crm_send_new_email(osv.osv_memory):
|
|||
if obj.html:
|
||||
subtype = 'html'
|
||||
|
||||
flag = tools.email_send(
|
||||
flag = email_message_obj.email_send(cr, uid,
|
||||
email_from,
|
||||
emails,
|
||||
obj.subject,
|
||||
body,
|
||||
model='crm.send.mail',
|
||||
email_cc=email_cc,
|
||||
attach=attach,
|
||||
subtype=subtype,
|
||||
|
@ -204,7 +204,7 @@ class crm_send_new_email(osv.osv_memory):
|
|||
"""
|
||||
This function gets default values for reply mail
|
||||
"""
|
||||
hist_obj = self.pool.get('mailgate.message')
|
||||
hist_obj = self.pool.get('email.message')
|
||||
res_ids = context and context.get('active_ids', []) or []
|
||||
|
||||
user_obj = self.pool.get('res.users')
|
||||
|
|
|
@ -32,47 +32,47 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
_order = "priority,date desc"
|
||||
_inherit = ['mailgate.thread']
|
||||
_columns = {
|
||||
'id': fields.integer('ID', readonly=True),
|
||||
'name': fields.char('Claim Subject', size=128, required=True),
|
||||
'id': fields.integer('ID', readonly=True),
|
||||
'name': fields.char('Claim Subject', size=128, required=True),
|
||||
'action_next': fields.char('Next Action', size=200),
|
||||
'date_action_next': fields.datetime('Next Action Date'),
|
||||
'description': fields.text('Description'),
|
||||
'resolution': fields.text('Resolution'),
|
||||
'create_date': fields.datetime('Creation Date' , readonly=True),
|
||||
'write_date': fields.datetime('Update Date' , readonly=True),
|
||||
'date_deadline': fields.date('Deadline'),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
'date': fields.datetime('Claim Date'),
|
||||
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
|
||||
'description': fields.text('Description'),
|
||||
'resolution': fields.text('Resolution'),
|
||||
'create_date': fields.datetime('Creation Date' , readonly=True),
|
||||
'write_date': fields.datetime('Update Date' , readonly=True),
|
||||
'date_deadline': fields.date('Deadline'),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
'date': fields.datetime('Claim Date'),
|
||||
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
|
||||
'categ_id': fields.many2one('crm.case.categ', 'Category', \
|
||||
domain="[('section_id','=',section_id),\
|
||||
('object_id.model', '=', 'crm.claim')]"),
|
||||
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
|
||||
('object_id.model', '=', 'crm.claim')]"),
|
||||
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
|
||||
'type_action': fields.selection([('correction','Corrective Action'),('prevention','Preventive Action')], 'Action Type'),
|
||||
'user_id': fields.many2one('res.users', 'Responsible'),
|
||||
'user_fault': fields.char('Trouble Responsible', size=64),
|
||||
'user_id': fields.many2one('res.users', 'Responsible'),
|
||||
'user_fault': fields.char('Trouble Responsible', size=64),
|
||||
'section_id': fields.many2one('crm.case.section', 'Sales Team', \
|
||||
select=True, help="Sales team to which Case belongs to."\
|
||||
"Define Responsible user and Email account for"\
|
||||
" mail gateway."),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
" mail gateway."),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
|
||||
# domain="[('partner_id','=',partner_id)]"
|
||||
),
|
||||
'email_cc': fields.text('Watchers Emails', size=252, help="These email addresses will be added to the CC field of all inbound and outbound emails for this record before being sent. Separate multiple email addresses with a comma"),
|
||||
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
||||
'partner_phone': fields.char('Phone', size=32),
|
||||
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('type','=','claim')]"),
|
||||
'cause': fields.text('Root Cause'),
|
||||
'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True,
|
||||
),
|
||||
'email_cc': fields.text('Watchers Emails', size=252, help="These email addresses will be added to the CC field of all inbound and outbound emails for this record before being sent. Separate multiple email addresses with a comma"),
|
||||
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
||||
'partner_phone': fields.char('Phone', size=32),
|
||||
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('type','=','claim')]"),
|
||||
'cause': fields.text('Root Cause'),
|
||||
'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True,
|
||||
help='The state is set to \'Draft\', when a case is created.\
|
||||
\nIf the case is in progress the state is set to \'Open\'.\
|
||||
\nWhen the case is over, the state is set to \'Done\'.\
|
||||
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
|
||||
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
\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 _get_stage_id(self, cr, uid, context=None):
|
||||
"""Finds type of stage according to object.
|
||||
@param self: The object pointer
|
||||
|
@ -87,18 +87,18 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
return stage_ids and stage_ids[0] or False
|
||||
|
||||
_defaults = {
|
||||
'user_id': crm.crm_case._get_default_user,
|
||||
'partner_id': crm.crm_case._get_default_partner,
|
||||
'partner_address_id': crm.crm_case._get_default_partner_address,
|
||||
'email_from':crm.crm_case. _get_default_email,
|
||||
'state': lambda *a: 'draft',
|
||||
'section_id':crm.crm_case. _get_section,
|
||||
'user_id': crm.crm_case._get_default_user,
|
||||
'partner_id': crm.crm_case._get_default_partner,
|
||||
'partner_address_id': crm.crm_case._get_default_partner_address,
|
||||
'email_from':crm.crm_case. _get_default_email,
|
||||
'state': lambda *a: 'draft',
|
||||
'section_id':crm.crm_case. _get_section,
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c),
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c),
|
||||
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
|
||||
#'stage_id': _get_stage_id,
|
||||
#'stage_id': _get_stage_id,
|
||||
}
|
||||
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, part, email=False):
|
||||
"""This function returns value of partner address based on partner
|
||||
@param self: The object pointer
|
||||
|
@ -110,7 +110,7 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
"""
|
||||
if not part:
|
||||
return {'value': {'partner_address_id': False,
|
||||
'email_from': False,
|
||||
'email_from': False,
|
||||
'partner_phone': False,
|
||||
'partner_mobile': False
|
||||
}}
|
||||
|
@ -132,37 +132,37 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
return {'value': {'email_from': False}}
|
||||
address = self.pool.get('res.partner.address').browse(cr, uid, add)
|
||||
return {'value': {'email_from': address.email, 'partner_phone': address.phone, 'partner_mobile': address.mobile}}
|
||||
|
||||
|
||||
def case_open(self, cr, uid, ids, *args):
|
||||
"""
|
||||
Opens Claim
|
||||
"""
|
||||
res = super(crm_claim, self).case_open(cr, uid, ids, *args)
|
||||
claims = self.browse(cr, uid, ids)
|
||||
|
||||
|
||||
for i in xrange(0, len(ids)):
|
||||
if not claims[i].stage_id :
|
||||
stage_id = self._find_first_stage(cr, uid, 'claim', claims[i].section_id.id or False)
|
||||
self.write(cr, uid, [ids[i]], {'stage_id' : stage_id})
|
||||
|
||||
|
||||
return res
|
||||
|
||||
crm_claim()
|
||||
|
||||
|
||||
class crm_stage_claim(osv.osv):
|
||||
|
||||
|
||||
def _get_type_value(self, cr, user, context):
|
||||
list = super(crm_stage_claim, self)._get_type_value(cr, user, context)
|
||||
list.append(('claim','Claim'))
|
||||
return list
|
||||
|
||||
|
||||
_inherit = "crm.case.stage"
|
||||
_columns = {
|
||||
'type': fields.selection(_get_type_value, 'Type'),
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
crm_stage_claim()
|
||||
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class crm_claim_report(osv.osv):
|
|||
('11', 'November'), ('12', 'December')], 'Month', readonly=True),
|
||||
'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
||||
'create_date': fields.datetime('Create Date', readonly=True, select=True),
|
||||
'day': fields.char('Day', size=128, readonly=True),
|
||||
'day': fields.char('Day', size=128, readonly=True),
|
||||
'delay_close': fields.float('Delay to close', digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to close the case"),
|
||||
'stage_id': fields.many2one ('crm.case.stage', 'Stage', readonly=True, domain="[('type','=','claim')]"),
|
||||
'categ_id': fields.many2one('crm.case.categ', 'Category',\
|
||||
|
@ -71,8 +71,8 @@ class crm_claim_report(osv.osv):
|
|||
'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
||||
'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'),
|
||||
'type_action': fields.selection([('correction','Corrective Action'),('prevention','Preventive Action')], 'Action Type'),
|
||||
'date_closed': fields.date('Close Date', readonly=True, select=True),
|
||||
'date_deadline': fields.date('Deadline', readonly=True, select=True),
|
||||
'date_closed': fields.date('Close Date', readonly=True, select=True),
|
||||
'date_deadline': fields.date('Deadline', readonly=True, select=True),
|
||||
'delay_expected': fields.float('Overpassed Deadline',digits=(16,2),readonly=True, group_operator="avg"),
|
||||
'email': fields.integer('# Emails', size=128, readonly=True),
|
||||
'probability': fields.float('Probability',digits=(16,2),readonly=True, group_operator="avg")
|
||||
|
@ -106,7 +106,7 @@ class crm_claim_report(osv.osv):
|
|||
c.type_action as type_action,
|
||||
date_trunc('day',c.create_date) as create_date,
|
||||
avg(extract('epoch' from (c.date_closed-c.create_date)))/(3600*24) as delay_close,
|
||||
(SELECT count(id) FROM mailgate_message WHERE model='crm.claim' AND res_id=c.id AND history=True) AS email,
|
||||
(SELECT count(id) FROM email_message WHERE model='crm.claim' AND res_id=c.id AND history=True) AS email,
|
||||
(SELECT avg(probability) FROM crm_case_stage WHERE type='claim' AND id=c.stage_id) AS probability,
|
||||
extract('epoch' from (c.date_deadline - c.date_closed))/(3600*24) as delay_expected
|
||||
from
|
||||
|
|
|
@ -30,83 +30,83 @@ class crm_fundraising(crm.crm_case, osv.osv):
|
|||
_order = "id desc"
|
||||
_inherit = ['mailgate.thread']
|
||||
_columns = {
|
||||
'id': fields.integer('ID'),
|
||||
'id': fields.integer('ID'),
|
||||
'name': fields.char('Name', size=128, required=True),
|
||||
'active': fields.boolean('Active', required=False),
|
||||
'active': fields.boolean('Active', required=False),
|
||||
'date_action_last': fields.datetime('Last Action', readonly=1),
|
||||
'date_action_next': fields.datetime('Next Action', readonly=1),
|
||||
'description': fields.text('Description'),
|
||||
'create_date': fields.datetime('Creation Date' , readonly=True),
|
||||
'write_date': fields.datetime('Update Date' , readonly=True),
|
||||
'date_deadline': fields.date('Deadline'),
|
||||
'user_id': fields.many2one('res.users', 'Responsible'),
|
||||
'date_action_next': fields.datetime('Next Action', readonly=1),
|
||||
'description': fields.text('Description'),
|
||||
'create_date': fields.datetime('Creation Date' , readonly=True),
|
||||
'write_date': fields.datetime('Update Date' , readonly=True),
|
||||
'date_deadline': fields.date('Deadline'),
|
||||
'user_id': fields.many2one('res.users', 'Responsible'),
|
||||
'section_id': fields.many2one('crm.case.section', 'Sales Team', \
|
||||
select=True, help='Sales team to which Case belongs to. Define Responsible user and Email account for mail gateway.'),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
select=True, help='Sales team to which Case belongs to. Define Responsible user and Email account for mail gateway.'),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
|
||||
domain="[('partner_id','=',partner_id)]"),
|
||||
'email_cc': fields.text('Watchers Emails', size=252 , help="These email addresses will be added to the CC field of all inbound and outbound emails for this record before being sent. Separate multiple email addresses with a comma"),
|
||||
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
'date': fields.datetime('Date'),
|
||||
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
|
||||
domain="[('partner_id','=',partner_id)]"),
|
||||
'email_cc': fields.text('Watchers Emails', size=252 , help="These email addresses will be added to the CC field of all inbound and outbound emails for this record before being sent. Separate multiple email addresses with a comma"),
|
||||
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
'date': fields.datetime('Date'),
|
||||
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
|
||||
'categ_id': fields.many2one('crm.case.categ', 'Category', \
|
||||
domain="[('section_id','=',section_id),\
|
||||
('object_id.model', '=', 'crm.fundraising')]"),
|
||||
'planned_revenue': fields.float('Planned Revenue'),
|
||||
'planned_cost': fields.float('Planned Costs'),
|
||||
'probability': fields.float('Probability (%)'),
|
||||
'partner_name': fields.char("Employee's Name", size=64),
|
||||
'partner_name2': fields.char('Employee Email', size=64),
|
||||
'partner_phone': fields.char('Phone', size=32),
|
||||
'partner_mobile': fields.char('Mobile', size=32),
|
||||
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('type', '=', 'fundraising')]"),
|
||||
('object_id.model', '=', 'crm.fundraising')]"),
|
||||
'planned_revenue': fields.float('Planned Revenue'),
|
||||
'planned_cost': fields.float('Planned Costs'),
|
||||
'probability': fields.float('Probability (%)'),
|
||||
'partner_name': fields.char("Employee's Name", size=64),
|
||||
'partner_name2': fields.char('Employee Email', size=64),
|
||||
'partner_phone': fields.char('Phone', size=32),
|
||||
'partner_mobile': fields.char('Mobile', size=32),
|
||||
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('type', '=', 'fundraising')]"),
|
||||
'type_id': fields.many2one('crm.case.resource.type', 'Campaign', \
|
||||
domain="[('section_id','=',section_id)]"),
|
||||
'duration': fields.float('Duration'),
|
||||
'ref': fields.reference('Reference', selection=crm._links_get, size=128),
|
||||
'ref2': fields.reference('Reference 2', selection=crm._links_get, size=128),
|
||||
domain="[('section_id','=',section_id)]"),
|
||||
'duration': fields.float('Duration'),
|
||||
'ref': fields.reference('Reference', selection=crm._links_get, size=128),
|
||||
'ref2': fields.reference('Reference 2', selection=crm._links_get, size=128),
|
||||
'canal_id': fields.many2one('res.partner.canal', 'Channel', \
|
||||
help="The channels represent the different communication \
|
||||
modes available with the customer."),
|
||||
'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True,
|
||||
modes available with the customer."),
|
||||
'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True,
|
||||
help='The state is set to \'Draft\', when a case is created.\
|
||||
\nIf the case is in progress the state is set to \'Open\'.\
|
||||
\nWhen the case is over, the state is set to \'Done\'.\
|
||||
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
|
||||
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
\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)]),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'active': lambda *a: 1,
|
||||
'user_id': crm.crm_case._get_default_user,
|
||||
'partner_id': crm.crm_case._get_default_partner,
|
||||
'partner_address_id': crm.crm_case._get_default_partner_address,
|
||||
'email_from': crm.crm_case. _get_default_email,
|
||||
'state': lambda *a: 'draft',
|
||||
'section_id': crm.crm_case. _get_section,
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c),
|
||||
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
|
||||
'probability': lambda *a:0.0,
|
||||
'planned_cost': lambda *a:0.0,
|
||||
'planned_revenue': lambda *a:0.0,
|
||||
'active': lambda *a: 1,
|
||||
'user_id': crm.crm_case._get_default_user,
|
||||
'partner_id': crm.crm_case._get_default_partner,
|
||||
'partner_address_id': crm.crm_case._get_default_partner_address,
|
||||
'email_from': crm.crm_case. _get_default_email,
|
||||
'state': lambda *a: 'draft',
|
||||
'section_id': crm.crm_case. _get_section,
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c),
|
||||
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
|
||||
'probability': lambda *a:0.0,
|
||||
'planned_cost': lambda *a:0.0,
|
||||
'planned_revenue': lambda *a:0.0,
|
||||
}
|
||||
|
||||
crm_fundraising()
|
||||
|
||||
|
||||
class crm_stage_fundraising(osv.osv):
|
||||
|
||||
|
||||
def _get_type_value(self, cr, user, context):
|
||||
list = super(crm_stage_fundraising, self)._get_type_value(cr, user, context)
|
||||
list.append(('fundraising','Fundraising'))
|
||||
return list
|
||||
|
||||
|
||||
_inherit = "crm.case.stage"
|
||||
_columns = {
|
||||
'type': fields.selection(_get_type_value, 'Type'),
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
crm_stage_fundraising()
|
||||
|
|
|
@ -31,59 +31,59 @@ class crm_helpdesk(crm.crm_case, osv.osv):
|
|||
_order = "id desc"
|
||||
_inherit = ['mailgate.thread']
|
||||
_columns = {
|
||||
'id': fields.integer('ID', readonly=True),
|
||||
'name': fields.char('Name', size=128, required=True),
|
||||
'active': fields.boolean('Active', required=False),
|
||||
'date_action_last': fields.datetime('Last Action', readonly=1),
|
||||
'date_action_next': fields.datetime('Next Action', readonly=1),
|
||||
'description': fields.text('Description'),
|
||||
'create_date': fields.datetime('Creation Date' , readonly=True),
|
||||
'write_date': fields.datetime('Update Date' , readonly=True),
|
||||
'date_deadline': fields.date('Deadline'),
|
||||
'user_id': fields.many2one('res.users', 'Responsible'),
|
||||
'id': fields.integer('ID', readonly=True),
|
||||
'name': fields.char('Name', size=128, required=True),
|
||||
'active': fields.boolean('Active', required=False),
|
||||
'date_action_last': fields.datetime('Last Action', readonly=1),
|
||||
'date_action_next': fields.datetime('Next Action', readonly=1),
|
||||
'description': fields.text('Description'),
|
||||
'create_date': fields.datetime('Creation Date' , readonly=True),
|
||||
'write_date': fields.datetime('Update Date' , readonly=True),
|
||||
'date_deadline': fields.date('Deadline'),
|
||||
'user_id': fields.many2one('res.users', 'Responsible'),
|
||||
'section_id': fields.many2one('crm.case.section', 'Sales Team', \
|
||||
select=True, help='Sales team to which Case belongs to.\
|
||||
Define Responsible user and Email account for mail gateway.'),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
Define Responsible user and Email account for mail gateway.'),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
|
||||
domain="[('partner_id','=',partner_id)]"),
|
||||
'email_cc': fields.text('Watchers Emails', size=252 , help="These email addresses will be added to the CC field of all inbound and outbound emails for this record before being sent. Separate multiple email addresses with a comma"),
|
||||
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
||||
'date': fields.datetime('Date'),
|
||||
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
|
||||
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
|
||||
domain="[('partner_id','=',partner_id)]"),
|
||||
'email_cc': fields.text('Watchers Emails', size=252 , help="These email addresses will be added to the CC field of all inbound and outbound emails for this record before being sent. Separate multiple email addresses with a comma"),
|
||||
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
||||
'date': fields.datetime('Date'),
|
||||
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
|
||||
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
|
||||
'canal_id': fields.many2one('res.partner.canal', 'Channel', \
|
||||
help="The channels represent the different communication \
|
||||
modes available with the customer."),
|
||||
'planned_revenue': fields.float('Planned Revenue'),
|
||||
'planned_cost': fields.float('Planned Costs'),
|
||||
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
|
||||
'probability': fields.float('Probability (%)'),
|
||||
modes available with the customer."),
|
||||
'planned_revenue': fields.float('Planned Revenue'),
|
||||
'planned_cost': fields.float('Planned Costs'),
|
||||
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
|
||||
'probability': fields.float('Probability (%)'),
|
||||
'categ_id': fields.many2one('crm.case.categ', 'Category', \
|
||||
domain="[('section_id','=',section_id),\
|
||||
('object_id.model', '=', 'crm.helpdesk')]"),
|
||||
'duration': fields.float('Duration', states={'done': [('readonly', True)]}),
|
||||
'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True,
|
||||
('object_id.model', '=', 'crm.helpdesk')]"),
|
||||
'duration': fields.float('Duration', states={'done': [('readonly', True)]}),
|
||||
'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True,
|
||||
help='The state is set to \'Draft\', when a case is created.\
|
||||
\nIf the case is in progress the state is set to \'Open\'.\
|
||||
\nWhen the case is over, the state is set to \'Done\'.\
|
||||
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
|
||||
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
'message_ids': fields.one2many('email.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'active': lambda *a: 1,
|
||||
'user_id': crm.crm_case._get_default_user,
|
||||
'partner_id': crm.crm_case._get_default_partner,
|
||||
'partner_address_id': crm.crm_case._get_default_partner_address,
|
||||
'email_from': crm.crm_case. _get_default_email,
|
||||
'state': lambda *a: 'draft',
|
||||
'active': lambda *a: 1,
|
||||
'user_id': crm.crm_case._get_default_user,
|
||||
'partner_id': crm.crm_case._get_default_partner,
|
||||
'partner_address_id': crm.crm_case._get_default_partner_address,
|
||||
'email_from': crm.crm_case. _get_default_email,
|
||||
'state': lambda *a: 'draft',
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'section_id': crm.crm_case. _get_section,
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c),
|
||||
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
|
||||
'section_id': crm.crm_case. _get_section,
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c),
|
||||
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
|
||||
}
|
||||
|
||||
crm_helpdesk()
|
||||
|
|
|
@ -56,7 +56,7 @@ class crm_helpdesk_report(osv.osv):
|
|||
'date_deadline': fields.date('Deadline', select=True),
|
||||
'priority': fields.selection([('5', 'Lowest'), ('4', 'Low'), \
|
||||
('3', 'Normal'), ('2', 'High'), ('1', 'Highest')], 'Priority'),
|
||||
'canal_id': fields.many2one('res.partner.canal', 'Channel'),
|
||||
'canal_id': fields.many2one('res.partner.canal', 'Channel'),
|
||||
'categ_id': fields.many2one('crm.case.categ', 'Category', \
|
||||
domain="[('section_id','=',section_id),\
|
||||
('object_id.model', '=', 'crm.helpdesk')]"),
|
||||
|
@ -97,7 +97,7 @@ class crm_helpdesk_report(osv.osv):
|
|||
c.planned_cost,
|
||||
count(*) as nbr,
|
||||
extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as delay_close,
|
||||
(SELECT count(id) FROM mailgate_message WHERE model='crm.helpdesk' AND res_id=c.id AND history=True) AS email,
|
||||
(SELECT count(id) FROM email_message WHERE model='crm.helpdesk' AND res_id=c.id AND history=True) AS email,
|
||||
abs(avg(extract('epoch' from (c.date_deadline - c.date_closed)))/(3600*24)) as delay_expected
|
||||
from
|
||||
crm_helpdesk c
|
||||
|
|
|
@ -69,7 +69,7 @@ class crm_lead_forward_to_partner(osv.osv_memory):
|
|||
@param hist_id: Id of latest history
|
||||
@param context: A standard dictionary for contextual values
|
||||
"""
|
||||
log_pool = self.pool.get('mailgate.message')
|
||||
log_pool = self.pool.get('email.message')
|
||||
hist = log_pool.browse(cr, uid, hist_id, context=context)
|
||||
header = '-------- Original Message --------'
|
||||
sender = 'From: %s' %(hist.email_from or '')
|
||||
|
@ -87,7 +87,7 @@ class crm_lead_forward_to_partner(osv.osv_memory):
|
|||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of Mail’s IDs
|
||||
@param user: Changed User id
|
||||
@param partner: Changed Partner id
|
||||
@param partner: Changed Partner id
|
||||
"""
|
||||
if not user:
|
||||
return {'value': {'email_to': False}}
|
||||
|
@ -146,7 +146,7 @@ class crm_lead_forward_to_partner(osv.osv_memory):
|
|||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of Mail’s IDs
|
||||
@param user: Changed User id
|
||||
@param partner: Changed Partner id
|
||||
@param partner: Changed Partner id
|
||||
"""
|
||||
if not partner_id:
|
||||
return {'value' : {'email_to' : False, 'address_id': False}}
|
||||
|
@ -155,7 +155,7 @@ class crm_lead_forward_to_partner(osv.osv_memory):
|
|||
data = {'address_id': addr['contact']}
|
||||
data.update(self.on_change_address(cr, uid, ids, addr['contact'])['value'])
|
||||
return {
|
||||
'value' : data,
|
||||
'value' : data,
|
||||
'domain' : {'address_id' : partner_id and "[('partner_id', '=', partner_id)]" or "[]"}
|
||||
}
|
||||
|
||||
|
@ -231,22 +231,22 @@ class crm_lead_forward_to_partner(osv.osv_memory):
|
|||
elif lead.type == 'opportunity':
|
||||
pa = lead.partner_address_id
|
||||
body = [
|
||||
"Partner: %s" % (lead.partner_id and lead.partner_id.name_get()[0][1]),
|
||||
"Contact: %s" % (pa.name or ''),
|
||||
"Title: %s" % (pa.title or ''),
|
||||
"Function: %s" % (pa.function or ''),
|
||||
"Street: %s" % (pa.street or ''),
|
||||
"Street2: %s" % (pa.street2 or ''),
|
||||
"Zip: %s" % (pa.zip or ''),
|
||||
"City: %s" % (pa.city or ''),
|
||||
"Country: %s" % (pa.country_id and pa.country_id.name_get()[0][1] or ''),
|
||||
"State: %s" % (pa.state_id and pa.state_id.name_get()[0][1] or ''),
|
||||
"Email: %s" % (pa.email or ''),
|
||||
"Phone: %s" % (pa.phone or ''),
|
||||
"Fax: %s" % (pa.fax or ''),
|
||||
"Mobile: %s" % (pa.mobile or ''),
|
||||
"Lead Category: %s" % (lead.categ_id and lead.categ_id.name or ''),
|
||||
"Details: %s" % (lead.description or ''),
|
||||
"Partner: %s" % (lead.partner_id and lead.partner_id.name_get()[0][1]),
|
||||
"Contact: %s" % (pa.name or ''),
|
||||
"Title: %s" % (pa.title or ''),
|
||||
"Function: %s" % (pa.function or ''),
|
||||
"Street: %s" % (pa.street or ''),
|
||||
"Street2: %s" % (pa.street2 or ''),
|
||||
"Zip: %s" % (pa.zip or ''),
|
||||
"City: %s" % (pa.city or ''),
|
||||
"Country: %s" % (pa.country_id and pa.country_id.name_get()[0][1] or ''),
|
||||
"State: %s" % (pa.state_id and pa.state_id.name_get()[0][1] or ''),
|
||||
"Email: %s" % (pa.email or ''),
|
||||
"Phone: %s" % (pa.phone or ''),
|
||||
"Fax: %s" % (pa.fax or ''),
|
||||
"Mobile: %s" % (pa.mobile or ''),
|
||||
"Lead Category: %s" % (lead.categ_id and lead.categ_id.name or ''),
|
||||
"Details: %s" % (lead.description or ''),
|
||||
]
|
||||
return "\n".join(body + ['---'])
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import mail_gateway
|
||||
import res_partner
|
||||
import email_gateway
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -28,17 +28,14 @@
|
|||
* Easy Integration with any Module""",
|
||||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'depends': ['base'],
|
||||
'depends': ['base','emails'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
"mail_gateway_view.xml",
|
||||
"res_partner_view.xml",
|
||||
'security/ir.model.access.csv'
|
||||
|
||||
"email_gateway_view.xml",
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'demo_xml': [],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
'certificate': '001056784984222247309',
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -42,7 +42,7 @@ class mailgate_thread(osv.osv):
|
|||
_description = 'Mailgateway Thread'
|
||||
|
||||
_columns = {
|
||||
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', readonly=True),
|
||||
'message_ids': fields.one2many('email.message', 'res_id', 'Messages', readonly=True),
|
||||
}
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
|
@ -123,7 +123,7 @@ class mailgate_thread(osv.osv):
|
|||
cases = self.browse(cr, uid, cases, context=context)
|
||||
|
||||
att_obj = self.pool.get('ir.attachment')
|
||||
obj = self.pool.get('mailgate.message')
|
||||
obj = self.pool.get('email.message')
|
||||
|
||||
for case in cases:
|
||||
attachments = []
|
||||
|
@ -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'
|
||||
|
@ -324,7 +206,7 @@ class mailgate_tool(osv.osv_memory):
|
|||
if isinstance(res_ids, (int, long)):
|
||||
res_ids = [res_ids]
|
||||
|
||||
msg_pool = self.pool.get('mailgate.message')
|
||||
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
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<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="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Mailgateway Thread">
|
||||
<separator string="History" colspan="4"/>
|
||||
<field name="message_ids" nolabel="1" colspan="4" mode="tree,form">
|
||||
<tree string="Mailgateway History">
|
||||
<field name="display_text"/>
|
||||
</tree>
|
||||
<form string="Mailgate History">
|
||||
<field name="name" widget="char"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id"/>
|
||||
<field name="message_id"/>
|
||||
<field name="history"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Email Details">
|
||||
<group col="4" colspan="4">
|
||||
<separator string="Email Details" colspan="4"/>
|
||||
<field name="email_from"/>
|
||||
<field name="email_to"/>
|
||||
<field name="email_cc"/>
|
||||
<field name="email_bcc"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Attachments">
|
||||
<separator string="Attachments" colspan="4"/>
|
||||
<field name="attachment_ids" nolabel="1" colspan="4" />
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</form>
|
||||
</field>
|
||||
</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="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Mailgateway Thread">
|
||||
<field name="message_ids" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 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="view_mode">tree,form</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_mailgate_thread_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>
|
||||
<field name="view_id" ref="view_mailgate_thread_tree"/>
|
||||
<field name="act_window_id" ref="action_view_mailgate_thread"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="action_view_mailgate_thread_view2">
|
||||
<field name="sequence" eval="2"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_mailgate_thread_form"/>
|
||||
<field name="act_window_id" ref="action_view_mailgate_thread"/>
|
||||
</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>
|
||||
<field name="view_id" ref="view_mailgate_thread_tree"/>
|
||||
<field name="act_window_id" ref="action_view_mailgate_thread"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="action_view_mailgate_thread_view2">
|
||||
<field name="sequence" eval="2"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_mailgate_thread_form"/>
|
||||
<field name="act_window_id" ref="action_view_mailgate_thread"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +1,2 @@
|
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_mailgate_thread","mailgate.thread","model_mailgate_thread",,1,0,0,0
|
|
|
@ -20,8 +20,8 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import email_template_account
|
||||
import email_template
|
||||
import email_template_mailbox
|
||||
import wizard
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -26,17 +26,15 @@
|
|||
"author" : "Openlabs",
|
||||
"website" : "http://openerp.com",
|
||||
"category" : "Added functionality",
|
||||
"depends" : ['marketing', 'base_tools'],
|
||||
"depends" : [ 'emails'],
|
||||
"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',
|
||||
'email_template_workflow.xml',
|
||||
'email_template_account_view.xml',
|
||||
'wizard/email_template_preview_view.xml',
|
||||
'email_template_view.xml',
|
||||
'email_template_mailbox_view.xml',
|
||||
'wizard/email_template_send_wizard_view.xml',
|
||||
'security/ir.model.access.csv'
|
||||
],
|
||||
|
|
|
@ -20,37 +20,21 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
import base64
|
||||
import random
|
||||
import netsvc
|
||||
import logging
|
||||
import re
|
||||
|
||||
TEMPLATE_ENGINES = []
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
import tools
|
||||
import pooler
|
||||
|
||||
try:
|
||||
from mako.template import Template as MakoTemplate
|
||||
TEMPLATE_ENGINES.append(('mako', 'Mako Templates'))
|
||||
except ImportError:
|
||||
logging.getLogger('init').warning("module email_template: Mako templates not installed")
|
||||
|
||||
try:
|
||||
from django.template import Context, Template as DjangoTemplate
|
||||
#Workaround for bug:
|
||||
#http://code.google.com/p/django-tagging/issues/detail?id=110
|
||||
from django.conf import settings
|
||||
settings.configure()
|
||||
#Workaround ends
|
||||
TEMPLATE_ENGINES.append(('django', 'Django Template'))
|
||||
except ImportError:
|
||||
logging.getLogger('init').warning("module email_template: Django templates not installed")
|
||||
|
||||
import tools
|
||||
import pooler
|
||||
import logging
|
||||
|
||||
def get_value(cursor, user, recid, message=None, template=None, context=None):
|
||||
"""
|
||||
|
@ -74,18 +58,9 @@ def get_value(cursor, user, recid, message=None, template=None, context=None):
|
|||
env = {
|
||||
'user':pool.get('res.users').browse(cursor, user, user, context=context),
|
||||
'db':cursor.dbname
|
||||
}
|
||||
if template.template_language == 'mako':
|
||||
templ = MakoTemplate(message, input_encoding='utf-8')
|
||||
reply = MakoTemplate(message).render_unicode(object=object,
|
||||
peobject=object,
|
||||
env=env,
|
||||
format_exceptions=True)
|
||||
elif template.template_language == 'django':
|
||||
templ = DjangoTemplate(message)
|
||||
env['object'] = object
|
||||
env['peobject'] = object
|
||||
reply = templ.render(Context(env))
|
||||
}
|
||||
templ = MakoTemplate(message, input_encoding='utf-8')
|
||||
reply = MakoTemplate(message).render_unicode(object=object, peobject=object, env=env, format_exceptions=True)
|
||||
return reply or False
|
||||
except Exception:
|
||||
logging.exception("can't render %r", message)
|
||||
|
@ -100,24 +75,17 @@ class email_template(osv.osv):
|
|||
_description = 'Email Templates for Models'
|
||||
|
||||
def change_model(self, cursor, user, ids, object_name, context=None):
|
||||
mod_name = False
|
||||
if object_name:
|
||||
mod_name = self.pool.get('ir.model').read(
|
||||
cursor,
|
||||
user,
|
||||
object_name,
|
||||
['model'], context)['model']
|
||||
else:
|
||||
mod_name = False
|
||||
return {
|
||||
'value':{'model_int_name':mod_name}
|
||||
}
|
||||
mod_name = self.pool.get('ir.model').browse(cursor, user, object_name, context).model
|
||||
return {'value':{'model_int_name':mod_name}}
|
||||
|
||||
_columns = {
|
||||
'name' : fields.char('Name', size=100, required=True),
|
||||
'object_name':fields.many2one('ir.model', 'Resource'),
|
||||
'model_int_name':fields.char('Model Internal Name', size=200,),
|
||||
'from_account':fields.many2one(
|
||||
'email_template.account',
|
||||
'email.smtp_server',
|
||||
string="Email Account",
|
||||
help="Emails will be sent from this approved account."),
|
||||
'def_to':fields.char(
|
||||
|
@ -245,17 +213,7 @@ This is useful for CRM leads for example"),
|
|||
help="Copy this html code to your HTML message"
|
||||
" body for displaying the info in your mail.",
|
||||
store=False),
|
||||
#Template language(engine eg.Mako) specifics
|
||||
'template_language':fields.selection(
|
||||
TEMPLATE_ENGINES,
|
||||
'Templating Language',
|
||||
required=True
|
||||
)
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'template_language' : lambda *a:'mako',
|
||||
|
||||
'auto_delete': fields.boolean('Auto Delete', help="Permanently delete emails after sending"),
|
||||
}
|
||||
|
||||
_sql_constraints = [
|
||||
|
@ -266,31 +224,32 @@ This is useful for CRM leads for example"),
|
|||
vals = {}
|
||||
if context is None:
|
||||
context = {}
|
||||
template_obj = self.browse(cr, uid, ids, context=context)[0]
|
||||
src_obj = template_obj.object_name.model
|
||||
vals['ref_ir_act_window'] = self.pool.get('ir.actions.act_window').create(cr, uid, {
|
||||
'name': template_obj.name,
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'email_template.send.wizard',
|
||||
'src_model': src_obj,
|
||||
'view_type': 'form',
|
||||
'context': "{'src_model':'%s','template_id':'%d','src_rec_id':active_id,'src_rec_ids':active_ids}" % (src_obj, template_obj.id),
|
||||
'view_mode':'form,tree',
|
||||
'view_id': self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'email_template.send.wizard.form')], context=context)[0],
|
||||
'target': 'new',
|
||||
'auto_refresh':1
|
||||
}, context)
|
||||
vals['ref_ir_value'] = self.pool.get('ir.values').create(cr, uid, {
|
||||
'name': _('Send Mail (%s)') % template_obj.name,
|
||||
'model': src_obj,
|
||||
'key2': 'client_action_multi',
|
||||
'value': "ir.actions.act_window," + str(vals['ref_ir_act_window']),
|
||||
'object': True,
|
||||
}, context)
|
||||
action_obj = self.pool.get('ir.actions.act_window')
|
||||
for template in self.browse(cr, uid, ids, context=context):
|
||||
src_obj = template.object_name.model
|
||||
vals['ref_ir_act_window'] = action_obj.create(cr, uid, {
|
||||
'name': template.name,
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'email_template.send.wizard',
|
||||
'src_model': src_obj,
|
||||
'view_type': 'form',
|
||||
'context': "{'src_model':'%s','template_id':'%d','src_rec_id':active_id,'src_rec_ids':active_ids}" % (src_obj, template.id),
|
||||
'view_mode':'form,tree',
|
||||
'view_id': self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'email_template.send.wizard.form')], context=context)[0],
|
||||
'target': 'new',
|
||||
'auto_refresh':1
|
||||
}, context)
|
||||
vals['ref_ir_value'] = self.pool.get('ir.values').create(cr, uid, {
|
||||
'name': _('Send Mail (%s)') % template.name,
|
||||
'model': src_obj,
|
||||
'key2': 'client_action_multi',
|
||||
'value': "ir.actions.act_window," + str(vals['ref_ir_act_window']),
|
||||
'object': True,
|
||||
}, context)
|
||||
self.write(cr, uid, ids, {
|
||||
'ref_ir_act_window': vals['ref_ir_act_window'],
|
||||
'ref_ir_value': vals['ref_ir_value'],
|
||||
}, context)
|
||||
'ref_ir_act_window': vals.get('ref_ir_act_window',False),
|
||||
'ref_ir_value': vals.get('ref_ir_value',False),
|
||||
}, context)
|
||||
return True
|
||||
|
||||
def unlink_action(self, cr, uid, ids, context=None):
|
||||
|
@ -323,125 +282,128 @@ This is useful for CRM leads for example"),
|
|||
default.update({'name':new_name})
|
||||
return super(email_template, self).copy(cr, uid, id, default, context)
|
||||
|
||||
def build_expression(self, field_name, sub_field_name, null_value, template_language='mako'):
|
||||
def build_expression(self, field_name, sub_field_name, null_value):
|
||||
"""
|
||||
Returns a template expression based on data provided
|
||||
@param field_name: field name
|
||||
@param sub_field_name: sub field name (M2O)
|
||||
@param null_value: default value if the target value is empty
|
||||
@param template_language: name of template engine
|
||||
@return: computed expression
|
||||
"""
|
||||
|
||||
expression = ''
|
||||
if template_language == 'mako':
|
||||
if field_name:
|
||||
expression = "${object." + field_name
|
||||
if sub_field_name:
|
||||
expression += "." + sub_field_name
|
||||
if null_value:
|
||||
expression += " or '''%s'''" % null_value
|
||||
expression += "}"
|
||||
elif template_language == 'django':
|
||||
if field_name:
|
||||
expression = "{{object." + field_name
|
||||
if sub_field_name:
|
||||
expression += "." + sub_field_name
|
||||
if null_value:
|
||||
expression += "|default: '''%s'''" % null_value
|
||||
expression += "}}"
|
||||
if field_name:
|
||||
expression = "${object." + field_name
|
||||
if sub_field_name:
|
||||
expression += "." + sub_field_name
|
||||
if null_value:
|
||||
expression += " or '''%s'''" % null_value
|
||||
expression += "}"
|
||||
return expression
|
||||
#
|
||||
# def onchange_model_object_field(self, cr, uid, ids, model_object_field, context=None):
|
||||
# if not model_object_field:
|
||||
# return {}
|
||||
# result = {}
|
||||
# field_obj = self.pool.get('ir.model.fields').browse(cr, uid, model_object_field, context)
|
||||
# #Check if field is relational
|
||||
# if field_obj.ttype in ['many2one', 'one2many', 'many2many']:
|
||||
# res_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', field_obj.relation)], context=context)
|
||||
# if res_ids:
|
||||
# result['sub_object'] = res_ids[0]
|
||||
# result['copyvalue'] = self.build_expression(False, False, False)
|
||||
# result['sub_model_object_field'] = False
|
||||
# result['null_value'] = False
|
||||
# else:
|
||||
# #Its a simple field... just compute placeholder
|
||||
# result['sub_object'] = False
|
||||
# result['copyvalue'] = self.build_expression(field_obj.name, False, False)
|
||||
# result['sub_model_object_field'] = False
|
||||
# result['null_value'] = False
|
||||
# return {'value':result}
|
||||
#
|
||||
# def onchange_sub_model_object_field(self, cr, uid, ids, model_object_field, sub_model_object_field, context=None):
|
||||
# if not model_object_field or not sub_model_object_field:
|
||||
# return {}
|
||||
# result = {}
|
||||
# field_obj = self.pool.get('ir.model.fields').browse(cr, uid, model_object_field, context)
|
||||
# if field_obj.ttype in ['many2one', 'one2many', 'many2many']:
|
||||
# res_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', field_obj.relation)], context=context)
|
||||
# sub_field_obj = self.pool.get('ir.model.fields').browse(cr, uid, sub_model_object_field, context)
|
||||
# if res_ids:
|
||||
# result['sub_object'] = res_ids[0]
|
||||
# result['copyvalue'] = self.build_expression(field_obj.name, sub_field_obj.name, False)
|
||||
# result['sub_model_object_field'] = sub_model_object_field
|
||||
# result['null_value'] = False
|
||||
# else:
|
||||
# #Its a simple field... just compute placeholder
|
||||
# result['sub_object'] = False
|
||||
# result['copyvalue'] = self.build_expression(field_obj.name, False, False)
|
||||
# result['sub_model_object_field'] = False
|
||||
# result['null_value'] = False
|
||||
# return {'value':result}
|
||||
#
|
||||
#
|
||||
# def onchange_null_value(self, cr, uid, ids, model_object_field, sub_model_object_field, null_value, template_language, context=None):
|
||||
# if not model_object_field and not null_value:
|
||||
# return {}
|
||||
# result = {}
|
||||
# field_obj = self.pool.get('ir.model.fields').browse(cr, uid, model_object_field, context)
|
||||
# if field_obj.ttype in ['many2one', 'one2many', 'many2many']:
|
||||
# res_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', field_obj.relation)], context=context)
|
||||
# sub_field_obj = self.pool.get('ir.model.fields').browse(cr, uid, sub_model_object_field, context)
|
||||
# if res_ids:
|
||||
# result['sub_object'] = res_ids[0]
|
||||
# result['copyvalue'] = self.build_expression(field_obj.name,
|
||||
# sub_field_obj.name,
|
||||
# null_value,
|
||||
# template_language
|
||||
# )
|
||||
# result['sub_model_object_field'] = sub_model_object_field
|
||||
# result['null_value'] = null_value
|
||||
# else:
|
||||
# #Its a simple field... just compute placeholder
|
||||
# result['sub_object'] = False
|
||||
# result['copyvalue'] = self.build_expression(field_obj.name,
|
||||
# False,
|
||||
# null_value,
|
||||
# template_language
|
||||
# )
|
||||
# result['sub_model_object_field'] = False
|
||||
# result['null_value'] = null_value
|
||||
# return {'value':result}
|
||||
|
||||
def onchange_model_object_field(self, cr, uid, ids, model_object_field, template_language, context=None):
|
||||
if not model_object_field:
|
||||
return {}
|
||||
result = {}
|
||||
field_obj = self.pool.get('ir.model.fields').browse(cr, uid, model_object_field, context)
|
||||
#Check if field is relational
|
||||
if field_obj.ttype in ['many2one', 'one2many', 'many2many']:
|
||||
res_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', field_obj.relation)], context=context)
|
||||
if res_ids:
|
||||
result['sub_object'] = res_ids[0]
|
||||
result['copyvalue'] = self.build_expression(False,
|
||||
False,
|
||||
False,
|
||||
template_language)
|
||||
result['sub_model_object_field'] = False
|
||||
result['null_value'] = False
|
||||
else:
|
||||
#Its a simple field... just compute placeholder
|
||||
result['sub_object'] = False
|
||||
result['copyvalue'] = self.build_expression(field_obj.name,
|
||||
False,
|
||||
False,
|
||||
template_language
|
||||
)
|
||||
result['sub_model_object_field'] = False
|
||||
result['null_value'] = False
|
||||
return {'value':result}
|
||||
|
||||
def onchange_sub_model_object_field(self, cr, uid, ids, model_object_field, sub_model_object_field, template_language, context=None):
|
||||
if not model_object_field or not sub_model_object_field:
|
||||
return {}
|
||||
result = {}
|
||||
field_obj = self.pool.get('ir.model.fields').browse(cr, uid, model_object_field, context)
|
||||
if field_obj.ttype in ['many2one', 'one2many', 'many2many']:
|
||||
res_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', field_obj.relation)], context=context)
|
||||
sub_field_obj = self.pool.get('ir.model.fields').browse(cr, uid, sub_model_object_field, context)
|
||||
if res_ids:
|
||||
result['sub_object'] = res_ids[0]
|
||||
result['copyvalue'] = self.build_expression(field_obj.name,
|
||||
sub_field_obj.name,
|
||||
False,
|
||||
template_language
|
||||
)
|
||||
result['sub_model_object_field'] = sub_model_object_field
|
||||
result['null_value'] = False
|
||||
else:
|
||||
#Its a simple field... just compute placeholder
|
||||
result['sub_object'] = False
|
||||
result['copyvalue'] = self.build_expression(field_obj.name,
|
||||
False,
|
||||
False,
|
||||
template_language
|
||||
)
|
||||
result['sub_model_object_field'] = False
|
||||
result['null_value'] = False
|
||||
return {'value':result}
|
||||
|
||||
def onchange_null_value(self, cr, uid, ids, model_object_field, sub_model_object_field, null_value, template_language, context=None):
|
||||
if not model_object_field and not null_value:
|
||||
return {}
|
||||
result = {}
|
||||
field_obj = self.pool.get('ir.model.fields').browse(cr, uid, model_object_field, context)
|
||||
if field_obj.ttype in ['many2one', 'one2many', 'many2many']:
|
||||
res_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', field_obj.relation)], context=context)
|
||||
sub_field_obj = self.pool.get('ir.model.fields').browse(cr, uid, sub_model_object_field, context)
|
||||
if res_ids:
|
||||
result['sub_object'] = res_ids[0]
|
||||
result['copyvalue'] = self.build_expression(field_obj.name,
|
||||
sub_field_obj.name,
|
||||
null_value,
|
||||
template_language
|
||||
)
|
||||
result['sub_model_object_field'] = sub_model_object_field
|
||||
result['null_value'] = null_value
|
||||
else:
|
||||
#Its a simple field... just compute placeholder
|
||||
result['sub_object'] = False
|
||||
result['copyvalue'] = self.build_expression(field_obj.name,
|
||||
False,
|
||||
null_value,
|
||||
template_language
|
||||
)
|
||||
result['sub_model_object_field'] = False
|
||||
result['null_value'] = null_value
|
||||
def onchange_sub_model_object_value_field(self, cr, uid, ids, model_object_field, sub_model_object_field=False, null_value=None, context=None):
|
||||
result = {
|
||||
'sub_object': False,
|
||||
'copyvalue': False,
|
||||
'sub_model_object_field': False,
|
||||
'null_value': False
|
||||
}
|
||||
if model_object_field:
|
||||
fields_obj = self.pool.get('ir.model.fields')
|
||||
field_value = fields_obj.browse(cr, uid, model_object_field, context)
|
||||
if field_value.ttype in ['many2one', 'one2many', 'many2many']:
|
||||
res_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', field_value.relation)], context=context)
|
||||
sub_field_value = False
|
||||
if sub_model_object_field:
|
||||
sub_field_value = fields_obj.browse(cr, uid, sub_model_object_field, context)
|
||||
if res_ids:
|
||||
result.update({
|
||||
'sub_object': res_ids[0],
|
||||
'copyvalue': self.build_expression(field_value.name, sub_field_value and sub_field_value.name or False, null_value or False),
|
||||
'sub_model_object_field': sub_model_object_field or False,
|
||||
'null_value': null_value or False
|
||||
})
|
||||
else:
|
||||
result.update({
|
||||
'copyvalue': self.build_expression(field_value.name, False, null_value or False),
|
||||
'null_value': null_value or False
|
||||
})
|
||||
return {'value':result}
|
||||
|
||||
def _add_attachment(self, cursor, user, mailbox_id, name, data, filename, context=None):
|
||||
"""
|
||||
Add an attachment to a given mailbox entry.
|
||||
|
||||
:param data: base64 encoded attachment data to store
|
||||
"""
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
|
@ -450,31 +412,19 @@ This is useful for CRM leads for example"),
|
|||
'datas': data,
|
||||
'datas_fname': filename,
|
||||
'description': name or _('No Description'),
|
||||
'res_model':'email_template.mailbox',
|
||||
'res_model':'email.message',
|
||||
'res_id': mailbox_id,
|
||||
}
|
||||
attachment_id = attachment_obj.create(cursor,
|
||||
user,
|
||||
attachment_data,
|
||||
context)
|
||||
attachment_id = attachment_obj.create(cursor, user, attachment_data, context)
|
||||
if attachment_id:
|
||||
self.pool.get('email_template.mailbox').write(
|
||||
cursor,
|
||||
user,
|
||||
mailbox_id,
|
||||
self.pool.get('email.message').write(cursor, user, mailbox_id,
|
||||
{
|
||||
'attachments_ids':[(4, attachment_id)],
|
||||
'mail_type':'multipart/mixed'
|
||||
},
|
||||
context)
|
||||
|
||||
def generate_attach_reports(self,
|
||||
cursor,
|
||||
user,
|
||||
template,
|
||||
record_id,
|
||||
mail,
|
||||
context=None):
|
||||
def generate_attach_reports(self, cursor, user, template, record_id, mail, context=None):
|
||||
"""
|
||||
Generate report to be attached and attach it
|
||||
to the email, and add any directly attached files as well.
|
||||
|
@ -490,21 +440,12 @@ This is useful for CRM leads for example"),
|
|||
@return: True
|
||||
"""
|
||||
if template.report_template:
|
||||
reportname = 'report.' + \
|
||||
self.pool.get('ir.actions.report.xml').read(
|
||||
cursor,
|
||||
user,
|
||||
template.report_template.id,
|
||||
['report_name'],
|
||||
context)['report_name']
|
||||
reportname = 'report.' + self.pool.get('ir.actions.report.xml').browse(cursor,
|
||||
user, template.report_template.id, context).report_name
|
||||
service = netsvc.LocalService(reportname)
|
||||
data = {}
|
||||
data['model'] = template.model_int_name
|
||||
(result, format) = service.create(cursor,
|
||||
user,
|
||||
[record_id],
|
||||
data,
|
||||
context)
|
||||
(result, format) = service.create(cursor, user, [record_id], data, context)
|
||||
fname = tools.ustr(get_value(cursor, user, record_id,
|
||||
template.file_name, template, context)
|
||||
or 'Report')
|
||||
|
@ -519,12 +460,7 @@ This is useful for CRM leads for example"),
|
|||
|
||||
return True
|
||||
|
||||
def _generate_mailbox_item_from_template(self,
|
||||
cursor,
|
||||
user,
|
||||
template,
|
||||
record_id,
|
||||
context=None):
|
||||
def _generate_mailbox_item_from_template(self, cursor, user, template, record_id, context=None):
|
||||
"""
|
||||
Generates an email from the template for
|
||||
record record_id of target object
|
||||
|
@ -542,25 +478,14 @@ This is useful for CRM leads for example"),
|
|||
context = {}
|
||||
#If account to send from is in context select it, else use enforced account
|
||||
if 'account_id' in context.keys():
|
||||
from_account = self.pool.get('email_template.account').read(
|
||||
cursor,
|
||||
user,
|
||||
context.get('account_id'),
|
||||
['name', 'email_id'],
|
||||
context
|
||||
)
|
||||
from_account = self.pool.get('email.smtp_server').read(cursor, user, context.get('account_id'), ['name', 'email_id'], context)
|
||||
else:
|
||||
from_account = {
|
||||
'id':template.from_account.id,
|
||||
'name':template.from_account.name,
|
||||
'email_id':template.from_account.email_id
|
||||
}
|
||||
lang = get_value(cursor,
|
||||
user,
|
||||
record_id,
|
||||
template.lang,
|
||||
template,
|
||||
context)
|
||||
lang = get_value(cursor, user, record_id, template.lang, template, context)
|
||||
if lang:
|
||||
ctx = context.copy()
|
||||
ctx.update({'lang':lang})
|
||||
|
@ -622,11 +547,11 @@ This is useful for CRM leads for example"),
|
|||
template.def_body_html,
|
||||
template,
|
||||
context),
|
||||
'account_id' :from_account['id'],
|
||||
#This is a mandatory field when automatic emails are sent
|
||||
'state':'na',
|
||||
'folder':'drafts',
|
||||
'mail_type':'multipart/alternative',
|
||||
'template_id': template.id
|
||||
}
|
||||
|
||||
if template['message_id']:
|
||||
|
@ -636,187 +561,55 @@ This is useful for CRM leads for example"),
|
|||
elif template['track_campaign_item']:
|
||||
# get appropriate message-id
|
||||
mailbox_values.update({'message_id': tools.misc.generate_tracking_message_id(record_id)})
|
||||
|
||||
if not mailbox_values['account_id']:
|
||||
raise Exception("Unable to send the mail. No account linked to the template.")
|
||||
#
|
||||
# if not mailbox_values['account_id']:
|
||||
# raise Exception("Unable to send the mail. No account linked to the template.")
|
||||
#Use signatures if allowed
|
||||
if template.use_sign:
|
||||
sign = self.pool.get('res.users').read(cursor,
|
||||
user,
|
||||
user,
|
||||
['signature'],
|
||||
context)['signature']
|
||||
sign = self.pool.get('res.users').read(cursor, user, user, ['signature'], context)['signature']
|
||||
if mailbox_values['body_text']:
|
||||
mailbox_values['body_text'] += sign
|
||||
if mailbox_values['body_html']:
|
||||
mailbox_values['body_html'] += sign
|
||||
mailbox_id = self.pool.get('email_template.mailbox').create(
|
||||
cursor,
|
||||
user,
|
||||
mailbox_values,
|
||||
context)
|
||||
mailbox_id = self.pool.get('email.message').create(cursor, user, mailbox_values, context)
|
||||
|
||||
return mailbox_id
|
||||
|
||||
|
||||
def generate_mail(self,
|
||||
cursor,
|
||||
user,
|
||||
template_id,
|
||||
record_ids,
|
||||
context=None):
|
||||
def generate_mail(self, cursor, user, template_id, record_ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
template = self.browse(cursor, user, template_id, context=context)
|
||||
if not template:
|
||||
raise Exception("The requested template could not be loaded")
|
||||
result = True
|
||||
mailbox_obj = self.pool.get('email_template.mailbox')
|
||||
mailbox_obj = self.pool.get('email.message')
|
||||
for record_id in record_ids:
|
||||
mailbox_id = self._generate_mailbox_item_from_template(
|
||||
cursor,
|
||||
user,
|
||||
template,
|
||||
record_id,
|
||||
context)
|
||||
mail = mailbox_obj.browse(
|
||||
cursor,
|
||||
user,
|
||||
mailbox_id,
|
||||
context=context
|
||||
)
|
||||
mailbox_id = self._generate_mailbox_item_from_template(cursor, user, template, record_id, context)
|
||||
mail = mailbox_obj.browse(cursor, user, mailbox_id, context=context)
|
||||
if template.report_template or template.attachment_ids:
|
||||
self.generate_attach_reports(
|
||||
cursor,
|
||||
user,
|
||||
template,
|
||||
record_id,
|
||||
mail,
|
||||
context
|
||||
)
|
||||
|
||||
self.pool.get('email_template.mailbox').write(
|
||||
cursor,
|
||||
user,
|
||||
mailbox_id,
|
||||
{'folder':'outbox'},
|
||||
context=context
|
||||
)
|
||||
# TODO : manage return value of all the records
|
||||
result = self.pool.get('email_template.mailbox').send_this_mail(cursor, user, [mailbox_id], context)
|
||||
self.generate_attach_reports(cursor, user, template, record_id, mail, context )
|
||||
mailbox_obj.write(cursor, user, mailbox_id, {'folder':'outbox', 'state': 'waiting'}, context=context)
|
||||
return result
|
||||
|
||||
email_template()
|
||||
|
||||
class email_message(osv.osv):
|
||||
_inherit = 'email.message'
|
||||
_columns = {
|
||||
'template_id': fields.many2one('email.template', 'Email-Template', readonly=True),
|
||||
}
|
||||
|
||||
## FIXME: this class duplicates a lot of features of the email template send wizard,
|
||||
## one of the 2 should inherit from the other!
|
||||
|
||||
class email_template_preview(osv.osv_memory):
|
||||
_name = "email_template.preview"
|
||||
_description = "Email Template Preview"
|
||||
|
||||
def _get_model_recs(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
#Fills up the selection box which allows records from the selected object to be displayed
|
||||
self.context = context
|
||||
if 'template_id' in context:
|
||||
ref_obj_id = self.pool.get('email.template').read(cr, uid, context['template_id'], ['object_name'], context)
|
||||
ref_obj_name = self.pool.get('ir.model').read(cr, uid, ref_obj_id['object_name'][0], ['model'], context)['model']
|
||||
model_obj = self.pool.get(ref_obj_name)
|
||||
ref_obj_ids = model_obj.search(cr, uid, [], 0, 20, 'id', context=context)
|
||||
if not ref_obj_ids:
|
||||
ref_obj_ids = []
|
||||
|
||||
# also add the default one if requested, otherwise it won't be available for selection:
|
||||
default_id = context.get('default_rel_model_ref')
|
||||
if default_id and default_id not in ref_obj_ids:
|
||||
ref_obj_ids.insert(0, default_id)
|
||||
return model_obj.name_get(cr, uid, ref_obj_ids, context)
|
||||
return []
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = super(email_template_preview, self).default_get(cr, uid, fields, context=context)
|
||||
if (not fields or 'rel_model_ref' in fields) and 'template_id' in context \
|
||||
and not result.get('rel_model_ref'):
|
||||
selectables = self._get_model_recs(cr, uid, context=context)
|
||||
result['rel_model_ref'] = selectables and selectables[0][0] or False
|
||||
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 _default_model(self, cursor, user, context=None):
|
||||
"""
|
||||
Returns the default value for model field
|
||||
@param cursor: Database Cursor
|
||||
@param user: ID of current user
|
||||
@param context: OpenERP Context
|
||||
"""
|
||||
return self.pool.get('email.template').read(
|
||||
cursor,
|
||||
user,
|
||||
context['template_id'],
|
||||
['object_name'],
|
||||
context).get('object_name', False)
|
||||
|
||||
_columns = {
|
||||
'ref_template':fields.many2one(
|
||||
'email.template',
|
||||
'Template', readonly=True),
|
||||
'rel_model':fields.many2one('ir.model', 'Model', readonly=True),
|
||||
'rel_model_ref':fields.selection(_get_model_recs, 'Referred Document'),
|
||||
'to':fields.char('To', size=250, readonly=True),
|
||||
'cc':fields.char('CC', size=250, readonly=True),
|
||||
'bcc':fields.char('BCC', size=250, readonly=True),
|
||||
'reply_to':fields.char('Reply-To',
|
||||
size=250,
|
||||
help="The address recipients should reply to,"
|
||||
" if different from the From address."
|
||||
" Placeholders can be used here."),
|
||||
'message_id':fields.char('Message-ID',
|
||||
size=250,
|
||||
help="The Message-ID header value, if you need to"
|
||||
"specify it, for example to automatically recognize the replies later."
|
||||
" Placeholders can be used here."),
|
||||
'subject':fields.char('Subject', size=200, readonly=True),
|
||||
'body_text':fields.text('Body', readonly=True),
|
||||
'body_html':fields.text('Body', readonly=True),
|
||||
'report':fields.char('Report Name', size=100, readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'ref_template': lambda self, cr, uid, ctx:ctx['template_id'] or False,
|
||||
'rel_model': _default_model,
|
||||
}
|
||||
def on_change_ref(self, cr, uid, ids, rel_model_ref, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if not rel_model_ref:
|
||||
return {}
|
||||
vals = {}
|
||||
if context == {}:
|
||||
context = self.context
|
||||
template = self.pool.get('email.template').browse(cr, uid, context['template_id'], context)
|
||||
#Search translated template
|
||||
lang = get_value(cr, uid, rel_model_ref, template.lang, template, context)
|
||||
if lang:
|
||||
ctx = context.copy()
|
||||
ctx.update({'lang':lang})
|
||||
template = self.pool.get('email.template').browse(cr, uid, context['template_id'], ctx)
|
||||
vals['to'] = get_value(cr, uid, rel_model_ref, template.def_to, template, context)
|
||||
vals['cc'] = get_value(cr, uid, rel_model_ref, template.def_cc, template, context)
|
||||
vals['bcc'] = get_value(cr, uid, rel_model_ref, template.def_bcc, template, context)
|
||||
vals['reply_to'] = get_value(cr, uid, rel_model_ref, template.reply_to, template, context)
|
||||
if template.message_id:
|
||||
vals['message_id'] = get_value(cr, uid, rel_model_ref, template.message_id, template, context)
|
||||
elif template.track_campaign_item:
|
||||
vals['message_id'] = tools.misc.generate_tracking_message_id(rel_model_ref)
|
||||
vals['subject'] = get_value(cr, uid, rel_model_ref, template.def_subject, template, context)
|
||||
vals['body_text'] = get_value(cr, uid, rel_model_ref, template.def_body_text, template, context)
|
||||
vals['body_html'] = get_value(cr, uid, rel_model_ref, template.def_body_html, template, context)
|
||||
vals['report'] = get_value(cr, uid, rel_model_ref, template.file_name, template, context)
|
||||
return {'value':vals}
|
||||
|
||||
email_template_preview()
|
||||
email_message()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -1,470 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2009 Sharoon Thomas
|
||||
# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
|
||||
#
|
||||
# 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
|
||||
import re
|
||||
import smtplib
|
||||
import base64
|
||||
from email import Encoders
|
||||
from email.mime.base import MIMEBase
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.header import decode_header, Header
|
||||
from email.utils import formatdate
|
||||
import netsvc
|
||||
import datetime
|
||||
from tools.translate import _
|
||||
import tools
|
||||
import logging
|
||||
|
||||
EMAIL_PATTERN = re.compile(r'([^()\[\] ,<:\\>@";]+@[^()\[\] ,<:\\>@";]+)') # See RFC822
|
||||
def extract_emails(emails_str):
|
||||
"""
|
||||
Returns a list of email addresses recognized in a string, ignoring the rest of the string.
|
||||
extract_emails('a@b.com,c@bcom, "John Doe" <d@b.com> , e@b.com') -> ['a@b.com','c@bcom', 'd@b.com', 'e@b.com']"
|
||||
"""
|
||||
return EMAIL_PATTERN.findall(emails_str)
|
||||
|
||||
|
||||
def extract_emails_from_dict(addresses={}):
|
||||
"""
|
||||
Extracts email addresses from a dictionary with comma-separated address string values, handling
|
||||
separately the To, CC, BCC and Reply-To addresses.
|
||||
|
||||
:param addresses: a dictionary of addresses in the form {'To': 'a@b.com,c@bcom; d@b.com;e@b.com' , 'CC': 'e@b.com;f@b.com', ... }
|
||||
:return: a dictionary with a list of separate addresses for each header (To, CC, BCC), with an additional key 'all-recipients'
|
||||
containing all addresses for the 'To', 'CC', 'BCC' entries.
|
||||
"""
|
||||
result = {'all-recipients':[]}
|
||||
keys = ['To', 'CC', 'BCC', 'Reply-To']
|
||||
for each in keys:
|
||||
emails = extract_emails(addresses.get(each, u''))
|
||||
while u'' in emails:
|
||||
emails.remove(u'')
|
||||
result[each] = emails
|
||||
if each != 'Reply-To':
|
||||
result['all-recipients'].extend(emails)
|
||||
return result
|
||||
|
||||
class email_template_account(osv.osv):
|
||||
"""
|
||||
Object to store email account settings
|
||||
"""
|
||||
_name = "email_template.account"
|
||||
_known_content_types = ['multipart/mixed',
|
||||
'multipart/alternative',
|
||||
'multipart/related',
|
||||
'text/plain',
|
||||
'text/html'
|
||||
]
|
||||
_columns = {
|
||||
'name': fields.char('Description',
|
||||
size=64, required=True,
|
||||
readonly=True, select=True,
|
||||
help="The description is used as the Sender name along with the provided From Email, \
|
||||
unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
|
||||
states={'draft':[('readonly', False)]}),
|
||||
'auto_delete': fields.boolean('Auto Delete', size=64, readonly=True,
|
||||
help="Permanently delete emails after sending",
|
||||
states={'draft':[('readonly', False)]}),
|
||||
'user':fields.many2one('res.users',
|
||||
'Related User', required=True,
|
||||
readonly=True, states={'draft':[('readonly', False)]}),
|
||||
'email_id': fields.char('From Email',
|
||||
size=120, required=True,
|
||||
readonly=True, states={'draft':[('readonly', False)]} ,
|
||||
help="eg: 'john@doe.com' or 'John Doe <john@doe.com>'"),
|
||||
'smtpserver': fields.char('Server',
|
||||
size=120, required=True,
|
||||
readonly=True, states={'draft':[('readonly', False)]},
|
||||
help="Enter name of outgoing server, eg: smtp.yourdomain.com"),
|
||||
'smtpport': fields.integer('SMTP Port',
|
||||
size=64, required=True,
|
||||
readonly=True, states={'draft':[('readonly', False)]},
|
||||
help="Enter port number, eg: 25 or 587"),
|
||||
'smtpuname': fields.char('User Name',
|
||||
size=120, required=False,
|
||||
readonly=True, states={'draft':[('readonly', False)]},
|
||||
help="Specify the username if your SMTP server requires authentication, "
|
||||
"otherwise leave it empty."),
|
||||
'smtppass': fields.char('Password',
|
||||
size=120, invisible=True,
|
||||
required=False, readonly=True,
|
||||
states={'draft':[('readonly', False)]}),
|
||||
'smtptls':fields.boolean('TLS',
|
||||
states={'draft':[('readonly', False)]}, readonly=True),
|
||||
|
||||
'smtpssl':fields.boolean('SSL/TLS (only in python 2.6)',
|
||||
states={'draft':[('readonly', False)]}, readonly=True),
|
||||
'send_pref':fields.selection([
|
||||
('html', 'HTML, otherwise Text'),
|
||||
('text', 'Text, otherwise HTML'),
|
||||
('alternative', 'Both HTML & Text (Alternative)'),
|
||||
('mixed', 'Both HTML & Text (Mixed)')
|
||||
], 'Mail Format', required=True),
|
||||
'company':fields.selection([
|
||||
('yes', 'Yes'),
|
||||
('no', 'No')
|
||||
], 'Corporate',
|
||||
readonly=True,
|
||||
help="Select if this mail account does not belong " \
|
||||
"to specific user but to the organization as a whole. " \
|
||||
"eg: info@companydomain.com",
|
||||
required=True, states={
|
||||
'draft':[('readonly', False)]
|
||||
}),
|
||||
|
||||
'state':fields.selection([
|
||||
('draft', 'Initiated'),
|
||||
('suspended', 'Suspended'),
|
||||
('approved', 'Approved')
|
||||
],
|
||||
'State', required=True, readonly=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'name':lambda self, cursor, user, context:self.pool.get(
|
||||
'res.users'
|
||||
).read(
|
||||
cursor,
|
||||
user,
|
||||
user,
|
||||
['name'],
|
||||
context
|
||||
)['name'],
|
||||
'state':lambda * a:'draft',
|
||||
'smtpport':lambda *a:25,
|
||||
'smtpserver':lambda *a:'localhost',
|
||||
'company':lambda *a:'yes',
|
||||
'user':lambda self, cursor, user, context:user,
|
||||
'send_pref':lambda *a: 'html',
|
||||
'smtptls':lambda *a:True,
|
||||
}
|
||||
|
||||
_sql_constraints = [
|
||||
(
|
||||
'email_uniq',
|
||||
'unique (email_id)',
|
||||
'Another setting already exists with this email ID !')
|
||||
]
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
return [(a["id"], "%s (%s)" % (a['email_id'], a['name'])) for a in self.read(cr, uid, ids, ['name', 'email_id'], context=context)]
|
||||
|
||||
def _constraint_unique(self, cursor, user, ids, context=None):
|
||||
"""
|
||||
This makes sure that you dont give personal
|
||||
users two accounts with same ID (Validated in sql constaints)
|
||||
However this constraint exempts company accounts.
|
||||
Any no of co accounts for a user is allowed
|
||||
"""
|
||||
if self.read(cursor, user, ids, ['company'])[0]['company'] == 'no':
|
||||
accounts = self.search(cursor, user, [
|
||||
('user', '=', user),
|
||||
('company', '=', 'no')
|
||||
])
|
||||
if len(accounts) > 1 :
|
||||
return False
|
||||
else :
|
||||
return True
|
||||
else:
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_constraint_unique,
|
||||
'Error: You are not allowed to have more than 1 account.',
|
||||
[])
|
||||
]
|
||||
|
||||
def get_outgoing_server(self, cursor, user, ids, context=None):
|
||||
"""
|
||||
Returns the Out Going Connection (SMTP) object
|
||||
|
||||
@attention: DO NOT USE except_osv IN THIS METHOD
|
||||
@param cursor: Database Cursor
|
||||
@param user: ID of current user
|
||||
@param ids: ID/list of ids of current object for
|
||||
which connection is required
|
||||
First ID will be chosen from lists
|
||||
@param context: Context
|
||||
|
||||
@return: SMTP server object or Exception
|
||||
"""
|
||||
#Type cast ids to integer
|
||||
if type(ids) == list:
|
||||
ids = ids[0]
|
||||
this_object = self.browse(cursor, user, ids, context=context)
|
||||
if this_object:
|
||||
if this_object.smtpserver and this_object.smtpport:
|
||||
try:
|
||||
if this_object.smtpssl:
|
||||
serv = smtplib.SMTP_SSL(this_object.smtpserver, this_object.smtpport)
|
||||
else:
|
||||
serv = smtplib.SMTP(this_object.smtpserver, this_object.smtpport)
|
||||
if this_object.smtptls:
|
||||
serv.ehlo()
|
||||
serv.starttls()
|
||||
serv.ehlo()
|
||||
except Exception, error:
|
||||
raise error
|
||||
try:
|
||||
if serv.has_extn('AUTH') or this_object.smtpuname or this_object.smtppass:
|
||||
serv.login(str(this_object.smtpuname), str(this_object.smtppass))
|
||||
except Exception, error:
|
||||
raise error
|
||||
return serv
|
||||
raise Exception(_("SMTP SERVER or PORT not specified"))
|
||||
raise Exception(_("Core connection for the given ID does not exist"))
|
||||
|
||||
def check_outgoing_connection(self, cursor, user, ids, context=None):
|
||||
"""
|
||||
checks SMTP credentials and confirms if outgoing connection works
|
||||
(Attached to button)
|
||||
@param cursor: Database Cursor
|
||||
@param user: ID of current user
|
||||
@param ids: list of ids of current object for
|
||||
which connection is required
|
||||
@param context: Context
|
||||
"""
|
||||
try:
|
||||
self.get_outgoing_server(cursor, user, ids, context)
|
||||
raise osv.except_osv(_("SMTP Test Connection Was Successful"), '')
|
||||
except osv.except_osv, success_message:
|
||||
raise success_message
|
||||
except Exception, error:
|
||||
raise osv.except_osv(
|
||||
_("Out going connection test failed"),
|
||||
_("Reason: %s") % error
|
||||
)
|
||||
|
||||
def do_approval(self, cr, uid, ids, context=None):
|
||||
#TODO: Check if user has rights
|
||||
self.write(cr, uid, ids, {'state':'approved'}, context=context)
|
||||
# wf_service = netsvc.LocalService("workflow")
|
||||
|
||||
def smtp_connection(self, cursor, user, id, context=None):
|
||||
"""
|
||||
This method should now wrap smtp_connection
|
||||
"""
|
||||
#This function returns a SMTP server object
|
||||
logger = netsvc.Logger()
|
||||
core_obj = self.browse(cursor, user, id, context=context)
|
||||
if core_obj.smtpserver and core_obj.smtpport and core_obj.state == 'approved':
|
||||
try:
|
||||
serv = self.get_outgoing_server(cursor, user, id, context)
|
||||
except Exception, error:
|
||||
logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed on login. Probable Reason:Could not login to server\nError: %s") % (id, error))
|
||||
return False
|
||||
#Everything is complete, now return the connection
|
||||
return serv
|
||||
else:
|
||||
logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Account not approved") % id)
|
||||
return False
|
||||
|
||||
#**************************** MAIL SENDING FEATURES ***********************#
|
||||
|
||||
|
||||
|
||||
|
||||
def send_mail(self, cr, uid, ids, addresses, subject='', body=None, payload=None, message_id=None, context=None):
|
||||
#TODO: Replace all this with a single email object
|
||||
if body is None:
|
||||
body = {}
|
||||
if payload is None:
|
||||
payload = {}
|
||||
if context is None:
|
||||
context = {}
|
||||
logger = netsvc.Logger()
|
||||
for id in ids:
|
||||
core_obj = self.browse(cr, uid, id, context)
|
||||
serv = self.smtp_connection(cr, uid, id)
|
||||
if serv:
|
||||
try:
|
||||
# Prepare multipart containers depending on data
|
||||
text_subtype = (core_obj.send_pref == 'alternative') and 'alternative' or 'mixed'
|
||||
# Need a multipart/mixed wrapper for attachments if content is alternative
|
||||
if payload and text_subtype == 'alternative':
|
||||
payload_part = MIMEMultipart(_subtype='mixed')
|
||||
text_part = MIMEMultipart(_subtype=text_subtype)
|
||||
payload_part.attach(text_part)
|
||||
else:
|
||||
# otherwise a single multipart/mixed will do the whole job
|
||||
payload_part = text_part = MIMEMultipart(_subtype=text_subtype)
|
||||
|
||||
if subject:
|
||||
payload_part['Subject'] = subject
|
||||
from_email = core_obj.email_id
|
||||
if '<' in from_email:
|
||||
# We have a structured email address, keep it untouched
|
||||
payload_part['From'] = Header(core_obj.email_id, 'utf-8').encode()
|
||||
else:
|
||||
# Plain email address, construct a structured one based on the name:
|
||||
sender_name = Header(core_obj.name, 'utf-8').encode()
|
||||
payload_part['From'] = sender_name + " <" + core_obj.email_id + ">"
|
||||
payload_part['Organization'] = tools.ustr(core_obj.user.company_id.name)
|
||||
payload_part['Date'] = formatdate()
|
||||
addresses_l = extract_emails_from_dict(addresses)
|
||||
if addresses_l['To']:
|
||||
payload_part['To'] = u','.join(addresses_l['To'])
|
||||
if addresses_l['CC']:
|
||||
payload_part['CC'] = u','.join(addresses_l['CC'])
|
||||
if addresses_l['Reply-To']:
|
||||
payload_part['Reply-To'] = addresses_l['Reply-To'][0]
|
||||
if message_id:
|
||||
payload_part['Message-ID'] = message_id
|
||||
if body.get('text', False):
|
||||
temp_body_text = body.get('text', '')
|
||||
l = len(temp_body_text.replace(' ', '').replace('\r', '').replace('\n', ''))
|
||||
if l == 0:
|
||||
body['text'] = u'No Mail Message'
|
||||
# Attach parts into message container.
|
||||
# According to RFC 2046, the last part of a multipart message, in this case
|
||||
# the HTML message, is best and preferred.
|
||||
if core_obj.send_pref in ('text', 'mixed', 'alternative'):
|
||||
body_text = body.get('text', u'<Empty Message>')
|
||||
body_text = tools.ustr(body_text)
|
||||
text_part.attach(MIMEText(body_text.encode("utf-8"), _charset='UTF-8'))
|
||||
if core_obj.send_pref in ('html', 'mixed', 'alternative'):
|
||||
html_body = body.get('html', u'')
|
||||
if len(html_body) == 0 or html_body == u'':
|
||||
html_body = body.get('text', u'<p><Empty Message></p>').replace('\n', '<br/>').replace('\r', '<br/>')
|
||||
html_body = tools.ustr(html_body)
|
||||
text_part.attach(MIMEText(html_body.encode("utf-8"), _subtype='html', _charset='UTF-8'))
|
||||
|
||||
#Now add attachments if any, wrapping into a container multipart/mixed if needed
|
||||
if payload:
|
||||
for file in payload:
|
||||
part = MIMEBase('application', "octet-stream")
|
||||
part.set_payload(base64.decodestring(payload[file]))
|
||||
part.add_header('Content-Disposition', 'attachment; filename="%s"' % file)
|
||||
Encoders.encode_base64(part)
|
||||
payload_part.attach(part)
|
||||
except Exception, error:
|
||||
logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:MIME Error\nDescription: %s") % (id, error))
|
||||
return {'error_msg': _("Server Send Error\nDescription: %s")%error}
|
||||
try:
|
||||
serv.sendmail(payload_part['From'], addresses_l['all-recipients'], payload_part.as_string())
|
||||
except Exception, error:
|
||||
logging.getLogger('email_template').error(_("Mail from Account %s failed. Probable Reason: Server Send Error\n Description: %s"), id, error, exc_info=True)
|
||||
return {'error_msg': _("Server Send Error\nDescription: %s")%error}
|
||||
#The mail sending is complete
|
||||
serv.close()
|
||||
logger.notifyChannel(_("Email Template"), netsvc.LOG_INFO, _("Mail from Account %s successfully Sent.") % (id))
|
||||
return True
|
||||
else:
|
||||
logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Account not approved") % id)
|
||||
return {'nodestroy':True,'error_msg': _("Mail from Account %s failed. Probable Reason:Account not approved")% id}
|
||||
|
||||
def extracttime(self, time_as_string):
|
||||
"""
|
||||
TODO: DOC THis
|
||||
"""
|
||||
logger = netsvc.Logger()
|
||||
#The standard email dates are of format similar to:
|
||||
#Thu, 8 Oct 2009 09:35:42 +0200
|
||||
date_as_date = False
|
||||
convertor = {'+':1, '-':-1}
|
||||
try:
|
||||
time_as_string = time_as_string.replace(',', '')
|
||||
date_list = time_as_string.split(' ')
|
||||
date_temp_str = ' '.join(date_list[1:5])
|
||||
if len(date_list) >= 6:
|
||||
sign = convertor.get(date_list[5][0], False)
|
||||
else:
|
||||
sign = False
|
||||
try:
|
||||
dt = datetime.datetime.strptime(
|
||||
date_temp_str,
|
||||
"%d %b %Y %H:%M:%S")
|
||||
except:
|
||||
try:
|
||||
dt = datetime.datetime.strptime(
|
||||
date_temp_str,
|
||||
"%d %b %Y %H:%M")
|
||||
except:
|
||||
return False
|
||||
if sign:
|
||||
try:
|
||||
offset = datetime.timedelta(
|
||||
hours=sign * int(
|
||||
date_list[5][1:3]
|
||||
),
|
||||
minutes=sign * int(
|
||||
date_list[5][3:5]
|
||||
)
|
||||
)
|
||||
except Exception, e2:
|
||||
"""Looks like UT or GMT, just forget decoding"""
|
||||
return False
|
||||
else:
|
||||
offset = datetime.timedelta(hours=0)
|
||||
dt = dt + offset
|
||||
date_as_date = dt.strftime('%Y-%m-%d %H:%M:%S')
|
||||
except Exception, e:
|
||||
logger.notifyChannel(
|
||||
_("Email Template"),
|
||||
netsvc.LOG_WARNING,
|
||||
_(
|
||||
"Datetime Extraction failed.Date:%s \
|
||||
\tError:%s") % (
|
||||
time_as_string,
|
||||
e)
|
||||
)
|
||||
return date_as_date
|
||||
|
||||
def send_receive(self, cr, uid, ids, context=None):
|
||||
for id in ids:
|
||||
ctx = context.copy()
|
||||
ctx['filters'] = [('account_id', '=', id)]
|
||||
self.pool.get('email_template.mailbox').send_all_mail(cr, uid, [], context=ctx)
|
||||
return True
|
||||
|
||||
def decode_header_text(self, text):
|
||||
""" Decode internationalized headers RFC2822.
|
||||
To, CC, BCC, Subject fields can contain
|
||||
text slices with different encodes, like:
|
||||
=?iso-8859-1?Q?Enric_Mart=ED?= <enricmarti@company.com>,
|
||||
=?Windows-1252?Q?David_G=F3mez?= <david@company.com>
|
||||
Sometimes they include extra " character at the beginning/
|
||||
end of the contact name, like:
|
||||
"=?iso-8859-1?Q?Enric_Mart=ED?=" <enricmarti@company.com>
|
||||
and decode_header() does not work well, so we use regular
|
||||
expressions (?= ? ? ?=) to split the text slices
|
||||
"""
|
||||
if not text:
|
||||
return text
|
||||
p = re.compile("(=\?.*?\?.\?.*?\?=)")
|
||||
text2 = ''
|
||||
try:
|
||||
for t2 in p.split(text):
|
||||
text2 += ''.join(
|
||||
[s.decode(
|
||||
t or 'ascii'
|
||||
) for (s, t) in decode_header(t2)]
|
||||
).encode('utf-8')
|
||||
except:
|
||||
return text
|
||||
return text2
|
||||
|
||||
email_template_account()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,124 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<menuitem name="Marketing" icon="terp-crm" id="base.marketing_menu" sequence="17"
|
||||
groups="marketing.group_marketing_user,marketing.group_marketing_manager"/>
|
||||
<menuitem name="Emails" id="base.menu_emails" parent="base.marketing_menu" sequence="5"/>
|
||||
<menuitem name="Email Template" id="menu_email_template" parent="base.menu_emails"/>
|
||||
|
||||
<record model="ir.ui.view" id="email_template_account_form">
|
||||
<field name="name">email_template.account.form</field>
|
||||
<field name="model">email_template.account</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Email Account Configuration">
|
||||
<group colspan="2">
|
||||
<field name="name" select="1" />
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Outgoing">
|
||||
<separator string="Server Information" colspan="4" />
|
||||
<group colspan="4" col="4">
|
||||
<field name="smtpserver" select="1"/>
|
||||
<button name="check_outgoing_connection" type="object" string="Test Outgoing Connection" icon="gtk-network" colspan="2"/>
|
||||
<field name="smtpport" select="2" />
|
||||
<field name="smtpssl" select="2" />
|
||||
<field name="smtptls" select="2" />
|
||||
<field name="auto_delete" />
|
||||
</group>
|
||||
<separator string="User Information" colspan="4" />
|
||||
<group col="2" colspan="2">
|
||||
<field name="email_id" select="1" colspan="2" />
|
||||
<field name="smtppass" password="True" colspan="2" />
|
||||
<field name="company" select="2" colspan="2" />
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<field name="smtpuname" select="1" colspan="2" />
|
||||
<field name="user" select="2" colspan="2" />
|
||||
<field name="send_pref" colspan="2" />
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
<group colspan="4" col="10">
|
||||
<field name="state" select="1"/>
|
||||
<button string="Approve Account" name="button_approval" states="draft" type="workflow" icon="terp-camera_test"/>
|
||||
<button string="Suspend Account" name="button_suspended" states="approved" type="workflow" icon="gtk-cancel"/>
|
||||
<button string="Request Re-activation" name="get_reapprove" states="suspended" type="workflow" icon="gtk-convert"/>
|
||||
<button string="Send/Receive" name="send_receive" states="approved" type="object" icon="terp-check"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="email_template_account_tree">
|
||||
<field name="name">email_template.account.tree</field>
|
||||
<field name="model">email_template.account</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="blue:state in ('draft');black:state in ('suspended','approved')" string="Email Accounts">
|
||||
<field name="name" />
|
||||
<field name="email_id" />
|
||||
<field name="smtpuname" />
|
||||
<field name="user" />
|
||||
<field name="smtpserver" />
|
||||
<field name="smtpport" />
|
||||
<field name="auto_delete" />
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_email_template_account_search" model="ir.ui.view">
|
||||
<field name="name">email_template.account.search</field>
|
||||
<field name="model">email_template.account</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Email Accounts">
|
||||
<filter icon="terp-document-new" string="Draft" name="draft" domain="[('state','=','draft')]"/>
|
||||
<filter icon="terp-camera_test" string="Approved" domain="[('state','=','approved')]"/>
|
||||
<filter icon="terp-emblem-important" string="Suspended" domain="[('state','=','suspended')]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-go-home" string="Company Accounts" domain="[('company','=','yes')]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="user" select="1">
|
||||
<filter icon="terp-personal" help="My Accounts" name="my" domain="[('user','=',uid)]"/>
|
||||
</field>
|
||||
<field name="name" select="1"/>
|
||||
<field name="email_id" select="1"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_email_template_account_tree_all">
|
||||
<field name="name">Accounts</field>
|
||||
<field name="res_model">email_template.account</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form,tree</field>
|
||||
<field name="view_id" ref="email_template_account_tree" />
|
||||
<field name="context">{'group_by': [], 'search_default_draft': 1, 'search_default_my': 1}</field>
|
||||
<field name="search_view_id" ref="view_email_template_account_search"/>
|
||||
</record>
|
||||
|
||||
<menuitem name="Configuration" parent="base.marketing_menu"
|
||||
id="base.menu_marketing_config_root" sequence="20" groups="base.group_system"/>
|
||||
|
||||
<menuitem name="Email Template" id="menu_email_template_configuration" parent="base.menu_marketing_config_root" />
|
||||
|
||||
<menuitem name="Email Accounts" id="menu_email_template_account_all" parent="menu_email_template_configuration" action="action_email_template_account_tree_all"/>
|
||||
|
||||
<menuitem name="Configuration" parent="base.menu_tools"
|
||||
id="base.menu_lunch_survey_root" sequence="20" />
|
||||
|
||||
<menuitem name="Email Template" id="menu_email_template_config_tools"
|
||||
parent="base.menu_lunch_survey_root" />
|
||||
|
||||
<menuitem name="Email Accounts" id="menu_email_account_all_tools"
|
||||
parent="menu_email_template_config_tools" action="action_email_template_account_tree_all" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,213 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2009 Sharoon Thomas
|
||||
# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
|
||||
#
|
||||
# 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
|
||||
import time
|
||||
import netsvc
|
||||
from tools.translate import _
|
||||
import tools
|
||||
|
||||
LOGGER = netsvc.Logger()
|
||||
|
||||
class email_template_mailbox(osv.osv):
|
||||
_name = "email_template.mailbox"
|
||||
_description = 'Email Mailbox'
|
||||
_rec_name = "subject"
|
||||
_order = "date_mail desc"
|
||||
|
||||
def run_mail_scheduler(self, cursor, user, context=None):
|
||||
"""
|
||||
This method is called by OpenERP Scheduler
|
||||
to periodically send emails
|
||||
"""
|
||||
try:
|
||||
self.send_all_mail(cursor, user, context=context)
|
||||
except Exception, e:
|
||||
LOGGER.notifyChannel(
|
||||
"Email Template",
|
||||
netsvc.LOG_ERROR,
|
||||
_("Error sending mail: %s") % e)
|
||||
|
||||
def send_all_mail(self, cr, uid, ids=None, context=None):
|
||||
if ids is None:
|
||||
ids = []
|
||||
if context is None:
|
||||
context = {}
|
||||
filters = [('folder', '=', 'outbox'), ('state', '!=', 'sending')]
|
||||
if 'filters' in context.keys():
|
||||
for each_filter in context['filters']:
|
||||
filters.append(each_filter)
|
||||
ids = self.search(cr, uid, filters, context=context)
|
||||
self.write(cr, uid, ids, {'state':'sending'}, context)
|
||||
self.send_this_mail(cr, uid, ids, context)
|
||||
return True
|
||||
|
||||
def send_this_mail(self, cr, uid, ids=None, context=None):
|
||||
#previous method to send email (link with email account can be found at the revision 4172 and below
|
||||
result = True
|
||||
attachment_pool = self.pool.get('ir.attachment')
|
||||
for id in (ids or []):
|
||||
try:
|
||||
account_obj = self.pool.get('email_template.account')
|
||||
values = self.read(cr, uid, id, [], context)
|
||||
payload = {}
|
||||
if values['attachments_ids']:
|
||||
for attid in values['attachments_ids']:
|
||||
attachment = attachment_pool.browse(cr, uid, attid, context)#,['datas_fname','datas'])
|
||||
payload[attachment.datas_fname] = attachment.datas
|
||||
result = account_obj.send_mail(cr, uid,
|
||||
[values['account_id'][0]],
|
||||
{'To':values.get('email_to') or u'',
|
||||
'CC':values.get('email_cc') or u'',
|
||||
'BCC':values.get('email_bcc') or u'',
|
||||
'Reply-To':values.get('reply_to') or u''},
|
||||
values['subject'] or u'',
|
||||
{'text':values.get('body_text') or u'', 'html':values.get('body_html') or u''},
|
||||
payload=payload,
|
||||
message_id=values['message_id'],
|
||||
context=context)
|
||||
if result == True:
|
||||
account = account_obj.browse(cr, uid, values['account_id'][0], context=context)
|
||||
if account.auto_delete:
|
||||
self.write(cr, uid, id, {'folder': 'trash'}, context=context)
|
||||
self.unlink(cr, uid, [id], context=context)
|
||||
# Remove attachments for this mail
|
||||
attachment_pool.unlink(cr, uid, values['attachments_ids'], context=context)
|
||||
else:
|
||||
self.write(cr, uid, id, {'folder':'sent', 'state':'na', 'date_mail':time.strftime("%Y-%m-%d %H:%M:%S")}, context)
|
||||
self.historise(cr, uid, [id], "Email sent successfully", context)
|
||||
else:
|
||||
error = result['error_msg']
|
||||
self.historise(cr, uid, [id], error, context)
|
||||
|
||||
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") % (id, error))
|
||||
self.historise(cr, uid, [id], error, context)
|
||||
self.write(cr, uid, id, {'state':'na'}, context)
|
||||
return result
|
||||
|
||||
def historise(self, cr, uid, ids, message='', context=None):
|
||||
for id in ids:
|
||||
history = self.read(cr, uid, id, ['history'], context).get('history', '')
|
||||
self.write(cr, uid, id, {'history': (history or '' )+ "\n" + time.strftime("%Y-%m-%d %H:%M:%S") + ": " + tools.ustr(message)}, context)
|
||||
|
||||
_columns = {
|
||||
'email_from':fields.char(
|
||||
'From',
|
||||
size=64),
|
||||
'email_to':fields.char(
|
||||
'Recipient (To)',
|
||||
size=250,),
|
||||
'email_cc':fields.char(
|
||||
'CC',
|
||||
size=250),
|
||||
'email_bcc':fields.char(
|
||||
'BCC',
|
||||
size=250),
|
||||
'reply_to':fields.char(
|
||||
'Reply-To',
|
||||
size=250),
|
||||
'message_id':fields.char(
|
||||
'Message-ID',
|
||||
size=250),
|
||||
'subject':fields.char(
|
||||
'Subject',
|
||||
size=200,),
|
||||
'body_text':fields.text(
|
||||
'Standard Body (Text)'),
|
||||
'body_html':fields.text(
|
||||
'Body (Rich Text Clients Only)'),
|
||||
'attachments_ids':fields.many2many(
|
||||
'ir.attachment',
|
||||
'mail_attachments_rel',
|
||||
'mail_id',
|
||||
'att_id',
|
||||
'Attachments'),
|
||||
'account_id' :fields.many2one(
|
||||
'email_template.account',
|
||||
'User account',
|
||||
required=True),
|
||||
'user':fields.related(
|
||||
'account_id',
|
||||
'user',
|
||||
type="many2one",
|
||||
relation="res.users",
|
||||
string="User"),
|
||||
'server_ref':fields.integer(
|
||||
'Server Reference of mail',
|
||||
help="Applicable for inward items only"),
|
||||
'mail_type':fields.selection([
|
||||
('multipart/mixed',
|
||||
'Has Attachments'),
|
||||
('multipart/alternative',
|
||||
'Plain Text & HTML with no attachments'),
|
||||
('multipart/related',
|
||||
'Intermixed content'),
|
||||
('text/plain',
|
||||
'Plain Text'),
|
||||
('text/html',
|
||||
'HTML Body'),
|
||||
], 'Mail Contents'),
|
||||
#I like GMAIL which allows putting same mail in many folders
|
||||
#Lets plan it for 0.9
|
||||
'folder':fields.selection([
|
||||
('drafts', 'Drafts'),
|
||||
('outbox', 'Outbox'),
|
||||
('trash', 'Trash'),
|
||||
('sent', 'Sent Items'),
|
||||
], 'Folder', required=True),
|
||||
'state':fields.selection([
|
||||
('na', 'Not Applicable'),
|
||||
('sending', 'Sending'),
|
||||
], 'Status', required=True),
|
||||
'date_mail':fields.datetime('Rec/Sent Date', help="Date on which Email Sent or Received"),
|
||||
'history':fields.text(
|
||||
'History',
|
||||
readonly=True,
|
||||
store=True)
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state': lambda * a: 'na',
|
||||
'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_template_mailbox, self).unlink(cr, uid, to_remove, context=context)
|
||||
|
||||
email_template_mailbox()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,134 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Email Template-->
|
||||
<record model="ir.ui.view" id="email_template_mailbox_form">
|
||||
<field name="name">email_template.mailbox.form</field>
|
||||
<field name="model">email_template.mailbox</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Emails">
|
||||
<group col="4" colspan="4" name="headers">
|
||||
<field name="email_from" select="1"/>
|
||||
<field name="email_to" required="1" select="1" />
|
||||
<field name="reply_to" select="2"/>
|
||||
<field name="email_cc" select="1"/>
|
||||
<field name="email_bcc" select="2"/>
|
||||
<field name="date_mail" select="2"/>
|
||||
<field name="subject" colspan="4" select="1"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Standard Body">
|
||||
<separator colspan="4" string="Standard Body" />
|
||||
<notebook colspan="4">
|
||||
<page string="Standard Body (Text)">
|
||||
<field name="body_text" nolabel="1" colspan="4" select="1"/>
|
||||
</page>
|
||||
<page string="Body (HTML-Web Client Only)">
|
||||
<field name="body_html" nolabel="1" colspan="4" />
|
||||
</page>
|
||||
</notebook>
|
||||
<separator colspan="4" string="" />
|
||||
<group col="4" colspan="4">
|
||||
<field name="state" readonly="1" string="State"/>
|
||||
<button name="send_this_mail" type="object" string="Send Mail" icon="terp-mail-message-new"/>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
<page string="Attachments">
|
||||
<separator colspan="4" string="Attachments" />
|
||||
<field name="attachments_ids" colspan="4" nolabel="1" />
|
||||
</page>
|
||||
<page string="Advanced">
|
||||
<field name="account_id" colspan="2" />
|
||||
<field name="server_ref" colspan="2" />
|
||||
<field name="mail_type" colspan="2" />
|
||||
<field name="folder" colspan="2" select="2"/>
|
||||
<field name="message_id" select="2"/>
|
||||
<separator string="History" colspan="4" />
|
||||
<field name="history" nolabel="1" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!--============================================= TREE VIEWS =============================================-->
|
||||
<record id="view_email_template_mailbox_tree" model="ir.ui.view">
|
||||
<field name="name">email_template.mailbox.tree</field>
|
||||
<field name="model">email_template.mailbox</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Emails" colors="blue:folder=='drafts';grey:folder=='trash'">
|
||||
<field name="subject" select="1" />
|
||||
<field name="user" />
|
||||
<field name="email_from" select="1" />
|
||||
<field name="email_to"/>
|
||||
<field name="date_mail" select="2" />
|
||||
<field name="attachments_ids" select="2" />
|
||||
<field name="folder" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_email_template_mailbox_search" model="ir.ui.view">
|
||||
<field name="name">email_template.mailbox.search</field>
|
||||
<field name="model">email_template.mailbox</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Emails">
|
||||
<filter icon="terp-document-new" string="Drafts" name="draft" domain="[('folder','=','drafts')]"/>
|
||||
<filter icon="terp-mail-" string="Outbox" name="outbox" domain="[('folder','=','outbox')]"/>
|
||||
<filter icon="terp-camera_test" string="Sent" domain="[('folder','=','sent')]"/>
|
||||
<filter icon="terp-mail_delete" string="Trash" domain="[('folder','=','trash')]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-personal+" string="Personal Emails" name="personal" domain="[('account_id.company','=','no')]"/>
|
||||
<filter icon="terp-go-home" string="Company Emails" name="company" domain="[('account_id.company','=','yes')]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="subject"/>
|
||||
<field name="email_from"/>
|
||||
<field name="user">
|
||||
<filter icon="terp-personal"
|
||||
string="My Emails" help="My Emails" name="myemails"
|
||||
domain="[('account_id.user','=', uid)]" />
|
||||
</field>
|
||||
<newline/>
|
||||
<field name="email_to"/>
|
||||
<field name="date_mail"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_email_template_mailbox">
|
||||
<field name="name">Emails</field>
|
||||
<field name="res_model">email_template.mailbox</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_email_template_mailbox_tree" />
|
||||
<field name="context">{'group_by': [], 'search_default_outbox': 1}</field>
|
||||
<field name="help">An email template is an email document that will be sent as part of a marketing campaign. You can personalize it according to specific customer profile fields, so that a partner name or other partner related information may be inserted automatically.</field>
|
||||
<field name="search_view_id" ref="view_email_template_mailbox_search"/>
|
||||
</record>
|
||||
|
||||
<!--======================================== MENUS ========================================-->
|
||||
|
||||
<menuitem name="Emails"
|
||||
id="menu_email_template_personal_mails"
|
||||
parent="menu_email_template"
|
||||
action="action_email_template_mailbox" />
|
||||
|
||||
<!-- Mailbox menu in Tools -->
|
||||
<menuitem name="Email Template" id="menu_email_template_tools"
|
||||
parent="base.menu_tools" />
|
||||
|
||||
<menuitem name="Emails"
|
||||
id="menu_email_template_mails_tools"
|
||||
parent="menu_email_template_tools"
|
||||
action="action_email_template_mailbox" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,51 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Email Template Preview -->
|
||||
<record model="ir.ui.view" id="email_template_preview_form">
|
||||
<field name="name">email_template.preview.form</field>
|
||||
<field name="model">email_template.preview</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Email Preview">
|
||||
<group col="4" colspan="4">
|
||||
<field name="rel_model" />
|
||||
<field name="rel_model_ref" on_change="on_change_ref(rel_model_ref, context)"/>
|
||||
</group>
|
||||
<group col="8" colspan="4">
|
||||
<field name="to" />
|
||||
<field name="cc" />
|
||||
<field name="bcc" />
|
||||
<field name="reply_to" />
|
||||
<field name="message_id" attrs="{'invisible':[('message_id','=',False)]}" groups="base.group_extended"/>
|
||||
<field name="subject" colspan="8"/>
|
||||
</group>
|
||||
<group col="4" colspan="4">
|
||||
<separator string= "Body(Text)" colspan="2"/>
|
||||
<separator string= "Body(Html)" colspan="2"/>
|
||||
<newline/>
|
||||
<field name="body_text" nolabel="1" colspan="2"/>
|
||||
<field name="body_html" nolabel="1" colspan="2"/>
|
||||
</group>
|
||||
<field name="report" colspan="2"/>
|
||||
<button icon="gtk-ok" special="cancel" string="OK" colspan="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="wizard_email_template_preview" model="ir.actions.act_window">
|
||||
<field name="name">Template Preview</field>
|
||||
<field name="res_model">email_template.preview</field>
|
||||
<field name="src_model">email_template.preview</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="auto_refresh" eval="1" />
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'template_id':active_id}</field>
|
||||
</record>
|
||||
<!--EMail client Form view -->
|
||||
|
||||
<record model="ir.ui.view" id="email_template_form">
|
||||
<field name="name">email.template.form</field>
|
||||
|
@ -53,10 +8,10 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Email Templates">
|
||||
<field name="name" />
|
||||
<field name="name"/>
|
||||
<field name="object_name" required="1"
|
||||
on_change="change_model(object_name)" />
|
||||
<field name="model_int_name" invisible="1" />
|
||||
on_change="change_model(object_name)"/>
|
||||
<field name="model_int_name" invisible="1"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Mail Details">
|
||||
<group col="2" colspan="2">
|
||||
|
@ -74,38 +29,34 @@
|
|||
<field name="track_campaign_item" colspan="4"/>
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<separator colspan="2" string="Email Content " />
|
||||
<field name="def_subject" colspan="4" required="1" />
|
||||
<separator colspan="2" string="Email Content"/>
|
||||
<field name="def_subject" colspan="4" required="1"/>
|
||||
<notebook>
|
||||
<page string="Body (Text)">
|
||||
<field name="def_body_text" colspan="4" nolabel="1" />
|
||||
<field name="def_body_text" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Body (Raw HTML)">
|
||||
<field name="def_body_html" colspan="4" nolabel="1" />
|
||||
<label string="Note: This is Raw HTML." colspan="4" />
|
||||
<field name="def_body_html" colspan="4" nolabel="1"/>
|
||||
<label string="Note: This is Raw HTML." colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</group>
|
||||
<group col="4" colspan="2">
|
||||
<separator colspan="4" string="Expression Builder" />
|
||||
<field name="template_language"
|
||||
on_change="onchange_null_value(model_object_field,sub_model_object_field,null_value,template_language,context)" />
|
||||
<notebook>
|
||||
<page string="Insert Simple Field">
|
||||
|
||||
<field name="model_object_field"
|
||||
domain="[('model_id','=',object_name),('ttype','!=','one2many'),('ttype','!=','many2many')]"
|
||||
on_change="onchange_model_object_field(model_object_field, template_language,context)"
|
||||
colspan="4" />
|
||||
<field name="sub_object" readonly="1" colspan="4" />
|
||||
on_change="onchange_sub_model_object_value_field(model_object_field)"
|
||||
colspan="4"/>
|
||||
<field name="sub_object" readonly="1" colspan="4"/>
|
||||
<field name="sub_model_object_field"
|
||||
domain="[('model_id','=',sub_object),('ttype','!=','one2many'),('ttype','!=','many2many')]"
|
||||
colspan="4"
|
||||
attrs="{'readonly':[('sub_object','=',False)],'required':[('sub_object','!=',False)]}"
|
||||
on_change="onchange_sub_model_object_field(model_object_field,sub_model_object_field,template_language,context)" />
|
||||
on_change="onchange_sub_model_object_value_field(model_object_field,sub_model_object_field)"/>
|
||||
<field name="null_value" colspan="4"
|
||||
on_change="onchange_null_value(model_object_field,sub_model_object_field,null_value,template_language,context)" />
|
||||
<field name="copyvalue" colspan="4" />
|
||||
on_change="onchange_sub_model_object_value_field(model_object_field,sub_model_object_field,null_value)" />
|
||||
<field name="copyvalue" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<button name="%(wizard_email_template_preview)d" string="Preview Template"
|
||||
|
@ -124,6 +75,7 @@
|
|||
<group colspan="2" col="2">
|
||||
<separator string="Advanced Options" colspan="2"/>
|
||||
<field name="message_id"/>
|
||||
<field name="auto_delete"/>
|
||||
</group>
|
||||
</group>
|
||||
<group colspan="2" col="2">
|
||||
|
@ -134,7 +86,7 @@
|
|||
</page>
|
||||
<page string="Report">
|
||||
<field name="report_template" colspan="4"
|
||||
domain="[('model','=',model_int_name)]" />
|
||||
domain="[('model','=',model_int_name)]"/>
|
||||
<field name="file_name" colspan="4" />
|
||||
</page>
|
||||
</notebook>
|
||||
|
@ -173,13 +125,13 @@
|
|||
<field name="arch" type="xml">
|
||||
<search string="Templates">
|
||||
<group col="13" colspan="4">
|
||||
<field name="name" select="1"/>
|
||||
<field name="object_name" select="1"/>
|
||||
<field name="def_to" select="1"/>
|
||||
<field name="name"/>
|
||||
<field name="object_name"/>
|
||||
<field name="def_to"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="lang" select="1"/>
|
||||
<field name="def_subject" select="1"/>
|
||||
<field name="file_name" select="1"/>
|
||||
<field name="lang"/>
|
||||
<field name="def_subject"/>
|
||||
<field name="file_name"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group by..." colspan="4" col="10">
|
||||
|
@ -200,16 +152,22 @@
|
|||
<field name="search_view_id" ref="view_email_template_search"/>
|
||||
</record>
|
||||
|
||||
<menuitem name="Email Templates" id="menu_email_template_all"
|
||||
parent="menu_email_template_configuration" action="action_email_template_tree_all" />
|
||||
|
||||
<!-- Email Template menu in Tools -->
|
||||
<menuitem name="Email Templates" id="menu_email_template_all_tools"
|
||||
parent="menu_email_template_config_tools" action="action_email_template_tree_all" />
|
||||
parent="emails.menu_config_email" 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="emails.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>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</openerp>
|
|
@ -1,64 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="wkf_email_template_setting" model="workflow">
|
||||
<field name="name">Email Template Workflow</field>
|
||||
<field name="osv">email_template.account</field>
|
||||
<field name="on_create">True</field>
|
||||
</record>
|
||||
|
||||
<!--Activity -->
|
||||
|
||||
<record id="act_draft" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf_email_template_setting"/>
|
||||
<field name="flow_start">True</field>
|
||||
<field name="name">draft</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">write({'state':'draft'})</field>
|
||||
</record>
|
||||
|
||||
<record id="act_approved" model="workflow.activity">
|
||||
<field name="name">approval</field>
|
||||
<field name="wkf_id" ref="wkf_email_template_setting"/>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">do_approval()</field>
|
||||
</record>
|
||||
|
||||
<record id="act_suspended" model="workflow.activity">
|
||||
<field name="name">suspended</field>
|
||||
<field name="wkf_id" ref="wkf_email_template_setting"/>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">write({'state':'suspended'})</field>
|
||||
</record>
|
||||
<record id="act_dummy" model="workflow.activity">
|
||||
<field name="name">dummy</field>
|
||||
<field name="wkf_id" ref="wkf_email_template_setting"/>
|
||||
<field name="flow_stop">True</field>
|
||||
</record>
|
||||
|
||||
<!-- Transition -->
|
||||
|
||||
<record id="trans_awaiting_approved" model="workflow.transition">
|
||||
<field name="act_from" ref="act_draft"/>
|
||||
<field name="act_to" ref="act_approved"/>
|
||||
<field name="signal">button_approval</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_approved_suspended" model="workflow.transition">
|
||||
<field name="act_from" ref="act_approved"/>
|
||||
<field name="act_to" ref="act_suspended"/>
|
||||
<field name="signal">button_suspended</field>
|
||||
</record>
|
||||
<record id="trans_suspended_reapproved" model="workflow.transition">
|
||||
<field name="act_from" ref="act_suspended"/>
|
||||
<field name="act_to" ref="act_draft"/>
|
||||
<field name="signal">get_reapprove</field>
|
||||
</record>
|
||||
<record id="trans_suspended_dummy" model="workflow.transition">
|
||||
<field name="act_from" ref="act_suspended"/>
|
||||
<field name="act_to" ref="act_dummy"/>
|
||||
<field name="signal">get_never</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,10 +1,4 @@
|
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_email_template_account","email_template.account","model_email_template_account","marketing.group_marketing_user",1,0,0,0
|
||||
"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_account_system","email_template.account system","model_email_template_account","base.group_system",1,1,1,1
|
||||
"access_email_template","email.template","model_email_template",,1,0,0,0
|
||||
"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_account_manager","email_template.account","model_email_template_account","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_mailbox_manager","email_template.mailbox","model_email_template_mailbox","marketing.group_marketing_manager",1,1,1,1
|
||||
"access_email_template_manager","email.template","model_email_template",,1,1,1,1
|
||||
|
|
|
|
@ -21,3 +21,4 @@
|
|||
##############################################################################
|
||||
|
||||
import email_template_send_wizard
|
||||
import email_template_preview
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2009 Sharoon Thomas
|
||||
# Copyright (C) 2010-2010 OpenERP SA (<http://www.openerp.com>)
|
||||
#
|
||||
# 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 _
|
||||
from email_template.email_template import get_value
|
||||
import tools
|
||||
|
||||
|
||||
class email_template_preview(osv.osv_memory):
|
||||
_name = "email_template.preview"
|
||||
_description = "Email Template Preview"
|
||||
|
||||
def _get_model_recs(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
#Fills up the selection box which allows records from the selected object to be displayed
|
||||
self.context = context
|
||||
if 'template_id' in context:
|
||||
ref_obj_id = self.pool.get('email.template').browse(cr, uid, context['template_id'], context).object_name.id
|
||||
ref_obj_name = self.pool.get('ir.model').browse(cr, uid, ref_obj_id, context).model
|
||||
model_obj = self.pool.get(ref_obj_name)
|
||||
ref_obj_ids = model_obj.search(cr, uid, [], 0, 20, 'id', context=context)
|
||||
if not ref_obj_ids:
|
||||
ref_obj_ids = []
|
||||
# also add the default one if requested, otherwise it won't be available for selection:
|
||||
default_id = context.get('default_rel_model_ref')
|
||||
if default_id and default_id not in ref_obj_ids:
|
||||
ref_obj_ids.insert(0, default_id)
|
||||
return model_obj.name_get(cr, uid, ref_obj_ids, context)
|
||||
return []
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = super(email_template_preview, self).default_get(cr, uid, fields, context=context)
|
||||
if (not fields or 'rel_model_ref' in fields) and 'template_id' in context and not result.get('rel_model_ref'):
|
||||
selectables = self._get_model_recs(cr, uid, context=context)
|
||||
result['rel_model_ref'] = selectables and selectables[0][0] or False
|
||||
return result
|
||||
|
||||
def _default_model(self, cursor, user, context=None):
|
||||
"""
|
||||
Returns the default value for model field
|
||||
@param cursor: Database Cursor
|
||||
@param user: ID of current user
|
||||
@param context: OpenERP Context
|
||||
"""
|
||||
return self.pool.get('email.template').read(cursor, user, context['template_id'], ['object_name'], context).get('object_name', False)
|
||||
|
||||
_columns = {
|
||||
'ref_template':fields.many2one(
|
||||
'email.template',
|
||||
'Template', readonly=True),
|
||||
'rel_model':fields.many2one('ir.model', 'Model', readonly=True),
|
||||
'rel_model_ref':fields.selection(_get_model_recs, 'Referred Document'),
|
||||
'to':fields.char('To', size=250, readonly=True),
|
||||
'cc':fields.char('CC', size=250, readonly=True),
|
||||
'bcc':fields.char('BCC', size=250, readonly=True),
|
||||
'reply_to':fields.char('Reply-To',
|
||||
size=250,
|
||||
help="The address recipients should reply to,"
|
||||
" if different from the From address."
|
||||
" Placeholders can be used here."),
|
||||
'message_id':fields.char('Message-ID',
|
||||
size=250,
|
||||
help="The Message-ID header value, if you need to"
|
||||
"specify it, for example to automatically recognize the replies later."
|
||||
" Placeholders can be used here."),
|
||||
'subject':fields.char('Subject', size=200, readonly=True),
|
||||
'body_text':fields.text('Body', readonly=True),
|
||||
'body_html':fields.text('Body', readonly=True),
|
||||
'report':fields.char('Report Name', size=100, readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'ref_template': lambda self, cr, uid, ctx:ctx['template_id'] or False,
|
||||
'rel_model': _default_model,
|
||||
}
|
||||
def on_change_ref(self, cr, uid, ids, rel_model_ref, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if not rel_model_ref:
|
||||
return {}
|
||||
vals = {}
|
||||
if context == {}:
|
||||
context = self.context
|
||||
template = self.pool.get('email.template').browse(cr, uid, context['template_id'], context)
|
||||
#Search translated template
|
||||
lang = get_value(cr, uid, rel_model_ref, template.lang, template, context)
|
||||
if lang:
|
||||
ctx = context.copy()
|
||||
ctx.update({'lang':lang})
|
||||
template = self.pool.get('email.template').browse(cr, uid, context['template_id'], ctx)
|
||||
vals['to'] = get_value(cr, uid, rel_model_ref, template.def_to, template, context)
|
||||
vals['cc'] = get_value(cr, uid, rel_model_ref, template.def_cc, template, context)
|
||||
vals['bcc'] = get_value(cr, uid, rel_model_ref, template.def_bcc, template, context)
|
||||
vals['reply_to'] = get_value(cr, uid, rel_model_ref, template.reply_to, template, context)
|
||||
if template.message_id:
|
||||
vals['message_id'] = get_value(cr, uid, rel_model_ref, template.message_id, template, context)
|
||||
elif template.track_campaign_item:
|
||||
vals['message_id'] = tools.misc.generate_tracking_message_id(rel_model_ref)
|
||||
vals['subject'] = get_value(cr, uid, rel_model_ref, template.def_subject, template, context)
|
||||
vals['body_text'] = get_value(cr, uid, rel_model_ref, template.def_body_text, template, context)
|
||||
vals['body_html'] = get_value(cr, uid, rel_model_ref, template.def_body_html, template, context)
|
||||
vals['report'] = get_value(cr, uid, rel_model_ref, template.file_name, template, context)
|
||||
return {'value':vals}
|
||||
|
||||
email_template_preview()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Email Template Preview -->
|
||||
<record model="ir.ui.view" id="email_template_preview_form">
|
||||
<field name="name">email_template.preview.form</field>
|
||||
<field name="model">email_template.preview</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Email Preview">
|
||||
<group col="4" colspan="4">
|
||||
<field name="rel_model"/>
|
||||
<field name="rel_model_ref" on_change="on_change_ref(rel_model_ref, context)"/>
|
||||
</group>
|
||||
<group col="8" colspan="4">
|
||||
<field name="to"/>
|
||||
<field name="cc"/>
|
||||
<field name="bcc"/>
|
||||
<field name="reply_to"/>
|
||||
<field name="message_id" attrs="{'invisible':[('message_id','=',False)]}" groups="base.group_extended"/>
|
||||
<field name="subject" colspan="8"/>
|
||||
</group>
|
||||
<group col="4" colspan="4">
|
||||
<separator string= "Body(Text)" colspan="2"/>
|
||||
<separator string= "Body(Html)" colspan="2"/>
|
||||
<newline/>
|
||||
<field name="body_text" nolabel="1" colspan="2"/>
|
||||
<field name="body_html" nolabel="1" colspan="2"/>
|
||||
</group>
|
||||
<field name="report" colspan="2"/>
|
||||
<button icon="gtk-ok" special="cancel" string="OK" colspan="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="wizard_email_template_preview" model="ir.actions.act_window">
|
||||
<field name="name">Template Preview</field>
|
||||
<field name="res_model">email_template.preview</field>
|
||||
<field name="src_model">email_template.preview</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="auto_refresh" eval="1" />
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'template_id':active_id}</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -29,7 +29,6 @@ from tools.translate import _
|
|||
import tools
|
||||
from email_template.email_template import get_value
|
||||
|
||||
|
||||
## FIXME: this wizard duplicates a lot of features of the email template preview,
|
||||
## one of the 2 should inherit from the other!
|
||||
|
||||
|
@ -51,45 +50,42 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
if template.from_account:
|
||||
return [(template.from_account.id, '%s (%s)' % (template.from_account.name, template.from_account.email_id))]
|
||||
else:
|
||||
account_id = self.pool.get('email_template.account').search(cr,uid,[('company','=','no'),('user','=',uid)], context=context)
|
||||
if account_id:
|
||||
account = self.pool.get('email_template.account').browse(cr,uid,account_id, context)
|
||||
return [(r.id,r.name + " (" + r.email_id + ")") for r in account]
|
||||
else:
|
||||
logger.notifyChannel(_("email-template"), netsvc.LOG_ERROR, _("No personal email accounts are configured for you. \nEither ask admin to enforce an account for this template or get yourself a personal email account."))
|
||||
raise osv.except_osv(_("Missing mail account"),_("No personal email accounts are configured for you. \nEither ask admin to enforce an account for this template or get yourself a personal email account."))
|
||||
logger.notifyChannel(_("email-template"), netsvc.LOG_ERROR, _("No personal email accounts are configured for you. \nEither ask admin to enforce an account for this template or get yourself a personal email account."))
|
||||
raise osv.except_osv(_("Missing mail account"),_("No personal email accounts are configured for you. \nEither ask admin to enforce an account for this template or get yourself a personal email account."))
|
||||
|
||||
def get_value(self, cursor, user, template, message, context=None, id=None):
|
||||
"""Gets the value of the message parsed with the content of object id (or the first 'src_rec_ids' if id is not given)"""
|
||||
if context is None:
|
||||
context = {}
|
||||
if not message:
|
||||
return ''
|
||||
if not id:
|
||||
id = context['src_rec_ids'][0]
|
||||
id = context.get('src_rec_ids',[]) and context.get('src_rec_ids')[0]
|
||||
return get_value(cursor, user, id, message, template, context)
|
||||
|
||||
|
||||
def _get_template(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
email_temp_obj = self.pool.get('email.template')
|
||||
if not 'template' in context and not 'template_id' in context:
|
||||
return None
|
||||
if 'template_id' in context.keys():
|
||||
template_ids = self.pool.get('email.template').search(cr, uid, [('id','=',context['template_id'])], context=context)
|
||||
template_ids = email_temp_obj.search(cr, uid, [('id','=',context['template_id'])], context=context)
|
||||
elif 'template' in context.keys():
|
||||
# Old versions of email_template used the name of the template. This caused
|
||||
# problems when the user changed the name of the template, but we keep the code
|
||||
# for compatibility with those versions.
|
||||
template_ids = self.pool.get('email.template').search(cr, uid, [('name','=',context['template'])], context=context)
|
||||
template_ids = email_temp_obj.search(cr, uid, [('name','=',context['template'])], context=context)
|
||||
if not template_ids:
|
||||
return None
|
||||
|
||||
template = self.pool.get('email.template').browse(cr, uid, template_ids[0], context)
|
||||
|
||||
template = email_temp_obj.browse(cr, uid, template_ids[0], context)
|
||||
lang = self.get_value(cr, uid, template, template.lang, context)
|
||||
if lang:
|
||||
# Use translated template if necessary
|
||||
ctx = context.copy()
|
||||
ctx['lang'] = lang
|
||||
template = self.pool.get('email.template').browse(cr, uid, template.id, ctx)
|
||||
template = email_temp_obj.browse(cr, uid, template.id, ctx)
|
||||
return template
|
||||
|
||||
def _get_template_value(self, cr, uid, field, context=None):
|
||||
|
@ -103,6 +99,15 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
else: # Simple Mail: Gets computed template values
|
||||
return self.get_value(cr, uid, template, getattr(template, field), context)
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = super(email_template_send_wizard, self).default_get(cr, uid, fields, context=context)
|
||||
if 'template_id' in context and context.get('template_id'):
|
||||
temp_data = self.pool.get('email.template').read(cr, uid, int(context.get('template_id')), ['attachment_ids'])
|
||||
result['attachment_ids'] = temp_data['attachment_ids']
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'state':fields.selection([
|
||||
('single','Simple Mail Wizard Step 1'),
|
||||
|
@ -116,13 +121,13 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
'to':fields.char('To',size=250,required=True),
|
||||
'cc':fields.char('CC',size=250,),
|
||||
'bcc':fields.char('BCC',size=250,),
|
||||
'reply_to':fields.char('Reply-To',
|
||||
size=250,
|
||||
'reply_to':fields.char('Reply-To',
|
||||
size=250,
|
||||
help="The address recipients should reply to,"
|
||||
" if different from the From address."
|
||||
" Placeholders can be used here."),
|
||||
'message_id':fields.char('Message-ID',
|
||||
size=250,
|
||||
'message_id':fields.char('Message-ID',
|
||||
size=250,
|
||||
help="The Message-ID header value, if you need to"
|
||||
"specify it, for example to automatically recognize the replies later."
|
||||
" Placeholders can be used here."),
|
||||
|
@ -133,15 +138,15 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
'signature':fields.boolean('Attach my signature to mail'),
|
||||
#'filename':fields.text('File Name'),
|
||||
'requested':fields.integer('No of requested Mails',readonly=True),
|
||||
'generated':fields.integer('No of generated Mails',readonly=True),
|
||||
'generated':fields.integer('No of generated Mails',readonly=True),
|
||||
'full_success':fields.boolean('Complete Success',readonly=True),
|
||||
'attachment_ids': fields.many2many('ir.attachment','send_wizard_attachment_rel', 'wizard_id', 'attachment_id', 'Attachments'),
|
||||
}
|
||||
|
||||
#FIXME: probably better by overriding default_get directly
|
||||
#FIXME: probably better by overriding default_get directly
|
||||
_defaults = {
|
||||
'state': lambda self,cr,uid,ctx: len(ctx['src_rec_ids']) > 1 and 'multi' or 'single',
|
||||
'rel_model': lambda self,cr,uid,ctx: self.pool.get('ir.model').search(cr,uid,[('model','=',ctx['src_model'])],context=ctx)[0],
|
||||
'state': lambda self,cr,uid,ctx: len(ctx.get('src_rec_ids','')) > 1 and 'multi' or 'single',
|
||||
'rel_model': lambda self,cr,uid,ctx: self.pool.get('ir.model').search(cr,uid,[('model','=',ctx.get('src_model'))],context=ctx)[0],
|
||||
'rel_model_ref': lambda self,cr,uid,ctx: ctx['active_id'],
|
||||
'to': lambda self,cr,uid,ctx: self._get_template_value(cr, uid, 'def_to', ctx),
|
||||
'cc': lambda self,cr,uid,ctx: self._get_template_value(cr, uid, 'def_cc', ctx),
|
||||
|
@ -154,9 +159,7 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
'ref_template':lambda self,cr,uid,ctx: self._get_template(cr, uid, ctx).id,
|
||||
'reply_to': lambda self,cr,uid,ctx: self._get_template_value(cr, uid, 'reply_to', ctx),
|
||||
'reply_to': lambda self,cr,uid,ctx: self._get_template_value(cr, uid, 'reply_to', ctx),
|
||||
'requested':lambda self,cr,uid,ctx: len(ctx['src_rec_ids']),
|
||||
'full_success': False,
|
||||
'attachment_ids': [],
|
||||
'requested':lambda self,cr,uid,ctx: len(ctx.get('src_rec_ids','')),
|
||||
}
|
||||
|
||||
def fields_get(self, cr, uid, fields=None, context=None, write_access=True):
|
||||
|
@ -171,15 +174,15 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
mailid = self.save_to_mailbox(cr, uid, ids, context=context)
|
||||
if self.pool.get('email_template.mailbox').write(cr, uid, mailid, {'folder':'drafts'}, context):
|
||||
return {'type':'ir.actions.act_window_close' }
|
||||
self.pool.get('email.message').write(cr, uid, mailid, {'folder':'drafts', 'state': 'na'}, context)
|
||||
return {}
|
||||
|
||||
def send_mail(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
mailid = self.save_to_mailbox(cr, uid, ids, context)
|
||||
if self.pool.get('email_template.mailbox').write(cr, uid, mailid, {'folder':'outbox'}, context):
|
||||
return {'type':'ir.actions.act_window_close' }
|
||||
self.pool.get('email.message').write(cr, uid, mailid, {'folder':'outbox', 'state': 'waiting'}, context)
|
||||
return {}
|
||||
|
||||
def get_generated(self, cr, uid, ids=None, context=None):
|
||||
if ids is None:
|
||||
|
@ -187,11 +190,11 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
logger = netsvc.Logger()
|
||||
if context['src_rec_ids'] and len(context['src_rec_ids'])>1:
|
||||
if context.get('src_rec_ids'):
|
||||
#Means there are multiple items selected for email.
|
||||
mail_ids = self.save_to_mailbox(cr, uid, ids, context)
|
||||
if mail_ids:
|
||||
self.pool.get('email_template.mailbox').write(cr, uid, mail_ids, {'folder':'outbox'}, context)
|
||||
self.pool.get('email.message').write(cr, uid, mail_ids, {'folder':'outbox', 'state': 'waiting'}, context)
|
||||
logger.notifyChannel("email-template", netsvc.LOG_INFO, _("Emails for multiple items saved in outbox."))
|
||||
self.write(cr, uid, ids, {
|
||||
'generated':len(mail_ids),
|
||||
|
@ -200,48 +203,48 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
else:
|
||||
raise osv.except_osv(_("Email Template"),_("Email sending failed for one or more objects."))
|
||||
return True
|
||||
|
||||
|
||||
def save_to_mailbox(self, cr, uid, ids, context=None):
|
||||
def get_end_value(id, value):
|
||||
if len(context['src_rec_ids']) > 1: # Multiple Mail: Gets value from the template
|
||||
return self.get_value(cr, uid, template, value, context, id)
|
||||
else:
|
||||
return value
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
mail_ids = []
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
attahcment_obj = self.pool.get('ir.attachment')
|
||||
smtp_obj = self.pool.get('email.smtp_server')
|
||||
user_obj = self.pool.get('res.users')
|
||||
report_xml_obj = self.pool.get('ir.actions.report.xml')
|
||||
model_obj = self.pool.get('ir.model')
|
||||
template = self._get_template(cr, uid, context)
|
||||
for id in context['src_rec_ids']:
|
||||
screen_vals = self.read(cr, uid, ids[0], [],context)
|
||||
account = self.pool.get('email_template.account').read(cr, uid, screen_vals['from'], context=context)
|
||||
for id in context.get('src_rec_ids',[]):
|
||||
screen_vals = self.read(cr, uid, ids[0], [], context)
|
||||
smtp_data = smtp_obj.browse(cr, uid, screen_vals['from'], context=context)
|
||||
vals = {
|
||||
'email_from': tools.ustr(account['name']) + "<" + tools.ustr(account['email_id']) + ">",
|
||||
'email_from': tools.ustr(smtp_data.name) + "<" + tools.ustr(smtp_data.email_id) + ">",
|
||||
'email_to': get_end_value(id, screen_vals['to']),
|
||||
'email_cc': get_end_value(id, screen_vals['cc']),
|
||||
'email_bcc': get_end_value(id, screen_vals['bcc']),
|
||||
'subject': get_end_value(id, screen_vals['subject']),
|
||||
'body_text': get_end_value(id, screen_vals['body_text']),
|
||||
'body_html': get_end_value(id, screen_vals['body_html']),
|
||||
'account_id': screen_vals['from'],
|
||||
'name': get_end_value(id, screen_vals['subject']),
|
||||
'description': get_end_value(id, screen_vals['body_text']) + "\n" + get_end_value(id, screen_vals['body_html'] or ''),
|
||||
'state':'na',
|
||||
'mail_type':'multipart/alternative' #Options:'multipart/mixed','multipart/alternative','text/plain','text/html'
|
||||
}
|
||||
if screen_vals['signature']:
|
||||
signature = self.pool.get('res.users').read(cr, uid, uid, ['signature'], context)['signature']
|
||||
signature = user_obj.browse(cr, uid, uid, context).signature
|
||||
if signature:
|
||||
vals['body_text'] = tools.ustr(vals['body_text'] or '') + signature
|
||||
vals['body_html'] = tools.ustr(vals['body_html'] or '') + signature
|
||||
vals['description'] = tools.ustr(vals['description'] or '') + signature
|
||||
|
||||
attachment_ids = []
|
||||
|
||||
#Create partly the mail and later update attachments
|
||||
mail_id = self.pool.get('email_template.mailbox').create(cr, uid, vals, context)
|
||||
mail_id = email_message_obj.create(cr, uid, vals, context)
|
||||
mail_ids.append(mail_id)
|
||||
if template.report_template:
|
||||
reportname = 'report.' + self.pool.get('ir.actions.report.xml').read(cr, uid, template.report_template.id, ['report_name'], context)['report_name']
|
||||
reportname = 'report.' + report_xml_obj.browse(cr, uid, template.report_template.id, context).report_name
|
||||
data = {}
|
||||
data['model'] = self.pool.get('ir.model').browse(cr, uid, screen_vals['rel_model'], context).model
|
||||
data['model'] = model_obj.browse(cr, uid, screen_vals['rel_model'], context).model
|
||||
|
||||
# Ensure report is rendered using template's language
|
||||
ctx = context.copy()
|
||||
|
@ -249,31 +252,29 @@ class email_template_send_wizard(osv.osv_memory):
|
|||
ctx['lang'] = self.get_value(cr, uid, template, template.lang, context, id)
|
||||
service = netsvc.LocalService(reportname)
|
||||
(result, format) = service.create(cr, uid, [id], data, ctx)
|
||||
attachment_id = self.pool.get('ir.attachment').create(cr, uid, {
|
||||
'name': _('%s (Email Attachment)') % tools.ustr(vals['subject']),
|
||||
attachment_id = attahcment_obj.create(cr, uid, {
|
||||
'name': _('%s (Email Attachment)') % tools.ustr(vals['name']),
|
||||
'datas': base64.b64encode(result),
|
||||
'datas_fname': tools.ustr(get_end_value(id, screen_vals['report']) or _('Report')) + "." + format,
|
||||
'description': vals['body_text'] or _("No Description"),
|
||||
'res_model': 'email_template.mailbox',
|
||||
'description': vals['description'] or _("No Description"),
|
||||
'res_model': 'email.message',
|
||||
'res_id': mail_id
|
||||
}, context)
|
||||
attachment_ids.append( attachment_id )
|
||||
attachment_ids.append(attachment_id)
|
||||
|
||||
# Add document attachments
|
||||
for attachment_id in screen_vals.get('attachment_ids',[]):
|
||||
new_id = self.pool.get('ir.attachment').copy(cr, uid, attachment_id, {
|
||||
'res_model': 'email_template.mailbox',
|
||||
new_id = attahcment_obj.copy(cr, uid, attachment_id, {
|
||||
'res_model': 'email.message',
|
||||
'res_id': mail_id,
|
||||
}, context)
|
||||
attachment_ids.append( new_id )
|
||||
|
||||
attachment_ids.append(new_id)
|
||||
if attachment_ids:
|
||||
self.pool.get('email_template.mailbox').write(cr, uid, mail_id, {
|
||||
'attachments_ids': [[6, 0, attachment_ids]],
|
||||
'mail_type': 'multipart/mixed'
|
||||
email_message_obj.write(cr, uid, mail_id, {
|
||||
'attachment_ids': [[6, 0, attachment_ids]],
|
||||
}, context)
|
||||
|
||||
return mail_ids
|
||||
|
||||
email_template_send_wizard()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -2,62 +2,58 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="email_template_send_wizard_form">
|
||||
<field name="name">email_template.send.wizard.form</field>
|
||||
<field name="model">email_template.send.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Send mail Wizard">
|
||||
<group col="4" colspan="4">
|
||||
<field name="rel_model" colspan="2" />
|
||||
<field name="from" required="1" colspan="2" />
|
||||
</group>
|
||||
<group col="4" colspan="4">
|
||||
<group col="6" colspan="4">
|
||||
<field name="to" select="1" colspan="4" />
|
||||
<newline />
|
||||
<field name="cc" select="2" colspan="4" />
|
||||
<newline />
|
||||
<field name="bcc" select="2" colspan="4" />
|
||||
<newline />
|
||||
<field name="subject" select="2" colspan="4" attrs="{'required':[('state','=','single')]}" />
|
||||
<newline />
|
||||
<field name="report" colspan="4" />
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<notebook colspan="4">
|
||||
<page string="Body (Plain Text)">
|
||||
<field name="body_text" select="2" colspan="4" nolabel="1" />
|
||||
</page>
|
||||
<page string="Body (HTML)">
|
||||
<field name="body_html" select="2" 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"/>
|
||||
<field name="attachment_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="signature" colspan="4" />
|
||||
</group>
|
||||
<group col="4" colspan="4" attrs="{'invisible':[('state','!=','single')]}">
|
||||
<button icon="gtk-apply" name="sav_to_drafts" string="Save in Drafts" type="object" />
|
||||
<button icon="gtk-ok" name="send_mail" string="Send now" type="object" />
|
||||
<button icon="gtk-cancel" special="cancel" string="Discard Mail" />
|
||||
</group>
|
||||
<group col="4" colspan="4" attrs="{'invisible':[('state','=','single')]}">
|
||||
<label string="Tip: Multiple emails are sent in the same language (the first one is proposed). We suggest you send emails in groups according to language." colspan="4"/>
|
||||
<field name="requested" />
|
||||
<field name="generated" />
|
||||
<button icon="gtk-ok" name="get_generated" string="Send all mails" type="object" states="multi" colspan="2" />
|
||||
<button icon="gtk-cancel" special="cancel" string="Discard Mail" colspan="2" states="multi" />
|
||||
</group>
|
||||
<button icon="gtk-ok" special="cancel" string="Close" colspan="4" states="done" />
|
||||
<field name="state" />
|
||||
<newline />
|
||||
<label string="After clicking send all mails, mails will be sent to outbox and cleared in next Send/Recieve" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
<record model="ir.ui.view" id="email_template_send_wizard_form">
|
||||
<field name="name">email_template.send.wizard.form</field>
|
||||
<field name="model">email_template.send.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Send mail Wizard">
|
||||
<group col="4" colspan="4">
|
||||
<field name="rel_model" colspan="2"/>
|
||||
<field name="from" required="1" colspan="2"/>
|
||||
</group>
|
||||
<group col="4" colspan="4">
|
||||
<group col="6" colspan="4">
|
||||
<field name="to" colspan="4"/>
|
||||
<field name="cc" colspan="4"/>
|
||||
<field name="bcc" colspan="4"/>
|
||||
<field name="subject" colspan="4" attrs="{'required':[('state','=','single')]}"/>
|
||||
<field name="report" colspan="4"/>
|
||||
</group>
|
||||
<separator string="" colspan="4"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Body (Plain Text)">
|
||||
<field name="body_text" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Body (HTML)">
|
||||
<field name="body_html" 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"/>
|
||||
<field name="attachment_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="signature" colspan="4"/>
|
||||
</group>
|
||||
<group col="4" colspan="4" attrs="{'invisible':[('state','!=','single')]}">
|
||||
<button icon="gtk-apply" name="sav_to_drafts" string="Save in Drafts" type="object"/>
|
||||
<button icon="gtk-ok" name="send_mail" string="Send now" type="object"/>
|
||||
<button icon="gtk-cancel" special="cancel" string="Discard Mail"/>
|
||||
</group>
|
||||
<group col="4" colspan="4" attrs="{'invisible':[('state','=','single')]}">
|
||||
<label string="Tip: Multiple emails are sent in the same language (the first one is proposed). We suggest you send emails in groups according to language." colspan="4"/>
|
||||
<field name="requested"/>
|
||||
<field name="generated"/>
|
||||
<button icon="gtk-ok" name="get_generated" string="Send all mails" type="object" states="multi" colspan="2"/>
|
||||
<button icon="gtk-cancel" special="cancel" string="Discard Mail" colspan="2" states="multi"/>
|
||||
</group>
|
||||
<button icon="gtk-ok" special="cancel" string="Close" colspan="4" states="done"/>
|
||||
<field name="state"/>
|
||||
<newline/>
|
||||
<label string="After clicking send all mails, mails will be sent to outbox and cleared in next Send/Recieve" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +1,27 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import email_smtp_server
|
||||
import email_message
|
||||
import res_partner
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
'name': 'Email System',
|
||||
'version': '1.0',
|
||||
'category': 'Generic Modules/Mail Service',
|
||||
'description': """The generic email system allows to send and receive emails
|
||||
* SMTP Server Configuration
|
||||
* Provide API for Sending Messages
|
||||
* Store all emails releated messages """,
|
||||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'depends': ['base', 'base_tools'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
"email_view.xml",
|
||||
"res_partner_view.xml",
|
||||
'security/ir.model.access.csv',
|
||||
'email_data.xml',
|
||||
|
||||
],
|
||||
'demo_xml': [],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
'certificate': False,
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,14 +1,24 @@
|
|||
<?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 Template scheduler</field>
|
||||
<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_template.mailbox'" name="model"/>
|
||||
<field eval="'email.message'" name="model"/>
|
||||
<field eval="'run_mail_scheduler'" name="function"/>
|
||||
<field eval="'()'" name="args"/>
|
||||
</record>
|
|
@ -0,0 +1,380 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
from tools.translate import _
|
||||
import tools
|
||||
import netsvc
|
||||
|
||||
import time
|
||||
#import binascii
|
||||
#import email
|
||||
#from email.header import decode_header
|
||||
#from email.utils import parsedate
|
||||
#import base64
|
||||
#import re
|
||||
#import logging
|
||||
#import xmlrpclib
|
||||
|
||||
#import re
|
||||
#import smtplib
|
||||
#import base64
|
||||
#from email import Encoders
|
||||
#from email.mime.base import MIMEBase
|
||||
#from email.mime.multipart import MIMEMultipart
|
||||
#from email.mime.text import MIMEText
|
||||
#from email.header import decode_header, Header
|
||||
#from email.utils import formatdate
|
||||
#import netsvc
|
||||
#import datetime
|
||||
#import tools
|
||||
#import logging
|
||||
#email_content_types = [
|
||||
# 'multipart/mixed',
|
||||
# 'multipart/alternative',
|
||||
# 'multipart/related',
|
||||
# 'text/plain',
|
||||
# 'text/html'
|
||||
#]
|
||||
|
||||
LOGGER = netsvc.Logger()
|
||||
|
||||
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(osv.osv):
|
||||
'''
|
||||
Email Message
|
||||
'''
|
||||
_name = 'email.message'
|
||||
_description = 'Email Message'
|
||||
_order = 'date desc'
|
||||
|
||||
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
|
||||
|
||||
_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),
|
||||
'date': fields.datetime('Date', 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."),
|
||||
'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'),
|
||||
'reply_to':fields.char('Reply-To', size=250, readonly=True),
|
||||
'sub_type': fields.char('Sub Type', size=32, readonly=True),
|
||||
'headers': fields.char('x_headers',size=256, readonly=True),
|
||||
'priority':fields.integer('Priority', readonly=True),
|
||||
'debug':fields.boolean('Debug', readonly=True),
|
||||
'history': fields.boolean('History', readonly=True),
|
||||
'description': fields.text('Description', readonly=True),
|
||||
#I like GMAIL which allows putting same mail in many folders
|
||||
#Lets plan it for 0.9
|
||||
'folder':fields.selection([
|
||||
('drafts', 'Drafts'),
|
||||
('outbox', 'Outbox'),
|
||||
('trash', 'Trash'),
|
||||
('sent', 'Sent Items'),
|
||||
], 'Folder', readonly=True),
|
||||
'state':fields.selection([
|
||||
('na', 'Not Applicable'),
|
||||
('sending', 'Sending'),
|
||||
('waiting', 'Waiting'),
|
||||
], 'State', readonly=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state': lambda * a: 'na',
|
||||
'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
|
||||
WHERE indexname = 'email_message_res_id_model_idx'""")
|
||||
if not cr.fetchone():
|
||||
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,
|
||||
openobject_id=False, debug=False, subtype='plain', x_headers={}, priority='3', context=None):
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
msg_vals = {
|
||||
'name': subject,
|
||||
'model': model or '',
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
'user_id': uid,
|
||||
'description': body,
|
||||
'email_from': email_from,
|
||||
'email_to': email_to and ','.join(email_to) or '',
|
||||
'email_cc': email_cc and ','.join(email_cc) or '',
|
||||
'email_bcc': email_bcc and ','.join(email_bcc) or '',
|
||||
'reply_to': reply_to and ','.join(reply_to) or '',
|
||||
'message_id': openobject_id,
|
||||
'sub_type': subtype or '',
|
||||
'headers': x_headers or False,
|
||||
'priority': priority,
|
||||
'debug': debug,
|
||||
'folder': 'outbox',
|
||||
'state': 'waiting',
|
||||
}
|
||||
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)'),
|
||||
'datas': attachment[1],
|
||||
'datas_fname': attachment[0],
|
||||
'description': subject or _('No Description'),
|
||||
'res_model':'email.message',
|
||||
'res_id': email_msg_id,
|
||||
}
|
||||
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 True
|
||||
|
||||
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')
|
||||
account_obj = self.pool.get('email.smtp_server')
|
||||
if not ids:
|
||||
filters = [('folder', '=', 'outbox'), ('state', '!=', 'sending')]
|
||||
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)
|
||||
for message in self.browse(cr, uid, ids, context):
|
||||
try:
|
||||
attachments = []
|
||||
for attach in message.attachment_ids:
|
||||
attachments.append((attach.datas_fname ,attach.datas))
|
||||
smtp_account = False
|
||||
smtp_ids = account_obj.search(cr, uid, [('default','=',True)])
|
||||
if smtp_ids:
|
||||
smtp_account = account_obj.browse(cr, uid, smtp_ids, context)[0]
|
||||
tools.email_send(message.email_from,
|
||||
message.email_to and message.email_to.split(',') or [],
|
||||
message.name, message.description,
|
||||
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 and message.reply_to.split(',') or [],
|
||||
attach=attachments, openobject_id=message.message_id,
|
||||
subtype=message.sub_type,
|
||||
x_headers=message.headers and eval(message.headers) or {},
|
||||
priority=message.priority, debug=message.debug,
|
||||
smtp_email_from=smtp_account and smtp_account.email_id or None,
|
||||
smtp_server=smtp_account and smtp_account.smtpserver or None,
|
||||
smtp_port=smtp_account and smtp_account.smtpport or None,
|
||||
ssl=smtp_account and smtp_account.smtpssl or False,
|
||||
smtp_user=smtp_account and smtp_account.smtpuname or None,
|
||||
smtp_password=smtp_account and smtp_account.smtppass or None)
|
||||
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))
|
||||
return ids
|
||||
|
||||
# OLD Code.
|
||||
# def send_all_mail(self, cr, uid, ids=None, context=None):
|
||||
# if ids is None:
|
||||
# ids = []
|
||||
# if context is None:
|
||||
# context = {}
|
||||
# filters = [('folder', '=', 'outbox'), ('state', '!=', 'sending')]
|
||||
# if 'filters' in context.keys():
|
||||
# for each_filter in context['filters']:
|
||||
# filters.append(each_filter)
|
||||
# ids = self.search(cr, uid, filters, context=context)
|
||||
# self.write(cr, uid, ids, {'state':'sending'}, context)
|
||||
# self.send_this_mail(cr, uid, ids, context)
|
||||
# return True
|
||||
#
|
||||
# def send_this_mail(self, cr, uid, ids=None, context=None):
|
||||
# #previous method to send email (link with email account can be found at the revision 4172 and below
|
||||
# result = True
|
||||
# attachment_pool = self.pool.get('ir.attachment')
|
||||
# for id in (ids or []):
|
||||
# try:
|
||||
# account_obj = self.pool.get('email.smtp_server')
|
||||
# values = self.read(cr, uid, id, [], context)
|
||||
# payload = {}
|
||||
# if values['attachments_ids']:
|
||||
# for attid in values['attachments_ids']:
|
||||
# attachment = attachment_pool.browse(cr, uid, attid, context)#,['datas_fname','datas'])
|
||||
# payload[attachment.datas_fname] = attachment.datas
|
||||
# result = account_obj.send_email(cr, uid,
|
||||
# [values['account_id'][0]],
|
||||
# {'To':values.get('email_to') or u'',
|
||||
# 'CC':values.get('email_cc') or u'',
|
||||
# 'BCC':values.get('email_bcc') or u'',
|
||||
# 'Reply-To':values.get('reply_to') or u''},
|
||||
# values['subject'] or u'',
|
||||
# {'text':values.get('body_text') or u'', 'html':values.get('body_html') or u''},
|
||||
# payload=payload,
|
||||
# message_id=values['message_id'],
|
||||
# context=context)
|
||||
# if result == True:
|
||||
# account = account_obj.browse(cr, uid, values['account_id'][0], context=context)
|
||||
# if account.auto_delete:
|
||||
# self.write(cr, uid, id, {'folder': 'trash'}, context=context)
|
||||
# self.unlink(cr, uid, [id], context=context)
|
||||
# # Remove attachments for this mail
|
||||
# attachment_pool.unlink(cr, uid, values['attachments_ids'], context=context)
|
||||
# else:
|
||||
# self.write(cr, uid, id, {'folder':'sent', 'state':'na', 'date_mail':time.strftime("%Y-%m-%d %H:%M:%S")}, context)
|
||||
# else:
|
||||
# error = result['error_msg']
|
||||
#
|
||||
# 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") % (id, error))
|
||||
# self.write(cr, uid, id, {'state':'na'}, context)
|
||||
# return result
|
||||
|
||||
email_message()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,423 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
from tools.translate import _
|
||||
import tools
|
||||
|
||||
#import time
|
||||
#import binascii
|
||||
#import email
|
||||
#from email.header import decode_header
|
||||
#from email.utils import parsedate
|
||||
#import base64
|
||||
#import re
|
||||
#import logging
|
||||
#import xmlrpclib
|
||||
|
||||
#_logger = logging.getLogger('mailgate')
|
||||
|
||||
#import re
|
||||
import smtplib
|
||||
#import base64
|
||||
#from email import Encoders
|
||||
#from email.mime.base import MIMEBase
|
||||
#from email.mime.multipart import MIMEMultipart
|
||||
#from email.mime.text import MIMEText
|
||||
#from email.header import decode_header, Header
|
||||
#from email.utils import formatdate
|
||||
#import netsvc
|
||||
#import datetime
|
||||
#import tools
|
||||
#import logging
|
||||
|
||||
#EMAIL_PATTERN = re.compile(r'([^()\[\] ,<:\\>@";]+@[^()\[\] ,<:\\>@";]+)') # See RFC822
|
||||
#def extract_emails(emails_str):
|
||||
# """
|
||||
# Returns a list of email addresses recognized in a string, ignoring the rest of the string.
|
||||
# extract_emails('a@b.com,c@bcom, "John Doe" <d@b.com> , e@b.com') -> ['a@b.com','c@bcom', 'd@b.com', 'e@b.com']"
|
||||
# """
|
||||
# return EMAIL_PATTERN.findall(emails_str)
|
||||
#
|
||||
#
|
||||
#def extract_emails_from_dict(addresses={}):
|
||||
# """
|
||||
# Extracts email addresses from a dictionary with comma-separated address string values, handling
|
||||
# separately the To, CC, BCC and Reply-To addresses.
|
||||
#
|
||||
# :param addresses: a dictionary of addresses in the form {'To': 'a@b.com,c@bcom; d@b.com;e@b.com' , 'CC': 'e@b.com;f@b.com', ... }
|
||||
# :return: a dictionary with a list of separate addresses for each header (To, CC, BCC), with an additional key 'all-recipients'
|
||||
# containing all addresses for the 'To', 'CC', 'BCC' entries.
|
||||
# """
|
||||
# result = {'all-recipients':[]}
|
||||
# keys = ['To', 'CC', 'BCC', 'Reply-To']
|
||||
# for each in keys:
|
||||
# emails = extract_emails(addresses.get(each, u''))
|
||||
# while u'' in emails:
|
||||
# emails.remove(u'')
|
||||
# result[each] = emails
|
||||
# if each != 'Reply-To':
|
||||
# result['all-recipients'].extend(emails)
|
||||
# return result
|
||||
|
||||
class email_smtp_server(osv.osv):
|
||||
"""
|
||||
SMTP Server
|
||||
"""
|
||||
_name = "email.smtp_server"
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name',
|
||||
size=64, required=True,
|
||||
readonly=True, select=True,
|
||||
help="The Name is used as the Sender name along with the provided From Email, \
|
||||
unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
|
||||
states={'draft':[('readonly', False)]}),
|
||||
'email_id': fields.char('From Email',
|
||||
size=120, required=True,
|
||||
readonly=True, states={'draft':[('readonly', False)]} ,
|
||||
help="eg: 'john@doe.com' or 'John Doe <john@doe.com>'"),
|
||||
'smtpserver': fields.char('Server',
|
||||
size=120, required=True,
|
||||
readonly=True, states={'draft':[('readonly', False)]},
|
||||
help="Enter name of outgoing server, eg: smtp.yourdomain.com"),
|
||||
'smtpport': fields.integer('SMTP Port',
|
||||
size=64, required=True,
|
||||
readonly=True, states={'draft':[('readonly', False)]},
|
||||
help="Enter port number, eg: 25 or 587"),
|
||||
'smtpuname': fields.char('User Name',
|
||||
size=120, required=False,
|
||||
readonly=True, states={'draft':[('readonly', False)]},
|
||||
help="Specify the username if your SMTP server requires authentication, "
|
||||
"otherwise leave it empty."),
|
||||
'smtppass': fields.char('Password',
|
||||
size=120, invisible=True,
|
||||
required=False, readonly=True,
|
||||
states={'draft':[('readonly', False)]}),
|
||||
'smtptls':fields.boolean('TLS',
|
||||
states={'draft':[('readonly', False)]}, readonly=True),
|
||||
'smtpssl':fields.boolean('SSL/TLS (only in python 2.6)',
|
||||
states={'draft':[('readonly', False)]}, readonly=True),
|
||||
'default': fields.boolean('Default', help="Only one account can be default at a time"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'name':lambda self, cursor, user, context:self.pool.get( 'res.users'
|
||||
).read(cursor, user, user, ['name'], context)['name'],
|
||||
'smtpport':lambda *a:25,
|
||||
'smtpserver':lambda *a:'localhost',
|
||||
'smtptls':lambda *a:True,
|
||||
}
|
||||
|
||||
_sql_constraints = [
|
||||
(
|
||||
'email_uniq',
|
||||
'unique (email_id)',
|
||||
'Another setting already exists with this email ID !')
|
||||
]
|
||||
|
||||
def _constraint_unique(self, cr, uid, ids, context=None):
|
||||
default_ids = self.search(cr, uid, [('default','=',True)])
|
||||
if len(default_ids) > 1:
|
||||
return False
|
||||
elif not default_ids:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_constraint_unique,
|
||||
'Error: You must be define one default smtp server account !.',
|
||||
[])
|
||||
]
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
return [(a["id"], "%s (%s)" % (a['email_id'], a['name'])) for a in self.read(cr, uid, ids, ['name', 'email_id'], context=context)]
|
||||
|
||||
def get_outgoing_server(self, cursor, user, id, context=None):
|
||||
"""
|
||||
Returns the Out Going Connection (SMTP) object
|
||||
|
||||
@attention: DO NOT USE except_osv IN THIS METHOD
|
||||
@param cursor: Database Cursor
|
||||
@param user: ID of current user
|
||||
@param ids: ID/list of ids of current object for
|
||||
which connection is required
|
||||
First ID will be chosen from lists
|
||||
@param context: Context
|
||||
|
||||
@return: SMTP server object or Exception
|
||||
"""
|
||||
#Type cast ids to integer
|
||||
if type(id) == list:
|
||||
id = id[0]
|
||||
smtp_data = self.browse(cursor, user, id, context=context)
|
||||
if smtp_data:
|
||||
if smtp_data.smtpserver and smtp_data.smtpport:
|
||||
try:
|
||||
if smtp_data.smtpssl:
|
||||
serv = smtplib.SMTP_SSL(smtp_data.smtpserver, smtp_data.smtpport)
|
||||
else:
|
||||
serv = smtplib.SMTP(smtp_data.smtpserver, smtp_data.smtpport)
|
||||
if smtp_data.smtptls:
|
||||
serv.ehlo()
|
||||
serv.starttls()
|
||||
serv.ehlo()
|
||||
except Exception, error:
|
||||
raise error
|
||||
try:
|
||||
if serv.has_extn('AUTH') or smtp_data.smtpuname or smtp_data.smtppass:
|
||||
serv.login(str(smtp_data.smtpuname), str(smtp_data.smtppass))
|
||||
except Exception, error:
|
||||
raise error
|
||||
return serv
|
||||
raise Exception(_("SMTP SERVER or PORT not specified"))
|
||||
raise Exception(_("Core connection for the given ID does not exist"))
|
||||
|
||||
def check_outgoing_connection(self, cursor, user, ids, context=None):
|
||||
"""
|
||||
checks SMTP credentials and confirms if outgoing connection works
|
||||
(Attached to button)
|
||||
@param cursor: Database Cursor
|
||||
@param user: ID of current user
|
||||
@param ids: list of ids of current object for
|
||||
which connection is required
|
||||
@param context: Context
|
||||
"""
|
||||
try:
|
||||
for id in ids:
|
||||
self.get_outgoing_server(cursor, user, id, context)
|
||||
raise osv.except_osv(_("SMTP Test Connection Was Successful"), '')
|
||||
except osv.except_osv, success_message:
|
||||
raise success_message
|
||||
except Exception, error:
|
||||
raise osv.except_osv(
|
||||
_("Out going connection test failed"),
|
||||
_("Reason: %s") % error
|
||||
)
|
||||
|
||||
# def do_approval(self, cr, uid, ids, context=None):
|
||||
# #TODO: Check if user has rights
|
||||
# self.write(cr, uid, ids, {'state':'approved'}, context=context)
|
||||
## wf_service = netsvc.LocalService("workflow")
|
||||
#
|
||||
# def smtp_connection(self, cursor, user, id, context=None):
|
||||
# """
|
||||
# This method should now wrap smtp_connection
|
||||
# """
|
||||
# #This function returns a SMTP server object
|
||||
# logger = netsvc.Logger()
|
||||
# core_obj = self.browse(cursor, user, id, context=context)
|
||||
# if core_obj.smtpserver and core_obj.smtpport and core_obj.state == 'approved':
|
||||
# try:
|
||||
# serv = self.get_outgoing_server(cursor, user, id, context)
|
||||
# except Exception, error:
|
||||
# logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed on login. Probable Reason:Could not login to server\nError: %s") % (id, error))
|
||||
# return False
|
||||
# #Everything is complete, now return the connection
|
||||
# return serv
|
||||
# else:
|
||||
# logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Account not approved") % id)
|
||||
# return False
|
||||
#
|
||||
##**************************** MAIL SENDING FEATURES ***********************#
|
||||
# def send_email(self, cr, uid, ids, addresses, subject='', body=None, payload=None, message_id=None, context=None):
|
||||
# #TODO: Replace all this with a single email object
|
||||
# if body is None:
|
||||
# body = {}
|
||||
# if payload is None:
|
||||
# payload = {}
|
||||
# if context is None:
|
||||
# context = {}
|
||||
# logger = netsvc.Logger()
|
||||
# for id in ids:
|
||||
# core_obj = self.browse(cr, uid, id, context)
|
||||
# serv = self.smtp_connection(cr, uid, id)
|
||||
# if serv:
|
||||
# try:
|
||||
# # Need a multipart/mixed wrapper for attachments if content is alternative
|
||||
# if payload:
|
||||
# payload_part = MIMEMultipart(_subtype='mixed')
|
||||
# text_part = MIMEMultipart(_subtype='mixed')
|
||||
# payload_part.attach(text_part)
|
||||
# else:
|
||||
# # otherwise a single multipart/mixed will do the whole job
|
||||
# payload_part = text_part = MIMEMultipart(_subtype='mixed')
|
||||
#
|
||||
# if subject:
|
||||
# payload_part['Subject'] = subject
|
||||
# from_email = core_obj.email_id
|
||||
# if '<' in from_email:
|
||||
# # We have a structured email address, keep it untouched
|
||||
# payload_part['From'] = Header(core_obj.email_id, 'utf-8').encode()
|
||||
# else:
|
||||
# # Plain email address, construct a structured one based on the name:
|
||||
# sender_name = Header(core_obj.name, 'utf-8').encode()
|
||||
# payload_part['From'] = sender_name + " <" + core_obj.email_id + ">"
|
||||
# payload_part['Organization'] = tools.ustr(core_obj.user.company_id.name)
|
||||
# payload_part['Date'] = formatdate()
|
||||
# addresses_l = extract_emails_from_dict(addresses)
|
||||
# if addresses_l['To']:
|
||||
# payload_part['To'] = u','.join(addresses_l['To'])
|
||||
# if addresses_l['CC']:
|
||||
# payload_part['CC'] = u','.join(addresses_l['CC'])
|
||||
# if addresses_l['Reply-To']:
|
||||
# payload_part['Reply-To'] = addresses_l['Reply-To'][0]
|
||||
# if message_id:
|
||||
# payload_part['Message-ID'] = message_id
|
||||
# if body.get('text', False):
|
||||
# temp_body_text = body.get('text', '')
|
||||
# l = len(temp_body_text.replace(' ', '').replace('\r', '').replace('\n', ''))
|
||||
# if l == 0:
|
||||
# body['text'] = u'No Mail Message'
|
||||
# # Attach parts into message container.
|
||||
# # According to RFC 2046, the last part of a multipart message, in this case
|
||||
# # the HTML message, is best and preferred.
|
||||
## if core_obj.send_pref in ('text', 'mixed', 'alternative'):
|
||||
## body_text = body.get('text', u'<Empty Message>')
|
||||
## body_text = tools.ustr(body_text)
|
||||
## text_part.attach(MIMEText(body_text.encode("utf-8"), _charset='UTF-8'))
|
||||
## if core_obj.send_pref in ('html', 'mixed', 'alternative'):
|
||||
# html_body = body.get('html', u'')
|
||||
# if len(html_body) == 0 or html_body == u'':
|
||||
# html_body = body.get('text', u'<p><Empty Message></p>').replace('\n', '<br/>').replace('\r', '<br/>')
|
||||
# html_body = tools.ustr(html_body)
|
||||
# text_part.attach(MIMEText(html_body.encode("utf-8"), _subtype='html', _charset='UTF-8'))
|
||||
#
|
||||
# #Now add attachments if any, wrapping into a container multipart/mixed if needed
|
||||
# if payload:
|
||||
# for file in payload:
|
||||
# part = MIMEBase('application', "octet-stream")
|
||||
# part.set_payload(base64.decodestring(payload[file]))
|
||||
# part.add_header('Content-Disposition', 'attachment; filename="%s"' % file)
|
||||
# Encoders.encode_base64(part)
|
||||
# payload_part.attach(part)
|
||||
# except Exception, error:
|
||||
# logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:MIME Error\nDescription: %s") % (id, error))
|
||||
# return {'error_msg': _("Server Send Error\nDescription: %s")%error}
|
||||
# try:
|
||||
# serv.sendmail(payload_part['From'], addresses_l['all-recipients'], payload_part.as_string())
|
||||
# except Exception, error:
|
||||
# logging.getLogger('email_template').error(_("Mail from Account %s failed. Probable Reason: Server Send Error\n Description: %s"), id, error, exc_info=True)
|
||||
# return {'error_msg': _("Server Send Error\nDescription: %s")%error}
|
||||
# #The mail sending is complete
|
||||
# serv.close()
|
||||
# logger.notifyChannel(_("Email Template"), netsvc.LOG_INFO, _("Mail from Account %s successfully Sent.") % (id))
|
||||
# return True
|
||||
# else:
|
||||
# logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Account not approved") % id)
|
||||
# return {'nodestroy':True,'error_msg': _("Mail from Account %s failed. Probable Reason:Account not approved")% id}
|
||||
#
|
||||
# def extracttime(self, time_as_string):
|
||||
# """
|
||||
# TODO: DOC THis
|
||||
# """
|
||||
# logger = netsvc.Logger()
|
||||
# #The standard email dates are of format similar to:
|
||||
# #Thu, 8 Oct 2009 09:35:42 +0200
|
||||
# date_as_date = False
|
||||
# convertor = {'+':1, '-':-1}
|
||||
# try:
|
||||
# time_as_string = time_as_string.replace(',', '')
|
||||
# date_list = time_as_string.split(' ')
|
||||
# date_temp_str = ' '.join(date_list[1:5])
|
||||
# if len(date_list) >= 6:
|
||||
# sign = convertor.get(date_list[5][0], False)
|
||||
# else:
|
||||
# sign = False
|
||||
# try:
|
||||
# dt = datetime.datetime.strptime(
|
||||
# date_temp_str,
|
||||
# "%d %b %Y %H:%M:%S")
|
||||
# except:
|
||||
# try:
|
||||
# dt = datetime.datetime.strptime(
|
||||
# date_temp_str,
|
||||
# "%d %b %Y %H:%M")
|
||||
# except:
|
||||
# return False
|
||||
# if sign:
|
||||
# try:
|
||||
# offset = datetime.timedelta(
|
||||
# hours=sign * int(
|
||||
# date_list[5][1:3]
|
||||
# ),
|
||||
# minutes=sign * int(
|
||||
# date_list[5][3:5]
|
||||
# )
|
||||
# )
|
||||
# except Exception, e2:
|
||||
# """Looks like UT or GMT, just forget decoding"""
|
||||
# return False
|
||||
# else:
|
||||
# offset = datetime.timedelta(hours=0)
|
||||
# dt = dt + offset
|
||||
# date_as_date = dt.strftime('%Y-%m-%d %H:%M:%S')
|
||||
# except Exception, e:
|
||||
# logger.notifyChannel(
|
||||
# _("Email Template"),
|
||||
# netsvc.LOG_WARNING,
|
||||
# _(
|
||||
# "Datetime Extraction failed.Date:%s \
|
||||
# \tError:%s") % (
|
||||
# time_as_string,
|
||||
# e)
|
||||
# )
|
||||
# return date_as_date
|
||||
#
|
||||
# def send_receive(self, cr, uid, ids, context=None):
|
||||
# for id in ids:
|
||||
# ctx = context.copy()
|
||||
# ctx['filters'] = [('account_id', '=', id)]
|
||||
# self.pool.get('email.message').send_all_mail(cr, uid, [], context=ctx)
|
||||
# return True
|
||||
#
|
||||
# def decode_header_text(self, text):
|
||||
# """ Decode internationalized headers RFC2822.
|
||||
# To, CC, BCC, Subject fields can contain
|
||||
# text slices with different encodes, like:
|
||||
# =?iso-8859-1?Q?Enric_Mart=ED?= <enricmarti@company.com>,
|
||||
# =?Windows-1252?Q?David_G=F3mez?= <david@company.com>
|
||||
# Sometimes they include extra " character at the beginning/
|
||||
# end of the contact name, like:
|
||||
# "=?iso-8859-1?Q?Enric_Mart=ED?=" <enricmarti@company.com>
|
||||
# and decode_header() does not work well, so we use regular
|
||||
# expressions (?= ? ? ?=) to split the text slices
|
||||
# """
|
||||
# if not text:
|
||||
# return text
|
||||
# p = re.compile("(=\?.*?\?.\?.*?\?=)")
|
||||
# text2 = ''
|
||||
# try:
|
||||
# for t2 in p.split(text):
|
||||
# text2 += ''.join(
|
||||
# [s.decode(
|
||||
# t or 'ascii'
|
||||
# ) for (s, t) in decode_header(t2)]
|
||||
# ).encode('utf-8')
|
||||
# except:
|
||||
# return text
|
||||
# return text2
|
||||
|
||||
email_smtp_server()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,208 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<menuitem name="Configuration" parent="base.menu_tools"
|
||||
id="base.menu_lunch_survey_root" sequence="20" />
|
||||
|
||||
<record model="ir.ui.view" id="view_email_message_form">
|
||||
<field name="name">email.message.form</field>
|
||||
<field name="model">email.message</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Email message">
|
||||
<group colspan="4" col="6">
|
||||
<field name="name" widget="char"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id" string="Owner"/>
|
||||
<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"/>
|
||||
<field name="email_cc"/>
|
||||
<field name="email_bcc" groups="base.group_extended"/>
|
||||
<field name="reply_to"/>
|
||||
</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"/>
|
||||
<field name="message_id"/>
|
||||
<button name="process_queue" string="Process Queue" type="object" icon="gtk-execute"/>
|
||||
</group>
|
||||
</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>
|
||||
<page string="Advanced">
|
||||
<group col="4" colspan="4">
|
||||
<field name="folder"/>
|
||||
<field name="state"/>
|
||||
<field name="sub_type"/>
|
||||
<field name="headers"/>
|
||||
<field name="priority"/>
|
||||
<field name="debug"/>
|
||||
<field name="history"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_email_message_tree">
|
||||
<field name="name">email.message.tree</field>
|
||||
<field name="model">email.message</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Emails">
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="email_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_email_message_search">
|
||||
<field name="name">email.message.search</field>
|
||||
<field name="model">email.message</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Email Search">
|
||||
<field name="name"/>
|
||||
<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">email.message</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="view_email_message_search"/>
|
||||
</record>
|
||||
|
||||
<act_window domain="[('partner_id', '=', active_id), ('history', '=', True)]"
|
||||
id="act_res_partner_emails" name="Emails"
|
||||
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="email.message"
|
||||
domain="[('res_id', '=', res_id),('res_model','=',model)]"/>
|
||||
|
||||
<menuitem name="Email Message" id="menu_email_message_tools"
|
||||
parent="base.menu_tools" />
|
||||
|
||||
<menuitem name="Message"
|
||||
id="menu_email_message"
|
||||
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="Email Smtp Server Configuration">
|
||||
<group colspan="2">
|
||||
<field name="name"/>
|
||||
<field name="default"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Outgoing">
|
||||
<separator string="Server Information" colspan="4"/>
|
||||
<group colspan="4" col="4">
|
||||
<field name="smtpserver"/>
|
||||
<button name="check_outgoing_connection" type="object" string="Test Outgoing Connection" icon="gtk-network" colspan="2"/>
|
||||
<field name="smtpport"/>
|
||||
<field name="smtpssl"/>
|
||||
<field name="smtptls"/>
|
||||
</group>
|
||||
<separator string="User Information" colspan="4"/>
|
||||
<group col="2" colspan="2">
|
||||
<field name="email_id" colspan="2"/>
|
||||
<field name="smtppass" password="True" colspan="2"/>
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<field name="smtpuname" colspan="2"/>
|
||||
</group>
|
||||
</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="Email Accounts">
|
||||
<field name="name"/>
|
||||
<field name="email_id"/>
|
||||
<field name="smtpuname"/>
|
||||
<field name="smtpserver"/>
|
||||
<field name="smtpport"/>
|
||||
</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="Email 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">Smtp Server</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="Email Smtp Server" id="menu_email_smtp_server_all" parent="menu_config_email" action="action_email_smtp_server_tree_all"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -19,17 +19,16 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields,osv
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
|
||||
class res_partner(osv.osv):
|
||||
""" Inherits partner and adds CRM information in the partner form """
|
||||
_inherit = 'res.partner'
|
||||
_columns = {
|
||||
'emails': fields.one2many('mailgate.message', 'partner_id',\
|
||||
'Emails', readonly=True, domain=[('history','=',True)]),
|
||||
'emails': fields.one2many('email.message', 'partner_id', 'Emails', readonly=True, domain=[('history','=',True)]),
|
||||
}
|
||||
|
||||
res_partner()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Partners inherited form -->
|
||||
<record id="base.view_crm_partner_info_History" model="ir.ui.view">
|
||||
<field name="name">res.partner.crm.history.inherit1</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page[@string='History']" position="attributes">
|
||||
<attribute name="invisible">False</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_emails_partner_info_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.emails.info.inherit</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<page string="History" position="inside">
|
||||
<field name="emails" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +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
|
|
|
@ -39,7 +39,7 @@
|
|||
Events / Reporting
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['crm', 'base_contact', 'account', 'marketing'],
|
||||
'depends': ['crm', 'base_contact', 'account', 'marketing', 'emails'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'security/event_security.xml',
|
||||
|
|
|
@ -24,7 +24,6 @@ import time
|
|||
from crm import crm
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import tools
|
||||
import decimal_precision as dp
|
||||
|
||||
class event_type(osv.osv):
|
||||
|
@ -313,8 +312,8 @@ class event_registration(osv.osv):
|
|||
'create_date': fields.datetime('Creation Date', readonly=True),
|
||||
'write_date': fields.datetime('Write Date', readonly=True),
|
||||
'description': fields.text('Description', states={'done': [('readonly', True)]}),
|
||||
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('model','=',_name)]),
|
||||
'message_ids': fields.one2many('email.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
'log_ids': fields.one2many('email.message', 'res_id', 'Logs', domain=[('history', '=', False),('model','=',_name)]),
|
||||
'date_deadline': fields.related('event_id','date_end', type='datetime', string="End Date", readonly=True),
|
||||
'date': fields.related('event_id', 'date_begin', type='datetime', string="Start Date", readonly=True),
|
||||
'user_id': fields.many2one('res.users', 'Responsible', states={'done': [('readonly', True)]}),
|
||||
|
@ -521,7 +520,7 @@ class event_registration(osv.osv):
|
|||
"""
|
||||
Send email to user
|
||||
"""
|
||||
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
for regestration in self.browse(cr, uid, ids, context=context):
|
||||
src = regestration.event_id.reply_to or False
|
||||
email_to = []
|
||||
|
@ -545,7 +544,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:
|
||||
tools.email_send(src, email_to, subject, body, email_cc=email_cc, openobject_id=regestration.id)
|
||||
email_message_obj.email_send(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, \
|
||||
subjec=subject, email_from=src, \
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#-*- coding:utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# mga@tinyerp.com
|
||||
#
|
||||
|
@ -24,9 +24,9 @@
|
|||
{
|
||||
"name" : "Fetchmail Server",
|
||||
"version" : "1.0",
|
||||
"depends" : ["base", 'mail_gateway'],
|
||||
"depends" : ["base", 'email_gateway'],
|
||||
"author" : "OpenERP SA",
|
||||
"description": """Fetchmail:
|
||||
"description": """Fetchmail:
|
||||
* Fetch email from Pop / IMAP server
|
||||
* Support SSL
|
||||
* Integrated with all Modules
|
||||
|
|
|
@ -61,7 +61,7 @@ class email_server(osv.osv):
|
|||
'object_id': fields.many2one('ir.model', "Model", required=True, help="OpenObject Model. Generates a record of this model.\nSelect Object with message_new attrbutes."),
|
||||
'priority': fields.integer('Server Priority', readonly=True, states={'draft':[('readonly', False)]}, help="Priority between 0 to 10, select define the order of Processing"),
|
||||
'user_id':fields.many2one('res.users', 'User', required=False),
|
||||
'message_ids': fields.one2many('mailgate.message', 'server_id', 'Messages', readonly=True),
|
||||
'message_ids': fields.one2many('email.message', 'server_id', 'Messages', readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'state': lambda *a: "draft",
|
||||
|
@ -110,7 +110,7 @@ class email_server(osv.osv):
|
|||
def set_draft(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids , {'state':'draft'})
|
||||
return True
|
||||
|
||||
|
||||
def button_confirm_login(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
@ -127,7 +127,7 @@ class email_server(osv.osv):
|
|||
|
||||
imap_server.login(server.user, server.password)
|
||||
ret_server = imap_server
|
||||
|
||||
|
||||
elif server.type == 'pop':
|
||||
pop_server = None
|
||||
if server.is_ssl:
|
||||
|
@ -140,7 +140,7 @@ class email_server(osv.osv):
|
|||
pop_server.user(server.user)
|
||||
pop_server.pass_(server.password)
|
||||
ret_server = pop_server
|
||||
|
||||
|
||||
self.write(cr, uid, [server.id], {'state':'done'})
|
||||
if context.get('get_server',False):
|
||||
return ret_server
|
||||
|
@ -207,9 +207,9 @@ class email_server(osv.osv):
|
|||
|
||||
email_server()
|
||||
|
||||
class mailgate_message(osv.osv):
|
||||
class email_message(osv.osv):
|
||||
|
||||
_inherit = "mailgate.message"
|
||||
_inherit = "email.message"
|
||||
|
||||
_columns = {
|
||||
'server_id': fields.many2one('email.server', "Mail Server", readonly=True, select=True),
|
||||
|
@ -229,7 +229,7 @@ class mailgate_message(osv.osv):
|
|||
values['server_id'] = server_id
|
||||
if server_type:
|
||||
values['server_type'] = server_type
|
||||
res = super(mailgate_message,self).create(cr, uid, values, context=context)
|
||||
res = super(email_message,self).create(cr, uid, values, context=context)
|
||||
return res
|
||||
|
||||
def write(self, cr, uid, ids, values, context=None):
|
||||
|
@ -241,9 +241,9 @@ class mailgate_message(osv.osv):
|
|||
values['server_id'] = server_id
|
||||
if server_type:
|
||||
values['server_type'] = server_type
|
||||
res = super(mailgate_message,self).write(cr, uid, ids, values, context=context)
|
||||
res = super(email_message,self).write(cr, uid, ids, values, context=context)
|
||||
return res
|
||||
|
||||
mailgate_message()
|
||||
email_message()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_email_server_tree">
|
||||
<field name="name">email.server.tree</field>
|
||||
<field name="model">email.server</field>
|
||||
|
@ -18,7 +18,7 @@
|
|||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_email_server_form">
|
||||
<field name="name">email.server.form</field>
|
||||
<field name="model">email.server</field>
|
||||
|
@ -68,7 +68,7 @@
|
|||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_email_server_search">
|
||||
<field name="name">email.server.search</field>
|
||||
<field name="model">email.server</field>
|
||||
|
@ -91,7 +91,7 @@
|
|||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="action_email_server_tree">
|
||||
<field name="name">Email Servers</field>
|
||||
<field name="res_model">email.server</field>
|
||||
|
@ -101,31 +101,30 @@
|
|||
<field name="search_view_id" ref="view_email_server_search"/>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
parent="base.menu_mail_gateway"
|
||||
<menuitem
|
||||
parent="emails.menu_email_message_tools"
|
||||
id="menu_action_fetchmail_server_tree"
|
||||
action="action_email_server_tree"
|
||||
action="action_email_server_tree"
|
||||
name="Email Servers"
|
||||
/>
|
||||
|
||||
<record model="ir.ui.view" id="mailgate_message_tree_view">
|
||||
<field name="name">mailgate.message.tree</field>
|
||||
<field name="model">mailgate.message</field>
|
||||
|
||||
<record model="ir.ui.view" id="email_message_tree_view">
|
||||
<field name="name">email.message.tree</field>
|
||||
<field name="model">email.message</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="inherit_id" ref="mail_gateway.view_mailgate_message_tree"/>
|
||||
<field name="inherit_id" ref="emails.view_email_message_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="user_id" position="after">
|
||||
<field name="server_id" select="1"/>
|
||||
<field name="ref_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="mailgate_message_search_view">
|
||||
<field name="name">mailgate.message.inherit.search</field>
|
||||
<field name="model">mailgate.message</field>
|
||||
|
||||
<record model="ir.ui.view" id="email_message_search_view">
|
||||
<field name="name">email.message.inherit.search</field>
|
||||
<field name="model">email.message</field>
|
||||
<field name="type">search</field>
|
||||
<field name="inherit_id" ref="mail_gateway.view_mailgate_message_search"/>
|
||||
<field name="inherit_id" ref="emails.view_email_message_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/search/field[@name='name']" position="before">
|
||||
<filter string="Emails" name="emails" domain="[('server_id','!=',False)]" icon="terp-mail-message-new"/>
|
||||
|
@ -136,24 +135,21 @@
|
|||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="action_view_mail_message_emails" model="ir.actions.act_window">
|
||||
<field name="name">Messages</field>
|
||||
<field name="res_model">mailgate.message</field>
|
||||
<field name="res_model">email.message</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{'search_default_emails': 1}</field>
|
||||
<field name="search_view_id" ref="mailgate_message_search_view"/>
|
||||
<field name="search_view_id" ref="email_message_search_view"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="base.menu_email_gateway_form"
|
||||
parent="base.menu_mail_gateway" action="action_view_mail_message_emails" />
|
||||
|
||||
<act_window
|
||||
<act_window
|
||||
context="{'server_id': active_id}"
|
||||
domain="[('server_id', '=', active_id)]"
|
||||
id="act_server_history" name="Emails"
|
||||
res_model="mailgate.message" src_model="email.server"/>
|
||||
|
||||
res_model="email.message" src_model="email.server"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
"author": "OpenERP SA",
|
||||
"category": "Generic Modules/Human Resources",
|
||||
"website": "http://www.openerp.com",
|
||||
"depends": ["hr",'hr_recruitment','survey'],
|
||||
"depends": ["hr","hr_recruitment","survey"],
|
||||
"description": """
|
||||
Ability to create employees evaluation.
|
||||
An evaluation can be created by employee for subordinates,
|
||||
|
|
|
@ -24,7 +24,6 @@ from datetime import datetime
|
|||
from dateutil.relativedelta import relativedelta
|
||||
from dateutil import parser
|
||||
from osv import fields, osv
|
||||
import tools
|
||||
from tools.translate import _
|
||||
|
||||
class hr_evaluation_plan(osv.osv):
|
||||
|
@ -193,6 +192,7 @@ class hr_evaluation(osv.osv):
|
|||
return {'value': {'plan_id':evaluation_plan_id}}
|
||||
|
||||
def button_plan_in_progress(self, cr, uid, ids, context=None):
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
hr_eval_inter_obj = self.pool.get('hr.evaluation.interview')
|
||||
if context is None:
|
||||
context = {}
|
||||
|
@ -229,7 +229,7 @@ class hr_evaluation(osv.osv):
|
|||
sub = phase.email_subject
|
||||
dest = [child.work_email]
|
||||
if dest:
|
||||
tools.email_send(evaluation.employee_id.work_email, dest, sub, body)
|
||||
email_message_obj.email_send(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
|
||||
|
|
|
@ -29,13 +29,14 @@ class hr_evaluation_reminder(osv.osv_memory):
|
|||
}
|
||||
|
||||
def send_mail(self, cr, uid, ids, context=None):
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
hr_evaluation_interview_obj = self.pool.get('hr.evaluation.interview')
|
||||
evaluation_data = self.read(cr, uid, ids, context=context)[0]
|
||||
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)
|
||||
tools.email_send(tools.config['email_from'], [current_interview.user_to_review_id.work_email],\
|
||||
'Reminder to fill up Survey', msg)
|
||||
email_message_obj.email_send(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'}
|
||||
|
||||
hr_evaluation_reminder()
|
||||
|
|
|
@ -117,7 +117,7 @@ class hr_applicant(crm.crm_case, osv.osv):
|
|||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=128, required=True),
|
||||
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
'message_ids': fields.one2many('email.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
'active': fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the case without removing it."),
|
||||
'description': fields.text('Description'),
|
||||
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
||||
|
|
|
@ -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_mailgate_message_user","mailgate.message.user","mail_gateway.model_mailgate_message","base.group_hr_user",1,1,1,1
|
||||
"access_email_message_user","email.message.user","emails.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
|
||||
|
|
|
|
@ -1,220 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<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>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Mailgateway Thread">
|
||||
<separator string="History" colspan="4"/>
|
||||
<field name="message_ids" nolabel="1" colspan="4" mode="tree,form">
|
||||
<tree string="Mailgateway History">
|
||||
<field name="display_text" />
|
||||
</tree>
|
||||
<form string="Mailgate History">
|
||||
<field name="name" widget="char" size="512"/>
|
||||
<field name="date" />
|
||||
<field name="user_id" />
|
||||
<field name="message_id" />
|
||||
<field name="history" />
|
||||
<notebook colspan="4">
|
||||
<page string="Email Details">
|
||||
<group col="4" colspan="4">
|
||||
<separator string="Email Details" 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"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Attachments">
|
||||
<separator string="Attachments" colspan="4"/>
|
||||
<field name="attachment_ids" nolabel="1" colspan="4" />
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</form>
|
||||
</field>
|
||||
</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="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Mailgateway Thread">
|
||||
<field name="message_ids" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 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="view_mode">tree,form</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_mailgate_thread_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>
|
||||
<field name="view_id" ref="view_mailgate_thread_tree"/>
|
||||
<field name="act_window_id" ref="action_view_mailgate_thread"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="action_view_mailgate_thread_view2">
|
||||
<field name="sequence" eval="2"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_mailgate_thread_form"/>
|
||||
<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>
|
||||
<field name="view_id" ref="view_mailgate_thread_tree"/>
|
||||
<field name="act_window_id" ref="action_view_mailgate_thread"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="action_view_mailgate_thread_view2">
|
||||
<field name="sequence" eval="2"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_mailgate_thread_form"/>
|
||||
<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>
|
|
@ -1,30 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Partners inherited form -->
|
||||
<record id="base.view_crm_partner_info_History" model="ir.ui.view">
|
||||
<field name="name">res.partner.crm.history.inherit1</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page[@string='History']" position="attributes">
|
||||
<attribute name="invisible">False</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_emails_partner_info_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.emails.info.inherit</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<page string="History" position="inside">
|
||||
<field name="emails" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
"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
|
|
|
@ -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_template.account.user","email_template.model_email_template_account","marketing.group_marketing_user",1,1,0,0
|
||||
"access_email_template_account_user","emails.account.user","emails.model_email_smtp_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_template.account.manager","email_template.model_email_template_account","marketing.group_marketing_manager",1,1,1,1
|
||||
"access_email_template_account_manager","emails.account.manager","emails.model_email_smtp_server","marketing.group_marketing_manager",1,1,1,1
|
||||
|
|
|
|
@ -25,15 +25,15 @@
|
|||
'version' : '1.0',
|
||||
'author' : 'OpenERP SA',
|
||||
'website' : 'http://www.openerp.com/',
|
||||
'depends' : ['base', 'mail_gateway'],
|
||||
'depends' : ['base', 'email_gateway'],
|
||||
'category' : 'Generic Modules/Outlook interface',
|
||||
'description': '''
|
||||
This module provide the Outlook plug-in.
|
||||
This module provide the Outlook plug-in.
|
||||
|
||||
Outlook plug-in allows you to select an object that you’d like to add
|
||||
to your email and its attachments from MS Outlook. You can select a partner, a task,
|
||||
a project, an analytical account, or any other object and Archived selected
|
||||
mail in mailgate.messages with attachments.
|
||||
mail in email.messages with attachments.
|
||||
|
||||
''',
|
||||
'init_xml' : [],
|
||||
|
|
|
@ -177,14 +177,14 @@ class XMLRpcConn(object):
|
|||
model = rec[0]
|
||||
res_id = rec[1]
|
||||
#Check if mailgate installed
|
||||
object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','mailgate.message')])
|
||||
object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','email.message')])
|
||||
if not object_id:
|
||||
win32ui.MessageBox("Mailgate is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mailgate not installed",win32con.MB_ICONERROR)
|
||||
return
|
||||
object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',model)])
|
||||
object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name']
|
||||
#Reading the Object ir.model Name
|
||||
ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mailgate.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)])
|
||||
ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)])
|
||||
if ext_ids:
|
||||
name = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,model,'read',res_id,['name'])['name']
|
||||
ext_msg += """This mail is already archived to {0} '{1}'.\n""".format(object_name,name)
|
||||
|
@ -457,19 +457,19 @@ class XMLRpcConn(object):
|
|||
import win32ui
|
||||
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object')
|
||||
res_vals = []
|
||||
mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message', 'search', [('message_id','=',message_id)])
|
||||
mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message', 'search', [('message_id','=',message_id)])
|
||||
ref_mail_id = None
|
||||
if not mail_id:
|
||||
ref_mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message', 'search', [('references','=',message_id)])
|
||||
ref_mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message', 'search', [('references','=',message_id)])
|
||||
if ref_mail_id:
|
||||
win32ui.MessageBox(str(ref_mail_id),"ref_mail_id")
|
||||
address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message','read',ref_mail_id[0],['model','res_id'])
|
||||
address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message','read',ref_mail_id[0],['model','res_id'])
|
||||
win32ui.MessageBox(str(address),"address")
|
||||
for key, vals in address.items():
|
||||
res_vals.append([key,vals])
|
||||
return res_vals
|
||||
return None
|
||||
address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message','read',mail_id[0],['model','res_id'])
|
||||
address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message','read',mail_id[0],['model','res_id'])
|
||||
for key, vals in address.items():
|
||||
res_vals.append([key,vals])
|
||||
return res_vals
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
"author": "OpenERP SA",
|
||||
"website": "http://www.openerp.com",
|
||||
"category": "Generic Modules/Projects & Services",
|
||||
"depends": ["product", "analytic", "board"],
|
||||
"depends": ["product", "analytic", "board", "emails"],
|
||||
"description": """Project management module tracks multi-level projects, tasks,
|
||||
work done on tasks, eso. It is able to render planning, order tasks, eso.
|
||||
Dashboard for project members that includes:
|
||||
|
|
|
@ -45,13 +45,13 @@ class project_task_close(osv.osv_memory):
|
|||
context = {}
|
||||
record_id = context and context.get('active_id', False) or False
|
||||
task_pool = self.pool.get('project.task')
|
||||
|
||||
|
||||
res = super(project_task_close, self).default_get(cr, uid, fields, context=context)
|
||||
task = task_pool.browse(cr, uid, record_id, context=context)
|
||||
project = task.project_id
|
||||
manager = project.user_id or False
|
||||
partner = task.partner_id or task.project_id.partner_id
|
||||
|
||||
|
||||
if 'description' in fields:
|
||||
res.update({'description': task.description or False})
|
||||
if 'manager_warn' in fields:
|
||||
|
@ -67,7 +67,8 @@ class project_task_close(osv.osv_memory):
|
|||
def send(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
task_pool = self.pool.get('project.task')
|
||||
task_id = context.get('active_id', False)
|
||||
if not task_id:
|
||||
|
@ -106,7 +107,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 = tools.email_send(from_adr, to_adr, subject, tools.ustr(body), email_bcc=[from_adr])
|
||||
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])
|
||||
if not mail_id:
|
||||
raise osv.except_osv(_('Error'), _("Couldn't send mail! Check the email ids and smtp configuration settings"))
|
||||
return {}
|
||||
|
|
|
@ -144,7 +144,7 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
issues = []
|
||||
issue_pool = self.pool.get('project.issue')
|
||||
for task in self.pool.get('project.task').browse(cr, uid, ids, context=context):
|
||||
issues += issue_pool.search(cr, uid, [('task_id','=',task.id)])
|
||||
issues += issue_pool.search(cr, uid, [('task_id','=',task.id)])
|
||||
return issues
|
||||
|
||||
def _get_issue_work(self, cr, uid, ids, context=None):
|
||||
|
@ -162,8 +162,8 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
progress = 0.0
|
||||
if issue.task_id:
|
||||
progress = task_pool._hours_get(cr, uid, [issue.task_id.id], field_names, args, context=context)[issue.task_id.id]['progress']
|
||||
res[issue.id] = {'progress' : progress}
|
||||
return res
|
||||
res[issue.id] = {'progress' : progress}
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'id': fields.integer('ID'),
|
||||
|
@ -213,7 +213,7 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
method=True, multi='working_days_open', type="float", store=True),
|
||||
'working_hours_close': fields.function(_compute_day, string='Working Hours to Close the Issue', \
|
||||
method=True, multi='working_days_close', type="float", store=True),
|
||||
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
'message_ids': fields.one2many('email.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
|
||||
'date_action_last': fields.datetime('Last Action', readonly=1),
|
||||
'date_action_next': fields.datetime('Next Action', readonly=1),
|
||||
'progress': fields.function(_hours_get, method=True, string='Progress (%)', multi='hours', group_operator="avg", help="Computed as: Time Spent / Total Time.",
|
||||
|
@ -370,7 +370,7 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks
|
||||
"""
|
||||
if context is None:
|
||||
if context is None:
|
||||
context = {}
|
||||
mailgate_pool = self.pool.get('email.server.tools')
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -16,7 +16,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -102,7 +102,7 @@ class project_issue_report(osv.osv):
|
|||
date_trunc('day',c.create_date) as create_date,
|
||||
extract('epoch' from (c.date_open-c.create_date))/(3600*24) as delay_open,
|
||||
extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as delay_close,
|
||||
(SELECT count(id) FROM mailgate_message WHERE model='project.issue' AND res_id=c.id) AS email
|
||||
(SELECT count(id) FROM email_message WHERE model='project.issue' AND res_id=c.id) AS email
|
||||
FROM
|
||||
project_issue c
|
||||
)""")
|
||||
|
|
|
@ -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_mailgate_message_project_manager","mailgate.message.manager","mail_gateway.model_mailgate_message","project.group_project_manager",1,1,1,1
|
||||
"access_email_message_project_manager","email.message.manager","emails.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_mailgate_message_issue_project_user","project.mailgate.message.issue.user","mail_gateway.model_mailgate_message","project.group_project_user",1,1,1,0
|
||||
"access_email_message_issue_project_user","project.mailgate.message.issue.user","emails.model_email_message","project.group_project_user",1,1,1,0
|
||||
|
|
|
|
@ -26,7 +26,7 @@
|
|||
"author": "OpenERP SA",
|
||||
"website": "http://www.openerp.com",
|
||||
"category": "Generic Modules/Projects & Services",
|
||||
"depends": ["project", "mail_gateway"],
|
||||
"depends": ["project", "email_gateway"],
|
||||
"description": """This module is an interface that synchronises mails with OpenERP Project Task.
|
||||
|
||||
It allows creating tasks as soon as a new mail arrives in our configured mail server.
|
||||
|
|
|
@ -26,9 +26,9 @@ import binascii
|
|||
class project_tasks(osv.osv):
|
||||
_name = "project.task"
|
||||
_inherit = ['mailgate.thread','project.task']
|
||||
|
||||
|
||||
_columns={
|
||||
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)], readonly=True),
|
||||
'message_ids': fields.one2many('email.message', 'res_id', 'Messages', domain=[('model','=',_name)], readonly=True),
|
||||
}
|
||||
def message_new(self, cr, uid, msg, context=None):
|
||||
# """
|
||||
|
@ -44,7 +44,7 @@ class project_tasks(osv.osv):
|
|||
msg_from = msg.get('from')
|
||||
priority = msg.get('priority')
|
||||
|
||||
data = {
|
||||
data = {
|
||||
'name': subject,
|
||||
'description': body,
|
||||
'planned_hours' : 0.0,
|
||||
|
@ -52,8 +52,8 @@ class project_tasks(osv.osv):
|
|||
res = mailgate_obj.get_partner(cr, uid, msg_from)
|
||||
if res:
|
||||
data.update(res)
|
||||
res = self.create(cr, uid, data)
|
||||
|
||||
res = self.create(cr, uid, data)
|
||||
|
||||
attachments = msg.get('attachments', [])
|
||||
for attachment in attachments or []:
|
||||
data_attach = {
|
||||
|
@ -66,19 +66,19 @@ class project_tasks(osv.osv):
|
|||
}
|
||||
self.pool.get('ir.attachment').create(cr, uid, data_attach)
|
||||
|
||||
return res
|
||||
|
||||
def message_update(self, cr, uid, id, msg, data={}, default_act='pending'):
|
||||
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)
|
||||
msg_actions, body_data = mailgate_obj.msg_act_get(msg)
|
||||
data.update({
|
||||
'description': body_data,
|
||||
'description': body_data,
|
||||
})
|
||||
act = 'do_'+default_act
|
||||
if 'state' in msg_actions:
|
||||
if msg_actions['state'] in ['draft','close','cancel','open','pending']:
|
||||
act = 'do_' + msg_actions['state']
|
||||
|
||||
|
||||
for k1,k2 in [('cost','planned_hours')]:
|
||||
try:
|
||||
data[k2] = float(msg_actions[k1])
|
||||
|
@ -88,7 +88,7 @@ class project_tasks(osv.osv):
|
|||
if 'priority' in msg_actions:
|
||||
if msg_actions['priority'] in ('1','2','3','4','5'):
|
||||
data['priority'] = msg_actions['priority']
|
||||
|
||||
|
||||
self.write(cr, uid, [id], data)
|
||||
getattr(self,act)(cr, uid, [id])
|
||||
return True
|
||||
|
@ -108,7 +108,7 @@ class project_tasks(osv.osv):
|
|||
|
||||
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,\
|
||||
|
@ -116,25 +116,25 @@ class project_tasks(osv.osv):
|
|||
details=details, email_from=email_from,\
|
||||
message_id=message_id, attach=attach, \
|
||||
context=context)
|
||||
|
||||
|
||||
def do_draft(self, cr, uid, ids, *args, **kwargs):
|
||||
res = super(project_tasks, self).do_draft(cr, uid, ids, *args, **kwargs)
|
||||
tasks = self.browse(cr, uid, ids)
|
||||
self._history(cr, uid, tasks, _('Draft'))
|
||||
return res
|
||||
|
||||
|
||||
def do_open(self, cr, uid, ids, *args, **kwargs):
|
||||
res = super(project_tasks, self).do_open(cr, uid, ids, *args, **kwargs)
|
||||
tasks = self.browse(cr, uid, ids)
|
||||
self._history(cr, uid, tasks, _('Open'))
|
||||
return res
|
||||
|
||||
|
||||
def do_pending(self, cr, uid, ids, *args, **kwargs):
|
||||
res = super(project_tasks, self).do_pending(cr, uid, ids, *args, **kwargs)
|
||||
tasks = self.browse(cr, uid, ids)
|
||||
self._history(cr, uid, tasks, _('Pending'))
|
||||
return res
|
||||
|
||||
|
||||
def do_close(self, cr, uid, ids, *args, **kwargs):
|
||||
res = super(project_tasks, self).do_close(cr, uid, ids, *args, **kwargs)
|
||||
tasks = self.browse(cr, uid, ids)
|
||||
|
@ -142,7 +142,7 @@ class project_tasks(osv.osv):
|
|||
if task.state == 'done':
|
||||
self._history(cr, uid, tasks, _('Done'))
|
||||
return res
|
||||
|
||||
|
||||
def do_cancel(self, cr, uid, ids, *args, **kwargs):
|
||||
res = super(project_tasks, self).do_cancel(cr, uid, ids, *args, **kwargs)
|
||||
tasks = self.browse(cr, uid, ids)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_mailgate_message_project_manager","project.mailgate.message.manager","mail_gateway.model_mailgate_message","project.group_project_manager",1,1,1,0
|
||||
"access_mailgate_message_project_user","project.mailgate.message.user","mail_gateway.model_mailgate_message","project.group_project_user",1,1,1,0
|
||||
"access_email_message_project_manager","project.mailgate.message.manager","emails.model_email_message","project.group_project_manager",1,1,1,0
|
||||
"access_email_message_project_user","project.mailgate.message.user","emails.model_email_message","project.group_project_user",1,1,1,0
|
||||
|
|
|
|
@ -47,7 +47,7 @@
|
|||
* http://controlchaos.com
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['project', 'process'],
|
||||
'depends': ['project', 'process', 'emails'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'security/ir.model.access.csv',
|
||||
|
|
|
@ -317,6 +317,7 @@ class project_scrum_meeting(osv.osv):
|
|||
return True
|
||||
|
||||
def email_send(self, cr, uid, ids, email, context=None):
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
email_from = tools.config.get('email_from', False)
|
||||
meeting_id = self.browse(cr, uid, ids, context=context)[0]
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
|
@ -325,7 +326,7 @@ class project_scrum_meeting(osv.osv):
|
|||
body += "\n"+ _('*Tasks since yesterday:')+ '\n_______________________%s' % (meeting_id.question_yesterday) + '\n' +_("*Task for Today:")+ '\n_______________________ %s\n' % (meeting_id.question_today )+ '\n' +_('*Blocks encountered:') +'\n_______________________ %s' % (meeting_id.question_blocks or _('No Blocks'))
|
||||
body += "\n\n"+_('Thank you')+",\n"+ user.name
|
||||
sub_name = meeting_id.name or _('Scrum Meeting of %s') % meeting_id.date
|
||||
flag = tools.email_send(user_email , [email], sub_name, body, reply_to=None, openobject_id=str(meeting_id.id))
|
||||
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))
|
||||
if not flag:
|
||||
return False
|
||||
return True
|
||||
|
|
|
@ -69,6 +69,7 @@ class project_scrum_email(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
|
||||
email_message_obj = self.pool.get('email.message')
|
||||
active_id = context.get('active_id', False)
|
||||
scrum_meeting_pool = self.pool.get('project.scrum.meeting')
|
||||
user_pool = self.pool.get('res.users')
|
||||
|
@ -91,7 +92,7 @@ class project_scrum_email(osv.osv_memory):
|
|||
body += "\n%s\n" %_("Task for Today")
|
||||
body += "_______________________ \n"
|
||||
body += "\n%s\n" %(meeting.question_today or _('None'))
|
||||
body += "\n%s\n" % _('Blocking points encountered:')
|
||||
body += "\n%s\n" % _('Blocking points encountered:')
|
||||
body += "_______________________ \n"
|
||||
body += "\n%s\n" %(meeting.question_blocks or _('None'))
|
||||
body += "\n%s\n%s" %(_('Thank you,'), user.name)
|
||||
|
@ -100,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:
|
||||
tools.email_send(user_email, [data.scrum_master_email], data.subject, body, reply_to=user_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)
|
||||
if data.product_owner_email:
|
||||
tools.email_send(user_email, [data.product_owner_email], data.subject, body, reply_to=user_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)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
project_scrum_email()
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue