2009-12-30 10:20:44 +00:00
|
|
|
#-*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# OpenERP, Open Source Management Solution
|
2010-01-12 09:18:39 +00:00
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
2009-12-30 10:20:44 +00:00
|
|
|
#
|
|
|
|
# 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 fields,osv,orm
|
2010-01-13 13:34:09 +00:00
|
|
|
import crm
|
2009-12-30 10:20:44 +00:00
|
|
|
|
2010-02-19 17:15:16 +00:00
|
|
|
AVAILABLE_STATES = [
|
|
|
|
('draft','New'),
|
|
|
|
('open','Open'),
|
|
|
|
('cancel', 'Lost'),
|
|
|
|
('done', 'Won'),
|
|
|
|
('pending','Pending')
|
|
|
|
]
|
|
|
|
|
2009-12-30 10:20:44 +00:00
|
|
|
class crm_opportunity(osv.osv):
|
|
|
|
_name = "crm.opportunity"
|
|
|
|
_description = "Opportunity Cases"
|
|
|
|
_order = "id desc"
|
2010-02-19 17:15:16 +00:00
|
|
|
_inherit = 'crm.case'
|
|
|
|
_columns = {
|
2010-01-19 04:41:02 +00:00
|
|
|
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
|
2010-02-23 10:35:15 +00:00
|
|
|
'categ_id': fields.many2one('crm.case.categ', 'Source', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
|
2010-01-19 04:41:02 +00:00
|
|
|
'type_id': fields.many2one('crm.case.resource.type', 'Resource Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
|
2010-01-13 13:34:09 +00:00
|
|
|
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
|
2010-01-11 13:16:46 +00:00
|
|
|
'probability': fields.float('Probability (%)'),
|
2010-02-19 17:15:16 +00:00
|
|
|
'planned_revenue': fields.float('Expected Revenue'),
|
2010-01-13 13:34:09 +00:00
|
|
|
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
|
|
|
|
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
|
2010-01-11 13:16:46 +00:00
|
|
|
'date_closed': fields.datetime('Closed', readonly=True),
|
2010-02-19 17:15:16 +00:00
|
|
|
'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\'.'),
|
2009-12-30 10:20:44 +00:00
|
|
|
}
|
2010-02-23 10:35:15 +00:00
|
|
|
def onchange_stage_id(self, cr, uid, ids, stage, context={}):
|
|
|
|
if not stage:
|
|
|
|
return {'value':{}}
|
|
|
|
probability = self.pool.get('crm.case.stage').browse(cr, uid, stage, context).probability
|
|
|
|
return {'value':{'probability':probability}}
|
2010-01-13 10:31:48 +00:00
|
|
|
|
2009-12-31 12:57:20 +00:00
|
|
|
crm_opportunity()
|
|
|
|
|