[IMP]: Changed inheritance of crm_lead and crm_opportunity.
bzr revid: uco@tinyerp.co.in-20100111125742-mb80wjo05nhmo1o7
This commit is contained in:
parent
fe5161a704
commit
0defede5d6
|
@ -32,53 +32,47 @@ import tools
|
|||
from osv import fields,osv,orm
|
||||
from osv.orm import except_orm
|
||||
|
||||
AVAILABLE_PRIORITIES = [
|
||||
('5','Lowest'),
|
||||
('4','Low'),
|
||||
('3','Normal'),
|
||||
('2','High'),
|
||||
('1','Highest')
|
||||
]
|
||||
|
||||
def _links_get(self, cr, uid, context={}):
|
||||
obj = self.pool.get('res.request.link')
|
||||
ids = obj.search(cr, uid, [])
|
||||
res = obj.read(cr, uid, ids, ['object', 'name'], context)
|
||||
return [(r['object'], r['name']) for r in res]
|
||||
|
||||
class crm_lead(osv.osv):
|
||||
_name = "crm.lead"
|
||||
_description = "Leads Cases"
|
||||
_order = "id desc"
|
||||
_inherits = {'crm.case':"inherit_case_id"}
|
||||
_columns = {
|
||||
'inherit_case_id':fields.many2one('crm.case','Case'),
|
||||
_inherit = 'crm.case'
|
||||
_columns = {
|
||||
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id)]", help='Category related to the section.Subdivide the CRM cases independently or section-wise.'),
|
||||
'category2_id': fields.many2one('crm.case.category2', 'Category Name', domain="[('section_id','=',section_id)]"),
|
||||
'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),
|
||||
'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'),
|
||||
'probability': fields.float('Probability (%)'),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
'ref' : fields.reference('Reference', selection=_links_get, size=128),
|
||||
'ref2' : fields.reference('Reference 2', selection=_links_get, size=128),
|
||||
'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."),
|
||||
'planned_revenue': fields.float('Planned Revenue'),
|
||||
'planned_cost': fields.float('Planned Costs'),
|
||||
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id)]"),
|
||||
'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
|
||||
"the partner mentality in relation to our services.The scale has" \
|
||||
"to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
|
||||
}
|
||||
|
||||
def _map_ids(self, method, cr, uid, ids, *args, **argv):
|
||||
if isinstance(ids, (str, int, long)):
|
||||
select = [ids]
|
||||
else:
|
||||
select = ids
|
||||
case_data = self.browse(cr, uid, select)
|
||||
new_ids = []
|
||||
for case in case_data:
|
||||
if case.inherit_case_id:
|
||||
new_ids.append(case.inherit_case_id.id)
|
||||
res = getattr(self.pool.get('crm.case'),method)(cr, uid, new_ids, *args, **argv)
|
||||
if isinstance(ids, (str, int, long)) and isinstance(res, list):
|
||||
return res and res[0] or False
|
||||
return res
|
||||
|
||||
|
||||
def onchange_case_id(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('onchange_case_id',cr,uid,ids,*args,**argv)
|
||||
def stage_next(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('stage_next',cr,uid,ids,*args,**argv)
|
||||
def onchange_partner_id(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('onchange_partner_id',cr,uid,ids,*args,**argv)
|
||||
def onchange_partner_address_id(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('onchange_partner_address_id',cr,uid,ids,*args,**argv)
|
||||
def onchange_categ_id(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('onchange_categ_id',cr,uid,ids,*args,**argv)
|
||||
def case_close(self,cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('case_close',cr,uid,ids,*args,**argv)
|
||||
def case_open(self,cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('case_open',cr,uid,ids,*args,**argv)
|
||||
def case_cancel(self,cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('case_cancel',cr,uid,ids,*args,**argv)
|
||||
def case_reset(self,cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('case_reset',cr,uid,ids,*args,**argv)
|
||||
def case_escalate(self,cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('case_escalate',cr,uid,ids,*args,**argv)
|
||||
|
||||
|
||||
def msg_new(self, cr, uid, msg):
|
||||
mailgate_obj = self.pool.get('mail.gateway')
|
||||
msg_body = mailgate_obj.msg_body_get(msg)
|
||||
|
@ -96,11 +90,4 @@ class crm_lead(osv.osv):
|
|||
res = self.create(cr, uid, data)
|
||||
return res
|
||||
|
||||
def msg_update(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('msg_update',cr, uid, ids, *args, **argv)
|
||||
def emails_get(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('emails_get',cr, uid, ids, *args, **argv)
|
||||
def msg_send(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('msg_send',cr, uid, ids, *args, **argv)
|
||||
|
||||
crm_lead()
|
||||
|
|
|
@ -32,53 +32,42 @@ import tools
|
|||
from osv import fields,osv,orm
|
||||
from osv.orm import except_orm
|
||||
|
||||
AVAILABLE_PRIORITIES = [
|
||||
('5','Lowest'),
|
||||
('4','Low'),
|
||||
('3','Normal'),
|
||||
('2','High'),
|
||||
('1','Highest')
|
||||
]
|
||||
|
||||
def _links_get(self, cr, uid, context={}):
|
||||
obj = self.pool.get('res.request.link')
|
||||
ids = obj.search(cr, uid, [])
|
||||
res = obj.read(cr, uid, ids, ['object', 'name'], context)
|
||||
return [(r['object'], r['name']) for r in res]
|
||||
|
||||
class crm_opportunity(osv.osv):
|
||||
_name = "crm.opportunity"
|
||||
_description = "Opportunity Cases"
|
||||
_order = "id desc"
|
||||
_inherits = {'crm.case':"inherit_case_id"}
|
||||
_inherit = 'crm.case'
|
||||
_columns = {
|
||||
'inherit_case_id': fields.many2one('crm.case','Case',ondelete='cascade'),
|
||||
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id)]"),
|
||||
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id)]", help='Category related to the section.Subdivide the CRM cases independently or section-wise.'),
|
||||
'category2_id': fields.many2one('crm.case.category2', 'Category Name', domain="[('section_id','=',section_id)]"),
|
||||
'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'),
|
||||
'probability': fields.float('Probability (%)'),
|
||||
'planned_revenue': fields.float('Planned Revenue'),
|
||||
'planned_cost': fields.float('Planned Costs'),
|
||||
'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."),
|
||||
'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
|
||||
"the partner mentality in relation to our services.The scale has" \
|
||||
"to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
|
||||
'ref' : fields.reference('Reference', selection=_links_get, size=128),
|
||||
'ref2' : fields.reference('Reference 2', selection=_links_get, size=128),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
}
|
||||
def _map_ids(self, method, cr, uid, ids, *args, **argv):
|
||||
if isinstance(ids, (str, int, long)):
|
||||
select = [ids]
|
||||
else:
|
||||
select = ids
|
||||
case_data = self.browse(cr, uid, select)
|
||||
new_ids = []
|
||||
for case in case_data:
|
||||
if case.inherit_case_id:
|
||||
new_ids.append(case.inherit_case_id.id)
|
||||
res = getattr(self.pool.get('crm.case'),method)(cr, uid, new_ids, *args, **argv)
|
||||
if isinstance(ids, (str, int, long)) and isinstance(res, list):
|
||||
return res and res[0] or False
|
||||
return res
|
||||
|
||||
|
||||
def onchange_case_id(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('onchange_case_id',cr,uid,ids,*args,**argv)
|
||||
def stage_next(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('stage_next',cr,uid,ids,*args,**argv)
|
||||
def onchange_partner_id(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('onchange_partner_id',cr,uid,ids,*args,**argv)
|
||||
def onchange_partner_address_id(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('onchange_partner_address_id',cr,uid,ids,*args,**argv)
|
||||
def onchange_categ_id(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('onchange_categ_id',cr,uid,ids,*args,**argv)
|
||||
def case_close(self,cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('case_close',cr,uid,ids,*args,**argv)
|
||||
def case_open(self,cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('case_open',cr,uid,ids,*args,**argv)
|
||||
def case_cancel(self,cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('case_cancel',cr,uid,ids,*args,**argv)
|
||||
def case_reset(self,cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('case_reset',cr,uid,ids,*args,**argv)
|
||||
def case_escalate(self,cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('case_escalate',cr,uid,ids,*args,**argv)
|
||||
def case_pending(self,cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('case_pending',cr,uid,ids,*args,**argv)
|
||||
|
||||
def msg_new(self, cr, uid, msg):
|
||||
mailgate_obj = self.pool.get('mail.gateway')
|
||||
|
@ -97,12 +86,6 @@ class crm_opportunity(osv.osv):
|
|||
res = self.create(cr, uid, data)
|
||||
return res
|
||||
|
||||
def msg_update(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('msg_update',cr, uid, ids, *args, **argv)
|
||||
def emails_get(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('emails_get',cr, uid, ids, *args, **argv)
|
||||
def msg_send(self, cr, uid, ids, *args, **argv):
|
||||
return self._map_ids('msg_send',cr, uid, ids, *args, **argv)
|
||||
crm_opportunity()
|
||||
|
||||
|
||||
|
@ -139,7 +122,7 @@ class crm_opportunity_assign_wizard(osv.osv_memory):
|
|||
{
|
||||
'section_id':res.get('section_id',False),
|
||||
'user_id':res.get('user_id',False),
|
||||
'case_id' : case.inherit_case_id.id
|
||||
'case_id' : case.id
|
||||
}, context=context)
|
||||
case_obj.case_close(cr, uid, [case_id])
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ class lead2opportunity(wizard.interface):
|
|||
'planned_revenue': data['form']['planned_revenue'],
|
||||
'probability': data['form']['probability'],
|
||||
'partner_id': data['form']['partner_id'],
|
||||
'case_id':lead.inherit_case_id.id,
|
||||
'case_id':lead.id,
|
||||
})
|
||||
|
||||
new_opportunity = opportunity_case_obj.browse(cr, uid, new_opportunity_id)
|
||||
|
|
|
@ -86,7 +86,7 @@ class opportunity2phonecall(wizard.interface):
|
|||
#TODO : Take Other Info from opportunity
|
||||
new_case = phonecall_case_obj.create(cr, uid, {
|
||||
'name' : opportunity.name,
|
||||
'case_id' : opportunity.inherit_case_id.id,
|
||||
'case_id' : opportunity.id,
|
||||
'user_id' : form['user_id'],
|
||||
'categ_id' : form['category_id'],
|
||||
'description' : form['note'],
|
||||
|
|
Loading…
Reference in New Issue