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
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_fundraising_categ(osv.osv):
50 _name = "crm.fundraising.categ"
51 _description = "Fundraising 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
60 crm_fundraising_categ()
62 class crm_fundraising_type(osv.osv):
63 _name = "crm.fundraising.type"
64 _description = "Fundraising Type"
67 'name': fields.char('Fundraising Type Name', size=64, required=True, translate=True),
68 'section_id': fields.many2one('crm.case.section', 'Case Section'),
71 crm_fundraising_type()
73 class crm_fundraising_stage(osv.osv):
74 _name = "crm.fundraising.stage"
75 _description = "Stage of fundraising case"
79 'name': fields.char('Stage Name', size=64, required=True, translate=True),
80 'section_id': fields.many2one('crm.case.section', 'Case Section'),
81 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of case stages."),
84 'sequence': lambda *args: 1
86 crm_fundraising_stage()
89 class crm_fundraising(osv.osv):
90 _name = "crm.fundraising"
91 _description = "Fund Raising Cases"
95 'date_closed': fields.datetime('Closed', readonly=True),
96 'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'),
97 'categ_id': fields.many2one('crm.fundraising.categ','Category', domain="[('section_id','=',section_id)]"),
98 'planned_revenue': fields.float('Planned Revenue'),
99 'planned_cost': fields.float('Planned Costs'),
100 'probability': fields.float('Probability (%)'),
101 'partner_name': fields.char("Employee's Name", size=64),
102 'partner_name2': fields.char('Employee Email', size=64),
103 'partner_phone': fields.char('Phone', size=32),
104 'partner_mobile': fields.char('Mobile', size=32),
105 'stage_id': fields.many2one ('crm.fundraising.stage', 'Stage', domain="[('section_id','=',section_id)]"),
106 'type_id': fields.many2one('crm.fundraising.type', 'Fundraising Type', domain="[('section_id','=',section_id)]"),
107 'duration': fields.float('Duration'),
108 'ref' : fields.reference('Reference', selection=_links_get, size=128),
109 'ref2' : fields.reference('Reference 2', selection=_links_get, size=128),
110 'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
111 " With each commercial opportunity, you can indicate the canall which is this opportunity source."),
112 'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
113 "the partner mentality in relation to our services.The scale has" \
114 "to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
118 'priority': lambda *a: AVAILABLE_PRIORITIES[2][0],
120 def onchange_categ_id(self, cr, uid, ids, categ, context={}):
123 cat = self.pool.get('crm.fundraising.categ').browse(cr, uid, categ, context).probability
124 return {'value':{'probability':cat}}