Skip to content

Commit

Permalink
[FIX] l10n_es_aeat_mod340: Evitar error cuando el NIF no existe y el …
Browse files Browse the repository at this point in the history
…tipo de NIF es != 1
  • Loading branch information
pedrobaeza committed Apr 8, 2015
1 parent afcacd6 commit bedcfd4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions l10n_es_aeat_mod340/wizard/calculate_mod340_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,22 @@ def _calculate_records(self, cr, uid, ids, context=None, recalculate=True):
include = False
for tax_line in invoice.tax_line:
if tax_line.base_code_id and tax_line.base:
if tax_line.base_code_id.mod340 is True:
if tax_line.base_code_id.mod340:
include = True
if include is True:
break
if include:
if invoice.partner_id.vat_type == '1':
if not invoice.partner_id.vat:
raise orm.except_orm(
_('La siguiente empresa no tiene asignado nif:'),
invoice.partner_id.name)
country_code, nif = (re.match(r"([A-Z]{0,2})(.*)",
invoice.partner_id.vat).groups())
if invoice.partner_id.vat:
country_code, nif = (
re.match(r"([A-Z]{0,2})(.*)",
invoice.partner_id.vat).groups())
else:
country_code = False
nif = False
values = {
'mod340_id': mod340.id,
'partner_id': invoice.partner_id.id,
Expand Down Expand Up @@ -155,7 +161,6 @@ def _calculate_records(self, cr, uid, ids, context=None, recalculate=True):
'correspond to AmountUntaxed on Invoice %.2f') %
(invoice.number, check_base,
invoice.amount_untaxed * sign))

if recalculate:
mod340.write({
'state': 'calculated',
Expand Down

0 comments on commit bedcfd4

Please sign in to comment.