[IMP]: Set the object_id domain to all cases
[odoo/odoo.git] / addons / crm / crm_opportunity.py
1 #-*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
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.
11 #
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.
16 #
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/>.
19 #
20 ##############################################################################
21
22 import time
23 import re
24 import os
25
26 import mx.DateTime
27 import base64
28
29 from tools.translate import _
30
31 import tools
32 from osv import fields,osv,orm
33 from osv.orm import except_orm
34
35 import crm
36
37
38 class crm_opportunity(osv.osv):
39     _name = "crm.opportunity"
40     _description = "Opportunity Cases"
41     _order = "id desc"
42     _inherit = 'crm.case'  
43     _columns = {        
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'),
60     }
61     def onchange_categ_id(self, cr, uid, ids, categ, context={}):
62         if not categ:
63             return {'value':{}}
64         cat = self.pool.get('crm.case.categ').browse(cr, uid, categ, context).probability
65         return {'value':{'probability':cat}}        
66
67 crm_opportunity()
68