2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
29 from tools.translate import _
32 from osv import fields,osv,orm
33 from osv.orm import except_orm
38 class crm_opportunity(osv.osv):
39 _name = "crm.opportunity"
40 _description = "Opportunity Cases"
44 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
45 'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
46 'type_id': fields.many2one('crm.case.resource.type', 'Resource Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
47 'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
48 'probability': fields.float('Probability (%)'),
49 'planned_revenue': fields.float('Planned Revenue'),
50 'planned_cost': fields.float('Planned Costs'),
51 'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
52 " With each commercial opportunity, you can indicate the canall which is this opportunity source."),
53 'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
54 "the partner mentality in relation to our services.The scale has" \
55 "to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
56 'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
57 'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
58 'date_closed': fields.datetime('Closed', readonly=True),
59 'phonecall_id':fields.many2one ('crm.phonecall', 'Phonecall'),
61 def onchange_categ_id(self, cr, uid, ids, categ, context={}):
64 cat = self.pool.get('crm.case.categ').browse(cr, uid, categ, context).probability
65 return {'value':{'probability':cat}}