Skip to content

Commit

Permalink
[UPD][l10n_it_fatturapa_out] update method to convert currecny to EUR
Browse files Browse the repository at this point in the history
  • Loading branch information
matteoopenf committed May 17, 2022
1 parent 7226648 commit b59ffde
Showing 1 changed file with 5 additions and 55 deletions.
60 changes: 5 additions & 55 deletions l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ def _to_EUR(self, currency, amount, invoice, company=None, today=None):
# Dispatch exchange date to convert euros in strange currency
if today:
exchange_date = today
elif invoice and invoice.rc_purchase_invoice_id.date_invoice:
exchange_date = invoice.rc_purchase_invoice_id.date_invoice
elif invoice and invoice.date_invoice:
exchange_date = invoice.date_invoice
elif invoice and invoice.rc_purchase_invoice_id.date:
exchange_date = invoice.rc_purchase_invoice_id.date
elif invoice and invoice.date:
exchange_date = invoice.date
else:
exchange_date = fields.Date.today()

Expand Down Expand Up @@ -974,54 +974,4 @@ def exportFatturaPA(self):
context_partner = self.env.context.copy()
context_partner.update({'lang': partner.lang})
for invoice_ids in invoices_by_partner[partner]:
fatturapa, number = self.exportInvoiceXML(
company, partner, invoice_ids, context=context_partner)

attach = self.saveAttachment(fatturapa, number)
attachments |= attach

for invoice_id in invoice_ids:
inv = invoice_obj.browse(invoice_id)
inv.write({'fatturapa_attachment_out_id': attach.id})

action = {
'view_type': 'form',
'name': "Export Electronic Invoice",
'res_model': 'fatturapa.attachment.out',
'type': 'ir.actions.act_window',
}
if len(attachments) == 1:
action['view_mode'] = 'form'
action['res_id'] = attachments[0].id
else:
action['view_mode'] = 'tree,form'
action['domain'] = [('id', 'in', attachments.ids)]
return action

def generate_attach_report(self, inv):
binding_model_id = self.with_context(
lang=None).report_print_menu.binding_model_id.id
name = self.report_print_menu.name
report_model = self.env['ir.actions.report'].with_context(
lang=None
).search(
[('binding_model_id', '=', binding_model_id),
('name', '=', name)]
)
attachment, attachment_type = report_model.render_qweb_pdf(inv.ids)
att_id = self.env['ir.attachment'].create({
'name': inv.number,
'type': 'binary',
'datas': base64.encodebytes(attachment),
'datas_fname': '{}.pdf'.format(inv.number),
'res_model': 'account.invoice',
'res_id': inv.id,
'mimetype': 'application/x-pdf'
})
inv.write({
'fatturapa_doc_attachments': [(0, 0, {
'is_pdf_invoice_print': True,
'ir_attachment_id': att_id.id,
'description': _("Attachment generated by "
"electronic invoice export")})]
})
fatt

0 comments on commit b59ffde

Please sign in to comment.