Skip to content

Commit

Permalink
[FIX] l10n_it_fatturapa_out payment terms must have XML codes defined
Browse files Browse the repository at this point in the history
Co-authored-by: Vincenzo Di Roberto <[email protected]>
  • Loading branch information
TheMule71 and vincenzodiroberto committed Feb 24, 2021
1 parent 1996a02 commit 51dfb77
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 20 additions & 1 deletion l10n_it_fatturapa_out/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,26 @@ class AccountInvoice(models.Model):
)

def preventive_checks(self):
# hook for preventive checks. Override and raise exception, in case
for invoice in self:
if invoice.invoice_payment_term_id.fatturapa_pt_id.code is False:
raise UserError(
_(
"Invoice %s fiscal payment term must be"
" set for the selected payment term %s",
invoice.name,
invoice.invoice_payment_term_id.name,
)
)

if invoice.invoice_payment_term_id.fatturapa_pm_id.code is False:
raise UserError(
_(
"Invoice %s fiscal payment method must be"
" set for the selected payment term %s",
invoice.name,
invoice.invoice_payment_term_id.name,
)
)
return

def action_invoice_cancel(self):
Expand Down
3 changes: 3 additions & 0 deletions l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def getNewId():
.browse(invoice_ids)
)

invoice_ids.preventive_checks()

# generate attachments (PDF version of invoice)
for inv in invoice_ids:
if not inv.fatturapa_doc_attachments and self.report_print_menu:
self.generate_attach_report(inv)
Expand Down

0 comments on commit 51dfb77

Please sign in to comment.