~vauxoo/addons-vauxoo/7.0-average_stock_valuation_journal_items-dev-yani

« back to all changes in this revision

Viewing changes to issue_load/wizard/load_issue.py

  • Committer: Yanina Aular
  • Date: 2014-04-25 23:42:42 UTC
  • mfrom: (0.1.1005 trunk)
  • Revision ID: yanina.aular@vauxoo.com-20140425234242-k4jkk1gd5t34r4c0

[MERGE] from addons-vauxoo-7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- encoding: utf-8 -*-
 
3
###########################################################################
 
4
#    Module Writen to OpenERP, Open Source Management Solution
 
5
#    Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
 
6
#    All Rights Reserved
 
7
# Credits######################################################
 
8
#    Coded by: Vauxoo C.A.
 
9
#    Planified by: Nhomar Hernandez
 
10
#    Audited by: Vauxoo C.A.
 
11
#############################################################################
 
12
#    This program is free software: you can redistribute it and/or modify
 
13
#    it under the terms of the GNU Affero General Public License as published by
 
14
#    the Free Software Foundation, either version 3 of the License, or
 
15
#    (at your option) any later version.
 
16
#
 
17
#    This program is distributed in the hope that it will be useful,
 
18
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
#    GNU Affero General Public License for more details.
 
21
#
 
22
#    You should have received a copy of the GNU Affero General Public License
 
23
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
24
##########################################################################
 
25
 
 
26
from openerp.osv import osv, fields
 
27
import openerp.tools as tools
 
28
from openerp.tools.translate import _
 
29
 
 
30
from tools import config
 
31
import openerp.netsvc as netsvc
 
32
import decimal_precision as dp
 
33
import time
 
34
import base64
 
35
from migrate import loadProjectsTasks
 
36
 
 
37
 
 
38
class load_issue(osv.TransientModel):
 
39
 
 
40
    _name = 'load.issue'
 
41
    _columns = {
 
42
        'issue': fields.binary('File XLS', requered=True,
 
43
            help="Put a xmind file"),
 
44
        'db': fields.char('Date Base', 40, help="Name of data base"),
 
45
        'port': fields.integer('XML-RPC Port',
 
46
            help="XML-RPC Port of server to load data"),
 
47
        'passs': fields.char('Password', 60,
 
48
            help="Password of data base"),
 
49
        'user': fields.char('User', 60, help="User of data base"),
 
50
        'host': fields.char('Host', 60, help="IP adreess of server"),
 
51
 
 
52
    }
 
53
 
 
54
    _defaults = {
 
55
        'db': 'vauxoo',
 
56
        'user': 'admin',
 
57
        'host': '70.38.44.102',
 
58
    }
 
59
 
 
60
    def xls_file(self, cr, uid, ids, context={}):
 
61
        wz_brw = self.browse(cr, uid, ids, context=context)[0]
 
62
        archivo = open("/tmp/load_issue.xls", "w")
 
63
        project_obj = self.pool.get('project.project')
 
64
        archivo.write(base64.b64decode(
 
65
            wz_brw and wz_brw.issue or 'Archivo Invalido'))
 
66
        archivo.close()
 
67
        if archivo:
 
68
            if wz_brw.db and wz_brw.port and wz_brw.passs and wz_brw.user and wz_brw.host:
 
69
                loadProjectsTasks(
 
70
                    '/tmp/load_issue.xls', wz_brw.host, wz_brw.port, wz_brw.db, wz_brw.user, wz_brw.passs)
 
71
            return True