[MERGE + clean] bug fix lp:689566

bzr revid: tfr@openerp.com-20110629110531-baxztn7ro4cznbtn
This commit is contained in:
tfr@openerp.com 2011-06-29 13:05:31 +02:00
commit 52fd99498c
3 changed files with 25 additions and 56 deletions

View File

@ -59,23 +59,17 @@ class crm_base(object):
def _get_default_partner_address(self, cr, uid, context=None):
"""Gives id of default address for current user
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values
:param context: if portal in context is false return false anyway
"""
if context is None:
context = {}
if not context.get('portal', False):
if not context.get('portal'):
return False
return self.pool.get('res.users').browse(cr, uid, uid, context).address_id.id
def _get_default_partner(self, cr, uid, context=None):
"""Gives id of partner for current user
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values
:param context: if portal in context is false return false anyway
"""
if context is None:
context = {}
@ -88,10 +82,7 @@ class crm_base(object):
def _get_default_email(self, cr, uid, context=None):
"""Gives default email address for current user
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values
:param context: if portal in context is false return false anyway
"""
if not context.get('portal', False):
return False
@ -102,10 +93,7 @@ class crm_base(object):
def _get_default_user(self, cr, uid, context=None):
"""Gives current user id
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values
:param context: if portal in context is false return false anyway
"""
if context and context.get('portal', False):
return False
@ -113,19 +101,12 @@ class crm_base(object):
def _get_section(self, cr, uid, context=None):
"""Gives section id for current User
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values
"""
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return user.context_section_id.id or False
def onchange_partner_address_id(self, cr, uid, ids, add, email=False):
"""This function returns value of partner email based on Partner Address
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case IDs
@param add: Id of Partner's address
@email: Partner's email ID
@ -140,9 +121,6 @@ class crm_base(object):
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
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case IDs
@param part: Partner's id
@email: Partner's email ID
@ -157,15 +135,13 @@ class crm_base(object):
def case_open(self, cr, uid, ids, *args):
"""Opens Case
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
print "case open"
cases = self.browse(cr, uid, ids)
for case in cases:
print case
print case.user_id
data = {'state': 'open', 'active': True}
if not case.user_id:
data['user_id'] = uid
@ -177,11 +153,7 @@ class crm_base(object):
def case_close(self, cr, uid, ids, *args):
"""Closes Case
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache
@ -196,11 +168,7 @@ class crm_base(object):
def case_cancel(self, cr, uid, ids, *args):
"""Cancels Case
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache
@ -214,11 +182,7 @@ class crm_base(object):
def case_pending(self, cr, uid, ids, *args):
"""Marks case as pending
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache
@ -228,11 +192,7 @@ class crm_base(object):
def case_reset(self, cr, uid, ids, *args):
"""Resets case as draft
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache

View File

@ -86,15 +86,21 @@ class crm_phonecall(crm_base, osv.osv):
if context and context.get('default_state', False):
return context.get('default_state')
return 'open'
def get_user_id(self, cr, uid, ctx):
print "default user"
return uid
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'priority': crm.AVAILABLE_PRIORITIES[2][0],
'state': _get_default_state,
'user_id': lambda self,cr,uid,ctx: uid,
'user_id': get_user_id,
'active': 1,
}
# From crm.case
def onchange_partner_address_id(self, cr, uid, ids, add, email=False):

View File

@ -21,6 +21,8 @@
from osv import osv, fields
from tools.translate import _
import pprint
pp = pprint.PrettyPrinter(indent=4)
import time
@ -121,23 +123,24 @@ class crm_opportunity2phonecall(osv.osv_memory):
for opp in opp_obj.browse(cr, uid, record_ids, context=context):
vals = {
'name' : opp.name,
'case_id' : opp.id ,
'case_id' : opp.id,
'user_id' : this.user_id and this.user_id.id or False,
'categ_id' : this.categ_id.id,
'description' : opp.description or False,
'date' : this.date,
'section_id' : this.section_id.id or opp.section_id.id or False,
'section_id' : this.section_id.id or False,
'partner_id': opp.partner_id and opp.partner_id.id or False,
'partner_address_id': opp.partner_address_id and opp.partner_address_id.id or False,
'partner_phone' : opp.phone or (opp.partner_address_id and opp.partner_address_id.phone or False),
'partner_mobile' : opp.partner_address_id and opp.partner_address_id.mobile or False,
'priority': opp.priority,
'opportunity_id': opp.id
'opportunity_id': opp.id,
'date_open': time.strftime('%Y-%m-%d %H:%M:%S')
}
new_case = phonecall_obj.create(cr, uid, vals, context=context)
if this.action == 'schedule':
phonecall_obj.case_open(cr, uid, [new_case])
elif this.action == 'log':
if this.action == 'log':
phonecall_obj.case_close(cr, uid, [new_case])
value = {
@ -149,7 +152,7 @@ class crm_opportunity2phonecall(osv.osv_memory):
'res_id' : new_case,
'views': [(id3, 'form'), (id2, 'tree'), (False, 'calendar')],
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
'search_view_id': res['res_id'],
}
return value