~argilsoft/+junk/mexico-70

« back to all changes in this revision

Viewing changes to l10n_mx_facturae_pac_sf/wizard/wizard_export_invoice_pac_sf_v5.py

  • Committer: Israel Cruz Argil
  • Date: 2013-02-16 00:45:44 UTC
  • Revision ID: israel.cruz@hesatecnica.com-20130216004544-gc1gwon7509x5uyn
Initial Importing...

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
###########################################################################
 
3
#    Module Writen to OpenERP, Open Source Management Solution
 
4
#
 
5
#    Copyright (c) 2011 Vauxoo - http://www.vauxoo.com
 
6
#    All Rights Reserved.
 
7
#    info Vauxoo (info@vauxoo.com)
 
8
############################################################################
 
9
#    Coded by: moylop260 (moylop260@vauxoo.com)
 
10
#    Financed by: http://www.sfsoluciones.com (aef@sfsoluciones.com)
 
11
############################################################################
 
12
#
 
13
#    This program is free software: you can redistribute it and/or modify
 
14
#    it under the terms of the GNU Affero General Public License as
 
15
#    published by the Free Software Foundation, either version 3 of the
 
16
#    License, or (at your option) any later version.
 
17
#
 
18
#    This program is distributed in the hope that it will be useful,
 
19
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
#    GNU Affero General Public License for more details.
 
22
#
 
23
#    You should have received a copy of the GNU Affero General Public License
 
24
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
25
#
 
26
##############################################################################
 
27
import wizard
 
28
import netsvc
 
29
import pooler
 
30
import time
 
31
import base64
 
32
import StringIO
 
33
import csv
 
34
import tempfile
 
35
import os
 
36
import sys
 
37
import codecs
 
38
import xml.dom.minidom
 
39
from datetime import datetime, timedelta
 
40
from tools.misc import ustr
 
41
try:
 
42
    from SOAPpy import WSDL
 
43
except:
 
44
    print "Package SOAPpy missed"
 
45
    pass
 
46
import time
 
47
####Agregar traducciones
 
48
_form = '''<?xml version="1.0"?>
 
49
<form string="Export invoice Solucion Factible">
 
50
    <image name="gtk-dialog-info" colspan="2"/>
 
51
    <group colspan="2" col="4">
 
52
        <field name="file"/>
 
53
        <newline/>
 
54
        <field name="msg" nolabel="1" colspan="3"/>
 
55
    </group>
 
56
</form>'''
 
57
_fields  = {
 
58
    'name': {
 
59
        'string': 'Name',
 
60
        'type': 'char',
 
61
        'size': 64,
 
62
    },
 
63
    'fname': {
 
64
        'string': 'Name',
 
65
        'type': 'char',
 
66
        'size': 64,
 
67
    },
 
68
    'file': {
 
69
        'string': 'File',
 
70
        'type': 'binary',
 
71
        'required': True,
 
72
        'readonly': True,
 
73
    },
 
74
    'msg': {
 
75
        'string' : 'msg',
 
76
        'type': 'text',
 
77
        'readonly': True,
 
78
    },
 
79
}
 
80
 
 
81
def _get_invoice_id(self, cr, uid, data, context = {}):
 
82
    res = {}
 
83
    pool = pooler.get_pool(cr.dbname)
 
84
    invoice_obj = pool.get('account.invoice')
 
85
    res = invoice_obj._get_file(cr, uid, data['ids'])
 
86
    return res
 
87
 
 
88
def _upload_to_pac(self, cr, uid, data, context ={}):
 
89
    res = {}
 
90
    pool = pooler.get_pool(cr.dbname)
 
91
    invoice_obj = pool.get('account.invoice')
 
92
    res = invoice_obj._upload_ws_file(cr, uid, data['ids'])
 
93
    return res
 
94
 
 
95
class wizard_export_invoice_pac_sf(wizard.interface):
 
96
    states = {
 
97
        'init': {
 
98
            'actions': [ _get_invoice_id ],
 
99
            'result': {'type': 'state', 'state':'show_view'},
 
100
        },
 
101
 
 
102
        'show_view': {
 
103
            'actions': [ ],
 
104
            'result': {
 
105
                'type': 'form',
 
106
                'arch': _form,
 
107
                'fields': _fields,
 
108
                'state': [ ('end', '_Cerrar', 'gtk-cancel', False), ('upload_ws', '_Subir Archivo', 'gtk-ok', True) ]
 
109
            }
 
110
        },
 
111
 
 
112
        'upload_ws': {
 
113
            'actions': [ _upload_to_pac ],
 
114
            'result': {'type': 'state', 'state':'show_view'},
 
115
        },
 
116
    }
 
117
wizard_export_invoice_pac_sf('wizard.export.invoice.pac.sf')