1
##############################################################################
3
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
5
# WARNING: This program as such is intended to be used by professional
6
# programmers who take the whole responsability of assessing all potential
7
# consequences resulting from its eventual inadequacies and bugs
8
# End users who are looking for a ready-to-use solution with commercial
9
# garantees and support are strongly adviced to contract a Free Software
12
# This program is Free Software; you can redistribute it and/or
13
# modify it under the terms of the GNU General Public License
14
# as published by the Free Software Foundation; either version 2
15
# of the License, or (at your option) any later version.
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 General Public License for more details.
22
# You should have received a copy of the GNU General Public License
23
# along with this program; if not, write to the Free Software
24
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
##############################################################################
29
from report import report_sxw
32
from lxml import etree
34
class account_invoice(report_sxw.rml_parse):
35
def __init__(self, cr, uid, name, context):
36
super(account_invoice, self).__init__(cr, uid, name, context)
37
user = self.pool.get('res.users').browse(cr, uid, uid)
38
self.localcontext.update({
40
'date_sp': text.date_sp,
41
'moneyfmt': text.moneyfmt,
42
'texto': self._get_text,
43
#'fix_space': text.fix_space,
45
'get_impuestos':self._get_impuestos,
46
'tipoDeComprobante': self._get_tipoDeComprobante,
47
'leyendaTipoDeCambio': self._get_leyendaTipoDeCambio,
48
'leyenda':self._get_leyenda_UDS,
49
'leyenda_pitex':self._get_leyenda_pitex,
50
'cadena':self._get_cadena,
51
#'give_me_space':self._give_me_space,
54
def _get_lines(self, txt):
55
res = txt[:len(txt)/2] + ' ' + txt[len(txt)/2:]
58
def _get_text(self, amount):
59
return text.text(int(amount))
61
def _get_cadena(self, cadena):
62
rows = len(cadena)/120
64
for rn in range(rows):
65
res += cadena[200*rn:(200*(rn+1))] + '\n'
68
def _get_leyenda_UDS(self, obj):
69
if obj.currency_id.code == 'USD':
70
return 'LA PRESENTE FACTURA SE SOLVENTARA ENTREGADO EL EQUIVALENTE EN MONEDA NACIONAL, AL TIPO DE CAMBIO QUE EL BANCO DE MEXICO PUBLIQUE EN EL DIARIO OFICIAL DE LA FEDERACION, EL DIA HABIL BANCARIO INMEDIATO ANTERIOR A AQUEL EN QUE SE EFECTUE EL PAGO'
74
def _get_leyenda_pitex(self, obj):
75
if obj.partner_id.property_account_position.name == 'RETENEDOR DEL IVA':
76
return 'Impuesto retenido de conformidad con la Ley del Impuesto al Valor Agregado'
81
def _get_tipoDeComprobante(self, inv_brw):
82
if inv_brw.type == 'out_invoice':
84
elif inv_brw.type == 'out_refund':
86
elif inv_brw.company_id.partner_id.vat == inv_brw.partner_id.vat:
92
def _get_leyendaTipoDeCambio(self, inv_brw):
93
if inv_brw.currency_id.code == 'USD':
94
return 'La presente factura se solventara entregado el equivalente en moneda nacional, al tipo de cambio que el Banco de Mexico publique en el Diario Oficial de la Federacion, el dia habil bancario inmediato anterior a aquel en que se efectue el pago'
100
def _get_impuestos(self, invoice_obj):
101
tax_obj = pooler.get_pool(self.cr.dbname).get('account.invoice')
102
tax_xml = tax_obj.get_impuestos(self.cr, self.uid, invoice_obj.tax_line)
104
for tax_type in tax_xml:
108
if tax.get('impuesto'):
109
res_dir['impuesto'] = tax_type[0].tag + ' ' + tax.get('impuesto')
111
res_dir['impuesto'] = ''
112
if tax.get('importe'):
113
res_dir['importe'] = '$ ' + tax.get('importe')
115
res_dir['importe'] = ''
117
res_dir['tasa'] = tax.get('tasa') + '%'
122
res_dir ={'impuesto':'', 'importe':'', 'tasa':''}
126
## def _get_impuestos(self, invoice_obj):
127
## tax_obj = pooler.get_pool(self.cr.dbname).get('account.invoice')
128
## tax_xml = tax_obj.get_impuestos(self.cr, self.uid, invoice_obj.tax_line)
130
## for tax_type in tax_xml:
131
## for tax in tax_type:
133
## if tax.get('impuesto'):
134
## res_dir['impuesto'] = tax_type[0].tag + ' ' + tax.get('impuesto')
136
## res_dir['impuesto'] = ''
137
## if tax.get('importe'):
138
## res_dir['importe'] = tax.get('importe')
140
## res_dir['importe'] = ''
141
## if tax.get('tasa'):
142
## res_dir['tasa'] = tax.get('tasa') + '%'
144
## res_dir['tasa'] = ''
145
## res.append(res_dir)
149
report_sxw.report_sxw('report.account.invoice.electronic', 'account.invoice', 'addons/bias_electronic_invoice/report/invoice_b.rml', parser=account_invoice, header=False)