~vauxoo/openerp-mexico-localization/l10n_mx_facturae_ir_approval_sequence_dev_carlos

« back to all changes in this revision

Viewing changes to l10n_mx_invoice_tax_ref/invoice.py

  • Committer: moylop260
  • Date: 2012-09-09 23:47:31 UTC
  • mfrom: (181.2.17 addons-mx-trunk)
  • Revision ID: moylop260@vauxoo.com-20120909234731-1tp1zww18ydo4r0r
[MERGE] Merge from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
        res = {}
43
43
        for invoice_tax in self.browse(cr, uid, ids, context=context):
44
44
            res[invoice_tax.id] = {}
45
 
            tax_name = invoice_tax.name.lower().replace('.','').replace(' ', '').replace('-', '')
46
 
            tax_percent = invoice_tax.amount and invoice_tax.base and invoice_tax.amount*100.0 / abs( invoice_tax.base ) or 0.0
47
 
            if 'iva' in tax_name:
 
45
            tax = 'tax_id' in self._columns and invoice_tax.tax_id or False#If patch apply and module account_invoice_tax install
 
46
            tax_name = (tax and tax.tax_category_id and tax.tax_category_id.code or invoice_tax.name).upper().replace('.','').replace(' ', '').replace('-', '')
 
47
            tax_percent = (tax and tax.amount*100.0 or False)#validate? type='percent'
 
48
            tax_percent = tax_percent or ( invoice_tax.amount and invoice_tax.base and invoice_tax.amount*100.0 / abs( invoice_tax.base ) or 0.0 )
 
49
            if 'IVA' in tax_name:
48
50
                tax_name = 'IVA'
49
 
                if tax_percent > 0:
 
51
                if not tax and tax_percent > 0:
50
52
                    tax_percent = round(tax_percent, 0)#Hay problemas de decimales al calcular el iva, y hasta ahora el iva no tiene decimales
51
 
            elif 'isr' in tax_name:
 
53
            elif 'ISR' in tax_name:
52
54
                tax_name = 'ISR'
53
 
            elif 'ieps' in tax_name:
 
55
            elif 'IEPS' in tax_name:
54
56
                tax_name = 'IEPS'
55
57
            res[invoice_tax.id]['name2'] = tax_name
56
58
            res[invoice_tax.id]['tax_percent'] = tax_percent