~serpent-consulting-services/addons-vauxoo/7.0-fix-aging-due-mx-dependency

« back to all changes in this revision

Viewing changes to note_to_task/wizard/convert_note.py

  • Committer: Moises Lopez
  • Date: 2014-10-03 08:04:16 UTC
  • mfrom: (1144.1.3 70-addons-vauxoo)
  • Revision ID: moylop260@vauxoo.com-20141003080416-yquvsxfq5i4cy8ux
[MERGE] [FIX] trailing whitespace pylint error C0303 and
[FIX] autopep8 ignoring E501 & E128 and
[FIX] reimported

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python                                                               
2
 
# -*- encoding: utf-8 -*-                                                       
3
 
############################################################################### 
 
1
#!/usr/bin/python
 
2
# -*- encoding: utf-8 -*-
 
3
###############################################################################
4
4
#    Module Writen to OpenERP, Open Source Management Solution
5
5
#    Copyright (C) Vauxoo (<http://vauxoo.com>).
6
 
#    All Rights Reserved                                                        
7
 
################# Credits###################################################### 
 
6
#    All Rights Reserved
 
7
################# Credits######################################################
8
8
#    Coded by: Luis Escobar <luis@vauxoo.com>
9
9
#    Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
10
 
############################################################################### 
11
 
#    This program is free software: you can redistribute it and/or modify       
12
 
#    it under the terms of the GNU Affero General Public License as published   
13
 
#    by the Free Software Foundation, either version 3 of the License, or       
14
 
#    (at your option) any later version.                                        
15
 
#                                                                               
16
 
#    This program is distributed in the hope that it will be useful,            
17
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of             
18
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
19
 
#    GNU Affero General Public License for more details.                        
20
 
#                                                                               
21
 
#    You should have received a copy of the GNU Affero General Public License   
22
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.      
23
 
###############################################################################    
 
10
###############################################################################
 
11
#    This program is free software: you can redistribute it and/or modify
 
12
#    it under the terms of the GNU Affero General Public License as published
 
13
#    by the Free Software Foundation, either version 3 of the License, or
 
14
#    (at your option) any later version.
 
15
#
 
16
#    This program is distributed in the hope that it will be useful,
 
17
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
#    GNU Affero General Public License for more details.
 
20
#
 
21
#    You should have received a copy of the GNU Affero General Public License
 
22
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
23
###############################################################################
24
24
 
25
25
from openerp.osv import fields, osv
26
26
 
 
27
 
27
28
class convert_note_task(osv.TransientModel):
28
 
    
 
29
 
29
30
    '''Convert Note to Task Wizard'''
30
 
    
 
31
 
31
32
    _name = 'convert.note.task'
32
 
    
 
33
 
33
34
    _columns = {
34
 
            'estimated_time':fields.float('Estimated Time', help="""Estimated Time to Complete the
35
 
                Task""", required=True), 
36
 
            'project_id':fields.many2one('project.project', 'Project', help='Project Linked', required=True), 
37
 
            'date_deadline':fields.date('Deadline', help='Date to complete the Task', required=True), 
 
35
        'estimated_time': fields.float('Estimated Time', help="""Estimated Time to Complete the
 
36
                Task""", required=True),
 
37
        'project_id': fields.many2one('project.project', 'Project', help='Project Linked', required=True),
 
38
        'date_deadline': fields.date('Deadline', help='Date to complete the Task', required=True),
38
39
    }
39
40
 
40
41
    def create_task(self, cr, uid, ids, context=None):
41
42
        if context is None:
42
 
            context = {} 
43
 
        cvt_brw = self.browse(cr, uid, ids, context=context) 
 
43
            context = {}
 
44
        cvt_brw = self.browse(cr, uid, ids, context=context)
44
45
        task_obj = self.pool.get('project.task')
45
46
        note_obj = self.pool.get('note.note')
46
47
        note_brw = note_obj.browse(cr, uid, [context.get('active_id')], context=context)
47
48
        task_id = task_obj.create(cr, uid, {
48
 
                'name': note_brw[0].name,
49
 
                'description': note_brw[0].memo,   
50
 
                'project_id': cvt_brw[0].project_id.id,
51
 
                'user_id': uid,
52
 
                'date_deadline': cvt_brw[0].date_deadline,
53
 
            },context=context); 
 
49
            'name': note_brw[0].name,
 
50
            'description': note_brw[0].memo,
 
51
            'project_id': cvt_brw[0].project_id.id,
 
52
            'user_id': uid,
 
53
            'date_deadline': cvt_brw[0].date_deadline,
 
54
        }, context=context)
54
55
        note_obj.write(cr, uid, [context.get('active_id')], {
55
 
                'open': False,
56
 
            })
 
56
            'open': False,
 
57
        })
57
58
        obj_model = self.pool.get('ir.model.data')
58
59
        model_data_ids = obj_model.search(
59
60
            cr, uid, [('model', '=', 'ir.ui.view'),
61
62
        resource_id = obj_model.read(cr, uid, model_data_ids,
62
63
                                    fields=['res_id'])[0]['res_id']
63
64
        return {
64
 
           'view_type': 'form',
65
 
           'view_mode': 'form',
66
 
           'res_model': 'project.task',
67
 
           'views': [(resource_id, 'form')],
68
 
           'res_id': task_id, 
69
 
           'type': 'ir.actions.act_window',
70
 
           'context': {},
 
65
            'view_type': 'form',
 
66
            'view_mode': 'form',
 
67
            'res_model': 'project.task',
 
68
            'views': [(resource_id, 'form')],
 
69
            'res_id': task_id,
 
70
            'type': 'ir.actions.act_window',
 
71
            'context': {},
71
72
        }