~juan-pimentel/openerp-digisolution/6.0

« back to all changes in this revision

Viewing changes to digicommerce/wizard/digi_answer_wizard.py

  • Committer: Juan Jose Pimentel
  • Date: 2012-09-06 16:19:46 UTC
  • Revision ID: juan.pimentel@digi-solution.com-20120906161946-0h4y7dux2czxqh36
[ADD] wizard to answer partners questions  

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
################################################################################
 
2
#                                                                                                                                                                 
 
3
#    OpenERP, Open Source Management Solution    
 
4
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
 
5
#    
 
6
#
 
7
#    Coded by: Juan Jose Pimentel  <juan.pimentel@digi-solution.com>
 
8
#    Planified by: Juan Jose Pimentel  <juan.pimentel@digi-solution.com>
 
9
#
 
10
#    This program is free software: you can redistribute it and/or modify
 
11
#    it under the terms of the GNU General Public License as published by
 
12
#    the Free Software Foundation, either version 3 of the License, or
 
13
#    (at your option) any later version.
 
14
#
 
15
#    This program is distributed in the hope that it will be useful,
 
16
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
#    GNU General Public License for more details.
 
19
#
 
20
#    You should have received a copy of the GNU General Public License
 
21
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
22
#
 
23
##############################################################################
 
24
 
 
25
from osv import osv, fields
 
26
from tools.translate import _
 
27
 
 
28
class digi_answer_wizard(osv.osv_memory):
 
29
    _name = 'digi.answer.wizard'
 
30
    _decription= 'Digicommerce Partner Contact Answer Wizard'
 
31
    
 
32
    def action_done(self, cr, uid, ids, *args):
 
33
        notes = self.read(cr, uid, ids)[0].get('notes')
 
34
        if not notes:
 
35
            raise osv.except_osv(_('Error!'), _('You must answer to partner'))
 
36
        if args[0].get('active_ids'):
 
37
            partner_contact_id = args[0].get('active_ids')
 
38
            pc_obj = self.pool.get('digicommerce.partner.contact').browse(cr, uid, partner_contact_id,args[0])
 
39
            for o in pc_obj:
 
40
                o.action_done(notes)
 
41
        return {
 
42
                'view_mode' : 'tree,form',
 
43
                'type': 'ir.actions.act_window_close',
 
44
                }
 
45
 
 
46
    _columns = {
 
47
        'content':fields.text('Question',),
 
48
        'notes':fields.text('Answer',),
 
49
        
 
50
    } 
 
51
    
 
52
    _defaults = {
 
53
        'notes': lambda obj, cr, uid, context: context.get('notes'),
 
54
        'content': lambda obj, cr, uid, context: context.get('content'),
 
55
    
 
56
    }
 
57
 
 
58
digi_answer_wizard()