[FIX]: crm, crm_claim, crm_helpdesk, crm_fundraising: Improvement in tooltips
[odoo/odoo.git] / addons / crm_claim / crm_claim.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 from osv import fields, osv
23 from crm import crm
24 import time
25 class crm_claim(osv.osv, crm.crm_case):
26     """
27     Crm claim
28     """
29     _name = "crm.claim"
30     _description = "Claim Cases"
31     _order = "id desc"
32     _inherit = ['mailgate.thread']
33     _columns = {
34         'id': fields.integer('ID', readonly=True), 
35         'name': fields.char('Name', size=128, required=True), 
36         'active': fields.boolean('Active', required=False), 
37         'date_action_last': fields.datetime('Last Action', readonly=1),
38         'date_action_next': fields.datetime('Next Action', readonly=1),
39         'description': fields.text('Description'), 
40         'create_date': fields.datetime('Creation Date' , readonly=True), 
41         'write_date': fields.datetime('Update Date' , readonly=True), 
42         'date_deadline': fields.date('Deadline'), 
43         'date_closed': fields.datetime('Closed', readonly=True), 
44         'date': fields.datetime('Date'), 
45         'ref' : fields.reference('Reference', selection=crm._links_get, size=128), 
46         'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128), 
47         'canal_id': fields.many2one('res.partner.canal', 'Channel', \
48                      help="The channels represent the different communication"\
49                       "modes available with the customer." \
50                      " With each commercial opportunity, you can indicate the"\
51                       "canall which is this opportunity source."), 
52         'planned_revenue': fields.float('Planned Revenue'), 
53         'planned_cost': fields.float('Planned Costs'), 
54         'som': fields.many2one('res.partner.som', 'State of Mind', \
55                         help="The minds states allow to define a value scale "\
56                             "which represents the partner mentality in "\
57                             "relation to our services.The scale has to be "\
58                             "created with a factor for each level from 0 "\
59                             "(Very dissatisfied) to 10 (Extremely satisfied)"), 
60         'categ_id': fields.many2one('crm.case.categ', 'Category', \
61                             domain="[('section_id','=',section_id),\
62                             ('object_id.model', '=', 'crm.claim')]"), 
63         'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'), 
64         'type_id': fields.many2one('crm.case.resource.type', 'Claim Type', \
65                          domain="[('section_id','=',section_id),\
66                          ('object_id.model', '=', 'crm.claim')]"), 
67         'user_id': fields.many2one('res.users', 'Responsible'), 
68         'section_id': fields.many2one('crm.case.section', 'Sales Team', \
69                         select=True, help="Sales team to which Case belongs to."\
70                                 "Define Responsible user and Email account for"\
71                                 " mail gateway."), 
72         'company_id': fields.many2one('res.company', 'Company'), 
73         'partner_id': fields.many2one('res.partner', 'Partner'), 
74         'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
75                                 # domain="[('partner_id','=',partner_id)]"
76                                  ), 
77         'email_cc': fields.text('Watchers Emails', size=252, help="These addresses(Comma-separated) will receive a copy of the future communication between partner and users"), 
78         'email_from': fields.char('Email', size=128, help="These people will receive email."), 
79         'partner_name': fields.char("Employee's Name", size=64), 
80         'partner_mobile': fields.char('Mobile', size=32), 
81         'partner_phone': fields.char('Phone', size=32), 
82         'stage_id': fields.many2one ('crm.case.stage', 'Stage'), 
83         'probability': fields.float('Probability (%)'), 
84         'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True, 
85                                   help='The state is set to \'Draft\', when a case is created.\
86                                   \nIf the case is in progress the state is set to \'Open\'.\
87                                   \nWhen the case is over, the state is set to \'Done\'.\
88                                   \nIf the case needs to be reviewed then the state is set to \'Pending\'.'), 
89         'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True),('model','=',_name)]),
90         'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('model','=',_name)]),
91     }
92
93     _defaults = {
94         'active': lambda *a: 1, 
95         'user_id': crm.crm_case._get_default_user, 
96         'partner_id': crm.crm_case._get_default_partner, 
97         'partner_address_id': crm.crm_case._get_default_partner_address, 
98         'email_from':crm.crm_case. _get_default_email, 
99         'state': lambda *a: 'draft', 
100         'section_id':crm.crm_case. _get_section, 
101         'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
102         'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c), 
103         'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0], 
104     }
105     
106     def onchange_partner_id(self, cr, uid, ids, part, email=False):
107         """This function returns value of partner address based on partner
108         @param self: The object pointer
109         @param cr: the current row, from the database cursor,
110         @param uid: the current user’s ID for security checks,
111         @param ids: List of case IDs
112         @param part: Partner's id
113         @email: Partner's email ID
114         """
115         if not part:
116             return {'value': {'partner_address_id': False,
117                             'email_from': False, 
118                             'partner_phone': False,
119                             'partner_mobile': False
120                             }}
121         addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['contact'])
122         data = {'partner_address_id': addr['contact']}
123         data.update(self.onchange_partner_address_id(cr, uid, ids, addr['contact'])['value'])
124         print data
125         return {'value': data}
126
127     def onchange_partner_address_id(self, cr, uid, ids, add, email=False):
128         """This function returns value of partner email based on Partner Address
129         @param self: The object pointer
130         @param cr: the current row, from the database cursor,
131         @param uid: the current user’s ID for security checks,
132         @param ids: List of case IDs
133         @param add: Id of Partner's address
134         @email: Partner's email ID
135         """
136         if not add:
137             return {'value': {'email_from': False}}
138         address = self.pool.get('res.partner.address').browse(cr, uid, add)
139         return {'value': {'email_from': address.email, 'partner_phone': address.phone, 'partner_mobile': address.mobile}}
140
141
142 crm_claim()
143
144 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: