diff --git a/addons/crm/__terp__.py b/addons/crm/__terp__.py
index 9567d449d9f..5931a056c7b 100644
--- a/addons/crm/__terp__.py
+++ b/addons/crm/__terp__.py
@@ -72,7 +72,7 @@ between mails and Open ERP.""",
'wizard/crm_opportunity_to_meeting_view.xml',
'wizard/crm_opportunity_to_phonecall_view.xml',
- 'wizard/crm_send_new_email_view.xml',
+ 'wizard/crm_send_email_view.xml',
'crm_wizard.xml',
'crm_view.xml',
diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index 01a0039cec5..ea3d330c1e5 100644
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -22,83 +22,95 @@
from datetime import datetime
from datetime import timedelta
from osv import fields
-from osv import orm
from osv import osv
-from osv.orm import except_orm
from tools.translate import _
-import base64
-import mx.DateTime
-import os
-import re
import time
import tools
MAX_LEVEL = 15
AVAILABLE_STATES = [
- ('draft','Draft'),
- ('open','Open'),
- ('cancel', 'Cancelled'),
- ('done', 'Closed'),
- ('pending','Pending')
+ ('draft', 'Draft'),
+ ('open', 'Open'),
+ ('cancel', 'Cancelled'),
+ ('done', 'Closed'),
+ ('pending', 'Pending')
]
AVAILABLE_PRIORITIES = [
- ('5','Lowest'),
- ('4','Low'),
- ('3','Normal'),
- ('2','High'),
- ('1','Highest')
+ ('5', 'Lowest'),
+ ('4', 'Low'),
+ ('3', 'Normal'),
+ ('2', 'High'),
+ ('1', 'Highest')
]
icon_lst = {
- 'form':'STOCK_NEW',
- 'tree':'STOCK_JUSTIFY_FILL',
- 'calendar':'STOCK_SELECT_COLOR'
+ 'form': 'STOCK_NEW',
+ 'tree': 'STOCK_JUSTIFY_FILL',
+ 'calendar': 'STOCK_SELECT_COLOR'
}
class crm_case_section(osv.osv):
+ """ Cases Section"""
+
_name = "crm.case.section"
_description = "Sales Teams"
_order = "name"
+
_columns = {
- 'name': fields.char('Sales Team',size=64, required=True, translate=True),
- 'code': fields.char('Code',size=8),
- 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the sales team without removing it."),
- 'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"),
- 'user_id': fields.many2one('res.users', 'Responsible User'),
- 'reply_to': fields.char('Reply-To', size=64, help="The email address put in the 'Reply-To' of all emails sent by Open ERP about cases in this sales team"),
- 'parent_id': fields.many2one('crm.case.section', 'Parent Section'),
- 'child_ids': fields.one2many('crm.case.section', 'parent_id', 'Child Sections'),
+ 'name': fields.char('Sales Team', size=64, required=True, translate=True),
+ 'code': fields.char('Code', size=8),
+ 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the sales team without removing it."),
+ 'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"),
+ 'user_id': fields.many2one('res.users', 'Responsible User'),
+ 'reply_to': fields.char('Reply-To', size=64, help="The email address put in the 'Reply-To' of all emails sent by Open ERP about cases in this sales team"),
+ 'parent_id': fields.many2one('crm.case.section', 'Parent Section'),
+ 'child_ids': fields.one2many('crm.case.section', 'parent_id', 'Child Sections'),
}
+
_defaults = {
- 'active': lambda *a: 1,
- 'allow_unlink': lambda *a: 1,
+ 'active': lambda *a: 1,
+ 'allow_unlink': lambda *a: 1,
}
+
_sql_constraints = [
('code_uniq', 'unique (code)', 'The code of the section must be unique !')
]
+
def _check_recursion(self, cr, uid, ids):
+ """
+ Checks for recursion level for sections
+ @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 section ids
+ """
level = 100
+
while len(ids):
- cr.execute('select distinct parent_id from crm_case_section where id =ANY(%s)',(ids,))
- ids = filter(None, map(lambda x:x[0], cr.fetchall()))
+ cr.execute('select distinct parent_id from crm_case_section where id =ANY(%s)', (ids,))
+ ids = filter(None, map(lambda x: x[0], cr.fetchall()))
if not level:
return False
level -= 1
+
return True
+
_constraints = [
(_check_recursion, 'Error ! You cannot create recursive sections.', ['parent_id'])
]
+
def name_get(self, cr, uid, ids, context={}):
+ """Overrides orm """
if not len(ids):
return []
- reads = self.read(cr, uid, ids, ['name','parent_id'], context)
+ reads = self.read(cr, uid, ids, ['name', 'parent_id'], context)
res = []
for record in reads:
name = record['name']
if record['parent_id']:
- name = record['parent_id'][1]+' / '+name
+ name = record['parent_id'][1] + ' / ' + name
res.append((record['id'], name))
return res
crm_case_section()
@@ -108,13 +120,13 @@ class crm_case_categ(osv.osv):
_description = "Category of case"
_columns = {
- 'name': fields.char('Case Category Name', size=64, required=True, translate=True),
- 'section_id': fields.many2one('crm.case.section', 'Sales Team'),
- 'object_id': fields.many2one('ir.model','Object Name'),
+ 'name': fields.char('Case Category Name', size=64, required=True, translate=True),
+ 'section_id': fields.many2one('crm.case.section', 'Sales Team'),
+ 'object_id': fields.many2one('ir.model', 'Object Name'),
}
def _find_object_id(self, cr, uid, context=None):
object_id = context and context.get('object_id', False) or False
- ids =self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)])
+ ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)])
return ids and ids[0]
_defaults = {
'object_id' : _find_object_id
@@ -127,13 +139,13 @@ class crm_case_resource_type(osv.osv):
_description = "Resource Type of case"
_rec_name = "name"
_columns = {
- 'name': fields.char('Case Resource Type', size=64, required=True, translate=True),
- 'section_id': fields.many2one('crm.case.section', 'Sales Team'),
- 'object_id': fields.many2one('ir.model','Object Name'),
+ 'name': fields.char('Case Resource Type', size=64, required=True, translate=True),
+ 'section_id': fields.many2one('crm.case.section', 'Sales Team'),
+ 'object_id': fields.many2one('ir.model', 'Object Name'),
}
def _find_object_id(self, cr, uid, context=None):
object_id = context and context.get('object_id', False) or False
- ids =self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)])
+ ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)])
return ids and ids[0]
_defaults = {
'object_id' : _find_object_id
@@ -147,21 +159,21 @@ class crm_case_stage(osv.osv):
_rec_name = 'name'
_order = "sequence"
_columns = {
- 'name': fields.char('Stage Name', size=64, required=True, translate=True),
- 'section_id': fields.many2one('crm.case.section', 'Sales Team'),
- 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of case stages."),
- 'object_id': fields.many2one('ir.model','Object Name'),
- 'probability': fields.float('Probability (%)', required=True),
- 'on_change': fields.boolean('Change Probability Automatically',help="Change Probability on next and previous stages."),
+ 'name': fields.char('Stage Name', size=64, required=True, translate=True),
+ 'section_id': fields.many2one('crm.case.section', 'Sales Team'),
+ 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of case stages."),
+ 'object_id': fields.many2one('ir.model', 'Object Name'),
+ 'probability': fields.float('Probability (%)', required=True),
+ 'on_change': fields.boolean('Change Probability Automatically', help="Change Probability on next and previous stages."),
'requirements': fields.text('Requirements')
}
def _find_object_id(self, cr, uid, context=None):
object_id = context and context.get('object_id', False) or False
- ids =self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)])
+ ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)])
return ids and ids[0]
_defaults = {
- 'sequence': lambda *args: 1,
- 'probability': lambda *args: 0.0,
+ 'sequence': lambda *args: 1,
+ 'probability': lambda *args: 0.0,
'object_id' : _find_object_id
}
@@ -188,8 +200,9 @@ class crm_case(osv.osv):
return res
def copy(self, cr, uid, id, default=None, context={}):
- if not default: default = {}
- default.update( {'state':'draft', 'id':False})
+ if not default:
+ default = {}
+ default.update({'state': 'draft', 'id': False})
return super(crm_case, self).copy(cr, uid, id, default, context)
def _get_log_ids(self, cr, uid, ids, field_names, arg, context={}):
@@ -205,55 +218,55 @@ class crm_case(osv.osv):
if not history_obj:
return result
for case in self.browse(cr, uid, ids, context):
- model_ids = model_obj.search(cr, uid, [('model','=',case._name)])
- history_ids = history_obj.search(cr, uid, [('model_id','=',model_ids[0]),('res_id','=',case.id)])
+ model_ids = model_obj.search(cr, uid, [('model', '=', case._name)])
+ history_ids = history_obj.search(cr, uid, [('model_id', '=', model_ids[0]), ('res_id', '=', case.id)])
if history_ids:
- result[case.id] = {name:history_ids}
+ result[case.id] = {name: history_ids}
else:
- result[case.id] = {name:[]}
+ result[case.id] = {name: []}
return result
_columns = {
- 'id': fields.integer('ID', readonly=True),
- 'name': fields.char('Description', size=1024, required=True),
- 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the case without removing it."),
- 'description': fields.text('Description'),
- '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.'),
- 'email_from': fields.char('Email', size=128, help="These people will receive email."),
+ 'id': fields.integer('ID', readonly=True),
+ 'name': fields.char('Description', size=1024, required=True),
+ 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the case without removing it."),
+ 'description': fields.text('Description'),
+ '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.'),
+ 'email_from': fields.char('Email', size=128, help="These people will receive email."),
'email_cc': fields.text('Watchers Emails', size=252 , help="These people will receive a copy of the future" \
- " communication between partner and users by email"),
- 'probability': fields.float('Probability'),
- 'email_last': fields.function(_email_last, method=True,
- string='Latest E-Mail', type='text'),
- 'partner_id': fields.many2one('res.partner', 'Partner'),
- 'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', domain="[('partner_id','=',partner_id)]"),
- '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'),
- 'history_line': fields.function(_get_log_ids, method=True, type='one2many', multi="history_line", relation="crm.case.history", string="Communication"),
- 'log_ids': fields.function(_get_log_ids, method=True, type='one2many', multi="log_ids", relation="crm.case.log", string="Logs History"),
- 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
- 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True,
+ " communication between partner and users by email"),
+ 'probability': fields.float('Probability'),
+ 'email_last': fields.function(_email_last, method=True,
+ string='Latest E-Mail', type='text'),
+ 'partner_id': fields.many2one('res.partner', 'Partner'),
+ 'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', domain="[('partner_id','=',partner_id)]"),
+ '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'),
+ 'history_line': fields.function(_get_log_ids, method=True, type='one2many', multi="history_line", relation="crm.case.history", string="Communication"),
+ 'log_ids': fields.function(_get_log_ids, method=True, type='one2many', multi="log_ids", relation="crm.case.log", string="Logs History"),
+ 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
+ 'state': fields.selection(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\'.'),
- 'company_id': fields.many2one('res.company','Company'),
+ \nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
+ 'company_id': fields.many2one('res.company', 'Company'),
}
def _get_default_partner_address(self, cr, uid, context):
- if not context.get('portal',False):
+ if not context.get('portal', False):
return False
return self.pool.get('res.users').browse(cr, uid, uid, context).address_id.id
def _get_default_partner(self, cr, uid, context):
- if not context.get('portal',False):
+ if not context.get('portal', False):
return False
user = self.pool.get('res.users').browse(cr, uid, uid, context)
if not user.address_id:
return False
return user.address_id.partner_id.id
def _get_default_email(self, cr, uid, context):
- if not context.get('portal',False):
+ if not context.get('portal', False):
return False
user = self.pool.get('res.users').browse(cr, uid, uid, context)
if not user.address_id:
@@ -265,26 +278,26 @@ class crm_case(osv.osv):
return uid
def _get_section(self, cr, uid, context):
- user = self.pool.get('res.users').browse(cr, uid, uid,context=context)
+ user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return user.context_section_id.id or False
_defaults = {
- 'active': lambda *a: 1,
- 'user_id': _get_default_user,
- 'partner_id': _get_default_partner,
- 'partner_address_id': _get_default_partner_address,
- 'email_from': _get_default_email,
- 'state': lambda *a: 'draft',
- 'date_deadline': lambda *a:(datetime.today() + timedelta(days=3)).strftime('%Y-%m-%d %H:%M:%S'),
- 'section_id': _get_section,
- 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c),
+ 'active': lambda *a: 1,
+ 'user_id': _get_default_user,
+ 'partner_id': _get_default_partner,
+ 'partner_address_id': _get_default_partner_address,
+ 'email_from': _get_default_email,
+ 'state': lambda *a: 'draft',
+ 'date_deadline': lambda *a: (datetime.today() + timedelta(days=3)).strftime('%Y-%m-%d %H:%M:%S'),
+ 'section_id': _get_section,
+ 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c),
}
_order = 'date_deadline desc, create_date desc,id desc'
def unlink(self, cr, uid, ids, context={}):
for case in self.browse(cr, uid, ids, context):
if (not case.section_id.allow_unlink) and (case.state <> 'draft'):
- raise osv.except_osv(_('Warning !'),
+ raise osv.except_osv(_('Warning !'),
_('You can not delete this case. You should better cancel it.'))
return super(crm_case, self).unlink(cr, uid, ids, context)
@@ -337,20 +350,20 @@ class crm_case(osv.osv):
def history(self, cr, uid, ids, keyword, history=False, email=False, details=None, context={}):
cases = self.browse(cr, uid, ids, context=context)
- return self.__history(cr, uid, cases, keyword=keyword,\
- history=history, email=email, details=details,\
+ return self.__history(cr, uid, cases, keyword=keyword, \
+ history=history, email=email, details=details, \
context=context)
def __history(self, cr, uid, cases, keyword, history=False, email=False, details=None, context={}):
model_obj = self.pool.get('ir.model')
for case in cases:
- model_ids = model_obj.search(cr, uid, [('model','=',case._name)])
+ model_ids = model_obj.search(cr, uid, [('model', '=', case._name)])
data = {
- 'name': keyword,
- 'user_id': uid,
- 'date': time.strftime('%Y-%m-%d %H:%M:%S'),
- 'model_id' : model_ids and model_ids[0] or False,
- 'res_id': case.id,
+ 'name': keyword,
+ 'user_id': uid,
+ 'date': time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'model_id' : model_ids and model_ids[0] or False,
+ 'res_id': case.id,
'section_id': case.section_id.id
}
obj = self.pool.get('crm.case.log')
@@ -368,7 +381,7 @@ class crm_case(osv.osv):
res = super(crm_case, self).create(cr, uid, *args, **argv)
cases = self.browse(cr, uid, [res])
cases[0].state # to fill the browse record cache
- self._action(cr,uid, cases, 'draft')
+ self._action(cr, uid, cases, 'draft')
return res
def add_reply(self, cursor, user, ids, context=None):
@@ -376,34 +389,34 @@ class crm_case(osv.osv):
if case.email_last:
description = email_last
self.write(cursor, user, case.id, {
- 'description': '> ' + description.replace('\n','\n> '),
+ 'description': '> ' + description.replace('\n', '\n> '),
}, context=context)
return True
- def case_log(self, cr, uid, ids,context={}, email=False, *args):
+ def case_log(self, cr, uid, ids, context={}, email=False, *args):
cases = self.browse(cr, uid, ids)
self.__history(cr, uid, cases, _('Historize'), history=True, email=email)
- return self.write(cr, uid, ids, {'description': False, 'som': False,
+ return self.write(cr, uid, ids, {'description': False, 'som': False,
'canal_id': False})
def case_log_reply(self, cr, uid, ids, context={}, email=False, *args):
cases = self.browse(cr, uid, ids)
for case in cases:
if not case.email_from:
- raise osv.except_osv(_('Error!'),
+ raise osv.except_osv(_('Error!'),
_('You must put a Partner eMail to use this action!'))
if not case.user_id:
- raise osv.except_osv(_('Error!'),
+ raise osv.except_osv(_('Error!'),
_('You must define a responsible user for this case in order to use this action!'))
if not case.description:
- raise osv.except_osv(_('Error!'),
+ raise osv.except_osv(_('Error!'),
_('Can not send mail with empty body,you should have description in the body'))
self.__history(cr, uid, cases, _('Send'), history=True, email=False)
for case in cases:
self.write(cr, uid, [case.id], {
- 'description': False,
- 'som': False,
- 'canal_id': False,
+ 'description': False,
+ 'som': False,
+ 'canal_id': False,
})
emails = [case.email_from] + (case.email_cc or '').split(',')
emails = filter(None, emails)
@@ -413,34 +426,34 @@ class crm_case(osv.osv):
emailfrom = case.user_id.address_id and case.user_id.address_id.email or False
if not emailfrom:
- raise osv.except_osv(_('Error!'),
+ raise osv.except_osv(_('Error!'),
_("No E-Mail ID Found for your Company address!"))
tools.email_send(
- emailfrom,
- emails,
- '['+str(case.id)+'] '+case.name,
- self.format_body(body),
- reply_to=case.section_id.reply_to,
- openobject_id=str(case.id)
+ emailfrom,
+ emails,
+ '[' + str(case.id) + '] ' + case.name,
+ self.format_body(body),
+ reply_to = case.section_id.reply_to,
+ openobject_id = str(case.id)
)
return True
def onchange_partner_id(self, cr, uid, ids, part, email=False):
if not part:
- return {'value':{'partner_address_id': False,
- 'email_from': False,
+ return {'value': {'partner_address_id': False,
+ 'email_from': False,
}}
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['contact'])
data = {'partner_address_id': addr['contact']}
data.update(self.onchange_partner_address_id(cr, uid, ids, addr['contact'])['value'])
- return {'value':data}
+ return {'value': data}
def onchange_partner_address_id(self, cr, uid, ids, add, email=False):
data = {}
if not add:
return {'value': {'email_from': False, 'partner_name2': False}}
- address= self.pool.get('res.partner.address').browse(cr, uid, add)
+ address = self.pool.get('res.partner.address').browse(cr, uid, add)
data['email_from'] = address.email
return {'value': data}
@@ -448,17 +461,17 @@ class crm_case(osv.osv):
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache
self.__history(cr, uid, cases, _('Close'))
- self.write(cr, uid, ids, {'state':'done', 'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')})
+ self.write(cr, uid, ids, {'state': 'done', 'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')})
#
# We use the cache of cases to keep the old case state
#
- self._action(cr,uid, cases, 'done')
+ self._action(cr, uid, cases, 'done')
return True
def case_escalate(self, cr, uid, ids, *args):
cases = self.browse(cr, uid, ids)
for case in cases:
- data = {'active':True, 'user_id': False}
+ data = {'active': True, 'user_id': False}
if case.section_id.parent_id:
data['section_id'] = case.section_id.parent_id.id
if case.section_id.parent_id.user_id:
@@ -468,7 +481,7 @@ class crm_case(osv.osv):
self.write(cr, uid, ids, data)
cases = self.browse(cr, uid, ids)
self.__history(cr, uid, cases, _('Escalate'))
- self._action(cr,uid, cases, 'escalate')
+ self._action(cr, uid, cases, 'escalate')
return True
@@ -476,11 +489,11 @@ class crm_case(osv.osv):
cases = self.browse(cr, uid, ids)
self.__history(cr, uid, cases, _('Open'))
for case in cases:
- data = {'state':'open', 'active':True}
+ data = {'state': 'open', 'active': True}
if not case.user_id:
data['user_id'] = uid
self.write(cr, uid, ids, data)
- self._action(cr,uid, cases, 'open')
+ self._action(cr, uid, cases, 'open')
return True
@@ -488,24 +501,24 @@ class crm_case(osv.osv):
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache
self.__history(cr, uid, cases, _('Cancel'))
- self.write(cr, uid, ids, {'state':'cancel', 'active':True})
- self._action(cr,uid, cases, 'cancel')
+ self.write(cr, uid, ids, {'state': 'cancel', 'active': True})
+ self._action(cr, uid, cases, 'cancel')
return True
def case_pending(self, cr, uid, ids, *args):
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache
self.__history(cr, uid, cases, _('Pending'))
- self.write(cr, uid, ids, {'state':'pending', 'active':True})
- self._action(cr,uid, cases, 'pending')
+ self.write(cr, uid, ids, {'state': 'pending', 'active': True})
+ self._action(cr, uid, cases, 'pending')
return True
def case_reset(self, cr, uid, ids, *args):
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache
self.__history(cr, uid, cases, _('Draft'))
- self.write(cr, uid, ids, {'state':'draft', 'active':True})
- self._action(cr,uid, cases, 'draft')
+ self.write(cr, uid, ids, {'state': 'draft', 'active': True})
+ self._action(cr, uid, cases, 'draft')
return True
crm_case()
@@ -516,17 +529,17 @@ class crm_case_log(osv.osv):
_description = "Case Communication History"
_order = "id desc"
_columns = {
- 'name': fields.char('Status', size=64),
- 'som': fields.many2one('res.partner.som', 'State of Mind'),
- 'date': fields.datetime('Date'),
- 'canal_id': fields.many2one('res.partner.canal', 'Channel'),
- 'section_id': fields.many2one('crm.case.section', 'Section'),
- 'user_id': fields.many2one('res.users', 'User Responsible', readonly=True),
- 'model_id': fields.many2one('ir.model', "Model"),
- 'res_id': fields.integer('Resource ID'),
+ 'name': fields.char('Status', size=64),
+ 'som': fields.many2one('res.partner.som', 'State of Mind'),
+ 'date': fields.datetime('Date'),
+ 'canal_id': fields.many2one('res.partner.canal', 'Channel'),
+ 'section_id': fields.many2one('crm.case.section', 'Section'),
+ 'user_id': fields.many2one('res.users', 'User Responsible', readonly=True),
+ 'model_id': fields.many2one('ir.model', "Model"),
+ 'res_id': fields.integer('Resource ID'),
}
_defaults = {
- 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
}
crm_case_log()
@@ -534,7 +547,7 @@ class crm_case_history(osv.osv):
_name = "crm.case.history"
_description = "Case history"
_order = "id desc"
- _inherits = {'crm.case.log':"log_id"}
+ _inherits = {'crm.case.log': "log_id"}
def _note_get(self, cursor, user, ids, name, arg, context=None):
res = {}
@@ -543,10 +556,10 @@ class crm_case_history(osv.osv):
res[hist.id] += (hist.description or '')
return res
_columns = {
- 'description': fields.text('Description'),
- 'note': fields.function(_note_get, method=True, string="Description", type="text"),
- 'email': fields.char('Email', size=84),
- 'log_id': fields.many2one('crm.case.log','Log',ondelete='cascade'),
+ 'description': fields.text('Description'),
+ 'note': fields.function(_note_get, method=True, string="Description", type="text"),
+ 'email': fields.char('Email', size=84),
+ 'log_id': fields.many2one('crm.case.log', 'Log', ondelete='cascade'),
}
crm_case_history()
@@ -554,26 +567,26 @@ class crm_email_add_cc_wizard(osv.osv_memory):
_name = "crm.email.add.cc"
_description = "Email Add CC"
_columns = {
- 'name': fields.selection([('user','User'),('partner','Partner'),('email','Email Address')], 'Send to', required=True),
- 'user_id': fields.many2one('res.users',"User"),
- 'partner_id': fields.many2one('res.partner',"Partner"),
- 'email': fields.char('Email', size=32),
- 'subject': fields.char('Subject', size=32),
+ 'name': fields.selection([('user', 'User'), ('partner', 'Partner'), ('email', 'Email Address')], 'Send to', required=True),
+ 'user_id': fields.many2one('res.users', "User"),
+ 'partner_id': fields.many2one('res.partner', "Partner"),
+ 'email': fields.char('Email', size=32),
+ 'subject': fields.char('Subject', size=32),
}
def change_email(self, cr, uid, ids, user, partner):
if (not partner and not user):
- return {'value':{'email': False}}
+ return {'value': {'email': False}}
email = False
if partner:
addr = self.pool.get('res.partner').address_get(cr, uid, [partner], ['contact'])
if addr:
- email = self.pool.get('res.partner.address').read(cr, uid,addr['contact'] , ['email'])['email']
+ email = self.pool.get('res.partner.address').read(cr, uid, addr['contact'] , ['email'])['email']
elif user:
addr = self.pool.get('res.users').read(cr, uid, user, ['address_id'])['address_id']
if addr:
- email = self.pool.get('res.partner.address').read(cr, uid,addr[0] , ['email'])['email']
- return {'value':{'email': email}}
+ email = self.pool.get('res.partner.address').read(cr, uid, addr[0] , ['email'])['email']
+ return {'value': {'email': email}}
def add_cc(self, cr, uid, ids, context={}):
@@ -587,20 +600,20 @@ class crm_email_add_cc_wizard(osv.osv_memory):
model = history_line.log_id.model_id.model
model_pool = self.pool.get(model)
case = model_pool.browse(cr, uid, history_line.log_id.res_id)
- body = history_line.description.replace('\n','\n> ')
+ body = history_line.description.replace('\n', '\n> ')
flag = tools.email_send(
- case.user_id.address_id.email,
- [case.email_from],
- subject or '['+str(case.id)+'] '+case.name,
- model_pool.format_body(body),
- email_cc = [email],
- openobject_id=str(case.id),
- subtype="html"
+ case.user_id.address_id.email,
+ [case.email_from],
+ subject or '[' + str(case.id) + '] ' + case.name,
+ model_pool.format_body(body),
+ email_cc = [email],
+ openobject_id = str(case.id),
+ subtype = "html"
)
if flag:
- model_pool.write(cr, uid, case.id, {'email_cc' : case.email_cc and case.email_cc +','+ email or email})
+ model_pool.write(cr, uid, case.id, {'email_cc' : case.email_cc and case.email_cc + ',' + email or email})
else:
- raise osv.except_osv(_('Email Fail!'),("Lastest Email is not sent successfully"))
+ raise osv.except_osv(_('Email Fail!'), ("Lastest Email is not sent successfully"))
return {}
crm_email_add_cc_wizard()
@@ -609,7 +622,7 @@ class users(osv.osv):
_inherit = 'res.users'
_description = "Users"
_columns = {
- 'context_section_id': fields.many2one('crm.case.section', 'Sales Team'),
+ 'context_section_id': fields.many2one('crm.case.section', 'Sales Team'),
}
users()
@@ -617,7 +630,7 @@ users()
class res_partner(osv.osv):
_inherit = 'res.partner'
_columns = {
- 'section_id': fields.many2one('crm.case.section', 'Sales Team'),
+ 'section_id': fields.many2one('crm.case.section', 'Sales Team'),
}
res_partner()
diff --git a/addons/crm/crm_claims_view.xml b/addons/crm/crm_claims_view.xml
index dc9708d89ba..1af94e62e11 100755
--- a/addons/crm/crm_claims_view.xml
+++ b/addons/crm/crm_claims_view.xml
@@ -188,7 +188,7 @@
diff --git a/addons/crm/crm_fund_view.xml b/addons/crm/crm_fund_view.xml
index 0b8db88220b..6d2a76df625 100644
--- a/addons/crm/crm_fund_view.xml
+++ b/addons/crm/crm_fund_view.xml
@@ -169,7 +169,7 @@
diff --git a/addons/crm/crm_helpdesk_view.xml b/addons/crm/crm_helpdesk_view.xml
index 2702f179395..c3f95deb253 100644
--- a/addons/crm/crm_helpdesk_view.xml
+++ b/addons/crm/crm_helpdesk_view.xml
@@ -117,7 +117,7 @@
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index 7f4d5030de4..51243f3e271 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -139,7 +139,7 @@
diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml
index 76399accba8..9a6fb6fb9a1 100644
--- a/addons/crm/crm_opportunity_view.xml
+++ b/addons/crm/crm_opportunity_view.xml
@@ -161,7 +161,7 @@
diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml
index 7af6ebcc868..a970701b735 100644
--- a/addons/crm/crm_view.xml
+++ b/addons/crm/crm_view.xml
@@ -361,7 +361,7 @@
diff --git a/addons/crm/security/ir.model.access.csv b/addons/crm/security/ir.model.access.csv
index cd47367c8bd..3ed862b98b9 100644
--- a/addons/crm/security/ir.model.access.csv
+++ b/addons/crm/security/ir.model.access.csv
@@ -32,12 +32,13 @@
"access_crm_phonecall_report_user","crm.phonecall.report","model_crm_phonecall_report","crm.group_crm_user",1,0,0,0
"access_crm_opportunity_report_user","crm.opportunity.report","model_crm_opportunity_report","crm.group_crm_user",1,0,0,0
"access_report_crm_case_service_dashboard","report.crm.case.service.dashboard","model_report_crm_case_service_dashboard","crm.group_crm_user",1,0,0,0
-"access_crm_lead2partner","crm.lead2partner","model_crm_lead2partner","crm.group_crm_user",1,0,0,0
-"access_crm_lead2opportunity","crm.lead2opportunity","model_crm_lead2opportunity","crm.group_crm_user",1,0,0,0
-"access_crm_opportunity2meeting","crm.opportunity2meeting","model_crm_opportunity2meeting","crm.group_crm_user",1,0,0,0
-"access_crm_opportunity2phonecall","crm.opportunity2phonecall","model_crm_opportunity2phonecall","crm.group_crm_user",1,0,0,0
-"access_crm_phonecall2phonecall","crm.phonecall2phonecall","model_crm_phonecall2phonecall","crm.group_crm_user",1,0,0,0
-"access_crm_phonecall2partner","crm.phonecall2partner","model_crm_phonecall2partner","crm.group_crm_user",1,0,0,0
-"access_crm_phonecall2meeting","crm.phonecall2meeting","model_crm_phonecall2meeting","crm.group_crm_user",1,0,0,0
-"access_crm_phonecall2opportunity","crm.phonecall2opportunity","model_crm_phonecall2opportunity","crm.group_crm_user",1,0,0,0
-"access_report_crm_helpdesk","report.crm.helpdesk","model_crm_helpdesk_report","crm.group_crm_user",1,0,0,0
+"access_crm_lead2partner","crm.lead2partner","model_crm_lead2partner","crm.group_crm_user",1,1,1,1
+"access_crm_lead2opportunity","crm.lead2opportunity","model_crm_lead2opportunity","crm.group_crm_user",1,1,1,1
+"access_crm_opportunity2meeting","crm.opportunity2meeting","model_crm_opportunity2meeting","crm.group_crm_user",1,1,1,1
+"access_crm_opportunity2phonecall","crm.opportunity2phonecall","model_crm_opportunity2phonecall","crm.group_crm_user",1,1,1,1
+"access_crm_phonecall2phonecall","crm.phonecall2phonecall","model_crm_phonecall2phonecall","crm.group_crm_user",1,1,1,1
+"access_crm_phonecall2partner","crm.phonecall2partner","model_crm_phonecall2partner","crm.group_crm_user",1,1,1,1
+"access_crm_phonecall2meeting","crm.phonecall2meeting","model_crm_phonecall2meeting","crm.group_crm_user",1,1,1,1
+"access_crm_phonecall2opportunity","crm.phonecall2opportunity","model_crm_phonecall2opportunity","crm.group_crm_user",1,1,1,1
+"access_report_crm_helpdesk","report.crm.helpdesk","model_crm_helpdesk_report","crm.group_crm_user",1,1,1,1
+"access_crm_send_mail","crm.send.mail","model_crmsend_mail","crm.group_crm_user",1,1,1,1
diff --git a/addons/crm/wizard/__init__.py b/addons/crm/wizard/__init__.py
index 0a74cfebc30..e95897a8495 100644
--- a/addons/crm/wizard/__init__.py
+++ b/addons/crm/wizard/__init__.py
@@ -19,7 +19,7 @@
#
##############################################################################
-import crm_send_new_email
+import crm_send_email
import wizard_history_event
import crm_lead_to_partner
diff --git a/addons/crm/wizard/crm_send_new_email.py b/addons/crm/wizard/crm_send_email.py
similarity index 99%
rename from addons/crm/wizard/crm_send_new_email.py
rename to addons/crm/wizard/crm_send_email.py
index 599d9022ef7..17442fe0052 100644
--- a/addons/crm/wizard/crm_send_new_email.py
+++ b/addons/crm/wizard/crm_send_email.py
@@ -27,7 +27,7 @@ import tools
class crm_send_new_email(osv.osv_memory):
""" Sends new email for the case"""
- _name = "crm.send.new.mail"
+ _name = "crm.send.mail"
_description = "Case Send new email"
_columns = {
diff --git a/addons/crm/wizard/crm_send_new_email_view.xml b/addons/crm/wizard/crm_send_email_view.xml
similarity index 89%
rename from addons/crm/wizard/crm_send_new_email_view.xml
rename to addons/crm/wizard/crm_send_email_view.xml
index 5411bf72af0..33b692b2d76 100644
--- a/addons/crm/wizard/crm_send_new_email_view.xml
+++ b/addons/crm/wizard/crm_send_email_view.xml
@@ -6,7 +6,7 @@
crm.new.send.mail.form
- crm.send.new.mail
+ crm.send.mail
form