~jo0thlt/sfsoluciones/mtf

« back to all changes in this revision

Viewing changes to l10n_mx_facturae_pac_sf/wizard/wizard_export_invoice_pac_sf_v6.py

  • Committer: contact at zbeanztech
  • Date: 2014-11-07 18:54:14 UTC
  • Revision ID: contact@zbeanztech.com-20141107185414-tzybvn7293tju4ce
 

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
#    Coded by: isaac (isaac@vauxoo.com)
 
11
#    Financed by: http://www.sfsoluciones.com (aef@sfsoluciones.com)
 
12
############################################################################
 
13
#
 
14
#    This program is free software: you can redistribute it and/or modify
 
15
#    it under the terms of the GNU Affero General Public License as
 
16
#    published by the Free Software Foundation, either version 3 of the
 
17
#    License, or (at your option) any later version.
 
18
#
 
19
#    This program is distributed in the hope that it will be useful,
 
20
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
22
#    GNU Affero General Public License for more details.
 
23
#
 
24
#    You should have received a copy of the GNU Affero General Public License
 
25
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
26
#
 
27
##############################################################################
 
28
 
 
29
from openerp.osv import fields, osv
 
30
from openerp.tools.translate import _
 
31
from openerp import pooler, tools, netsvc
 
32
from openerp.tools.misc import ustr
 
33
 
 
34
import time
 
35
import base64
 
36
import StringIO
 
37
import csv
 
38
import tempfile
 
39
import os
 
40
import sys
 
41
import codecs
 
42
import xml.dom.minidom
 
43
from datetime import datetime, timedelta
 
44
import time
 
45
 
 
46
 
 
47
class wizard_export_invoice_pac_sf_v6(osv.TransientModel):
 
48
    _name = 'wizard.export.invoice.pac.sf.v6'
 
49
 
 
50
    def _get_invoice_id(self, cr, uid, data, context={}):
 
51
        """
 
52
        @params data : Dictionary with information of the user, and active ids
 
53
        """
 
54
        res = {}
 
55
        invoice_obj = self.pool.get('account.invoice')
 
56
        res = invoice_obj._get_file(cr, uid, data['active_ids'])
 
57
        file_xml = res['file']
 
58
        return file_xml
 
59
 
 
60
    def upload_to_pac(self, cr, uid, ids, context={}):
 
61
        res = {}
 
62
        factura_attachment_pool = self.pool.get('ir.attachment.facturae.mx')
 
63
        factura_attachment_ids = factura_attachment_pool.search(cr, uid, [('invoice_id', 'in', context['active_ids'])],
 
64
                                                                context=context)
 
65
        res = factura_attachment_pool._upload_ws_file(cr, uid, factura_attachment_ids)
 
66
        self.write(cr, uid, ids, {'message': res['msg']}, context=None)
 
67
        return {
 
68
            'type': 'ir.actions.act_window',
 
69
            'name': 'Export invoice V6',
 
70
            'view_mode': 'form',
 
71
            'view_type': 'form',
 
72
            'res_model': 'wizard.export.invoice.pac.sf.v6',
 
73
            'nodestroy': 'true',
 
74
            'target': 'new',
 
75
            'res_id': ids[0],
 
76
            'views': [(False, 'form')],
 
77
        }
 
78
 
 
79
    _columns = {
 
80
        'file': fields.binary('File', readonly=True,
 
81
                              help='Shows the file returned'),
 
82
        'message': fields.text('text', readonly=True, help='Shows the message \
 
83
            that returned after of upload the xml to sign'),
 
84
    }
 
85
 
 
86
    _defaults = {
 
87
        'message': 'Choose the button Upload Invoice for export to PAC',
 
88
        'file': _get_invoice_id,
 
89
    }