[FIX] crm fix crm_claim

bzr revid: al@openerp.com-20110825045455-95a8nt7ep6sonk3a
This commit is contained in:
Antony Lesuisse 2011-08-25 06:54:55 +02:00
parent dcc7b02198
commit c8dcb4e685
3 changed files with 16 additions and 67 deletions

View File

@ -350,7 +350,7 @@ class crm_case(crm_base):
value = {}
if hasattr(self,'onchange_stage_id'):
value = self.onchange_stage_id(cr, uid, ids, stage_id)['value']
value['stage_id'] = stage_id
value['stage_id'] = stage_id
self.write(cr, uid, ids, value, context=context)
def stage_change(self, cr, uid, ids, op, order, context=None):

View File

@ -82,33 +82,6 @@ class crm_claim(crm.crm_case, osv.osv):
\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)]),
}
def stage_next(self, cr, uid, ids, context=None):
stage = super(crm_claim, self).stage_next(cr, uid, ids, context=context)
if stage:
stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, stage, context=context)
self.history(cr, uid, ids, _("Changed Stage to: ") + stage_obj.name)
return stage
def stage_previous(self, cr, uid, ids, context=None):
stage = super(crm_claim, self).stage_previous(cr, uid, ids, context=context)
if stage:
stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, stage, context=context)
self.history(cr, uid, ids, _("Changed Stage to: ") + stage_obj.name)
return stage
def _get_stage_id(self, cr, uid, context=None):
"""Finds type of stage according to object.
@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
"""
if context is None:
context = {}
type = context and context.get('stage_type', '')
stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [('type','=',type),('sequence','>=',1)])
return stage_ids and stage_ids[0] or False
_defaults = {
'user_id': crm.crm_case._get_default_user,
@ -116,19 +89,14 @@ class crm_claim(crm.crm_case, osv.osv):
'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,
'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),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
#'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
@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
"""
@ -145,10 +113,6 @@ class crm_claim(crm.crm_case, osv.osv):
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
"""
@ -156,28 +120,23 @@ 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
"""
for l in self.browse(cr, uid, ids):
# When coming from draft override date and stage otherwise just set state
if l.state == 'draft':
message = _("The claim '%s' has been opened.") % l.name
self.log(cr, uid, l.id, message)
value = {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}
self.write(cr, uid, [l.id], value)
stage_id = self.stage_find(cr, uid, l.section_id.id or False, [('sequence','>',0)])
if stage_id:
self.stage_set(cr, uid, [l.id], stage_id)
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
def message_new(self, cr, uid, msg, context=None):
"""
Automatically calls when new email message arrives
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks
""" Automatically calls when new email message arrives
"""
mailgate_pool = self.pool.get('email.server.tools')
@ -217,9 +176,6 @@ class crm_claim(crm.crm_case, osv.osv):
def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context=None):
"""
@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 update mails IDs
"""
if isinstance(ids, (str, int, long)):
@ -253,21 +209,14 @@ class crm_claim(crm.crm_case, osv.osv):
return res
def msg_send(self, cr, uid, id, *args, **argv):
""" Send The Message
@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 emails IDs
@param *args: Return Tuple Value
@param **args: Return Dictionary of Keyword Value
@param ids: List of emails IDs
"""
return True
crm_claim()
class res_partner(osv.osv):
_inherit = 'res.partner'
_columns = {
'claims_ids': fields.one2many('crm.claim', 'partner_id', 'Claims'),

View File

@ -82,7 +82,7 @@
<group colspan="2" col="4">
<field name="stage_id" domain="[('section_ids','=',section_id)]"/>
<button name="stage_previous" string="" type="object" icon="gtk-go-back" />
<button icon="gtk-go-forward" string="" name="stage_next" type="object"/>
<button name="stage_next" string="" type="object" icon="gtk-go-forward" />
</group>
<newline />
<field name="priority"/>