1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 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
35 AVAILABLE_PRIORITIES = [
43 def _links_get(self, cr, uid, context={}):
44 obj = self.pool.get('res.request.link')
45 ids = obj.search(cr, uid, [])
46 res = obj.read(cr, uid, ids, ['object', 'name'], context)
47 return [(r['object'], r['name']) for r in res]
49 class crm_job_categ(osv.osv):
50 _name = "crm.job.categ"
51 _description = "Job Categories"
53 'name': fields.char('Category Name', size=64, required=True),
54 'probability': fields.float('Probability (%)', required=True),
55 'section_id': fields.many2one('crm.case.section', 'Case Section'),
58 'probability': lambda *args: 0.0
62 class crm_job(osv.osv):
64 _description = "Job Cases"
68 'date_closed': fields.datetime('Closed', readonly=True),
69 'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'),
70 'categ_id': fields.many2one('crm.job.categ', 'Category', domain="[('section_id','=',section_id)]"),
71 'planned_revenue': fields.float('Planned Revenue'),
72 'planned_cost': fields.float('Planned Costs'),
73 'probability': fields.float('Probability (%)'),
74 'partner_name': fields.char("Employee's Name", size=64),
75 'partner_name2': fields.char('Employee Email', size=64),
76 'partner_phone': fields.char('Phone', size=32),
77 'partner_mobile': fields.char('Mobile', size=32),
78 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id)]"),
79 'category2_id': fields.many2one('crm.case.category2', 'Category Name', domain="[('section_id','=',section_id)]"),
80 'duration': fields.float('Duration'),
81 'case_id': fields.many2one('crm.case', 'Related Case'),
82 'ref' : fields.reference('Reference', selection=_links_get, size=128),
83 'ref2' : fields.reference('Reference 2', selection=_links_get, size=128),
84 'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
85 " With each commercial opportunity, you can indicate the canall which is this opportunity source."),
86 'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
87 "the partner mentality in relation to our services.The scale has" \
88 "to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
92 def onchange_categ_id(self, cr, uid, ids, categ, context={}):
95 cat = self.pool.get('crm.categ.categ').browse(cr, uid, categ, context).probability
96 return {'value':{'probability':cat}}