~eduardo-bayardo-bias/bias-trunk/bias_trunk

« back to all changes in this revision

Viewing changes to bias_electronic_invoice_v6/invoice.py

  • Committer: Arturo Galvan Rdz.
  • Date: 2011-05-09 21:20:52 UTC
  • mfrom: (186 bias_trunk)
  • mto: (193.1.28 bias_trunk)
  • mto: This revision was merged to the branch mainline in revision 188.
  • Revision ID: agalvan@duglas.com.mx-20110509212052-bnpo469jwrm5rm1o
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
                'uuid':fields.char('UUID', size=36),
71
71
                'bar_code': fields.binary('Bar Code'),
72
72
                #'provider_signature':  fields.text('Signature Provider'),
73
 
                #'invoice_xml':fields.text('Invoice_Xml'),
74
73
                }
75
74
 
76
75
 
204
203
                                date_time = now().Format('%Y-%m-%d %H:%M:%S')
205
204
                                self.write(cr, uid, ids, {'cancel_date':date_time})
206
205
                        if inv_brw.company_id.proveedor_cfd == 'my_suite_cfd' and inv_brw.journal_id.e_invoice:
207
 
                                print 'entra al metodo de canclacio de my suite'
208
206
                                from  invoice_mys import *
209
207
                                self.mysuiteConn = MySuiteConn()
210
208
                                self.mysuiteConn.transaction = "CANCEL_XML"
288
286
                                'FROM account_invoice ' \
289
287
                                'WHERE id IN ('+','.join(map(str,ids))+')')
290
288
                for (id, invtype, number, move_id, reference) in cr.fetchall():
291
 
                        if not number:
 
289
                        if not number or number == '/':
292
290
                                if (self.browse(cr, uid, id).journal_id.e_invoice) and (self.browse(cr, uid, id).journal_id.code == 'nota_credito_e'):
293
291
                                        invtype = 'nota_credito_e'
294
292
                                elif self.browse(cr, uid, id).journal_id.e_invoice:
300
298
                                else:
301
299
                                        ref = self._convert_ref(cr, uid, number)
302
300
                                cr.execute('UPDATE account_invoice SET number=%s ' \
303
 
                                                'WHERE id=%d', (number, id))
 
301
                                                'WHERE id=%s', (number, id))
304
302
                                cr.execute('UPDATE account_move_line SET ref=%s ' \
305
 
                                                'WHERE move_id=%d AND (ref is null OR ref = \'\')',
 
303
                                                'WHERE move_id=%s AND (ref is null OR ref = \'\')',
306
304
                                                (ref, move_id))
307
305
                                cr.execute('UPDATE account_analytic_line SET ref=%s ' \
308
306
                                                'FROM account_move_line ' \
309
 
                                                'WHERE account_move_line.move_id = %d ' \
 
307
                                                'WHERE account_move_line.move_id = %s ' \
310
308
                                                        'AND account_analytic_line.move_id = account_move_line.id',
311
309
                                                        (ref, move_id))
312
310
                return True
336
334
                        if inv_brw.type in ('in_invoice','in_refund'):
337
335
                                super(account_invoice, self).action_number( cr, uid, ids, *args)
338
336
                        #super(account_invoice, self).action_number( cr, uid, ids, *args)
339
 
                        else:
340
 
                                print 'se va por el else en test_open'
341
 
                                super(account_invoice, self).action_number( cr, uid, [inv_brw.id], *args)
 
337
                        #else:
 
338
                                #print '        super(account_invoice'
 
339
                                #super(account_invoice, self).action_number( cr, uid, [inv_brw.id], *args)
342
340
                        if (inv_brw.journal_id.e_invoice) and (inv_brw.type in ('out_invoice', 'out_refund')):
343
341
                                #try:
344
 
                                #self.action_number( cr, uid, [inv_brw.id], *args)
 
342
                                self.action_number( cr, uid, [inv_brw.id], *args)
345
343
                                if inv_brw.company_id.proveedor_cfd == 'propios_medios':
346
344
                                        cadenatimbre = ''
 
345
                                        print 'create_xml'
347
346
                                        cfe = self.create_xml(cr, uid, [inv_brw.id], *args)
348
347
                                        cfe_str = etree.tostring(cfe, pretty_print=True, encoding='utf-8')
349
348
                                elif inv_brw.company_id.proveedor_cfd == 'my_suite_cfd':
402
401
 
403
402
 
404
403
        def make_barcode(self, cr, uid, inv_id):
405
 
                print 'make_barcode',inv_id
406
404
                inv_brw = self.browse(cr, uid, inv_id)
407
405
                cfdutil.createBarCodeImg(inv_brw.company_id.partner_id.vat,
408
406
                                         inv_brw.partner_id.vat,
793
791
        
794
792
        def get_inv_number(self, cr, uid, inv_brw):
795
793
                prefix = ''
796
 
                if inv_brw.journal_id.sequence_id:
797
 
                        prefix = inv_brw.journal_id.sequence_id.prefix
 
794
                if (inv_brw.journal_id.e_invoice) and (inv_brw.journal_id.code == 'nota_credito_e'):
 
795
                        invtype = 'nota_credito_e'
 
796
                elif inv_brw.journal_id.e_invoice:
 
797
                        invtype = 'factura_e'
 
798
                sequence_obj = self.pool.get('ir.sequence')
 
799
                code = 'account.invoice.' + invtype
 
800
                sequence_id = sequence_obj.search(cr, uid, [('code','=',code)])
 
801
                prefix = sequence_obj.browse(cr, uid, sequence_id[0]).prefix
798
802
                if (prefix) and (inv_brw.number):
 
803
 
799
804
                        number = int(inv_brw.number[len(prefix):])
800
805
                else:
801
806
                        number = int(inv_brw.number)