Skip to content

Commit

Permalink
[ADD][l10n_it_fatturapa_out] add method to convert euro to currency
Browse files Browse the repository at this point in the history
  • Loading branch information
matteoopenf committed Feb 23, 2022
1 parent dbb00ab commit d0341c7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ def _domain_ir_values(self):
return [('binding_model_id', '=', model_name),
('type', '=', 'ir.actions.report')]

@api.model
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

Check warning on line 109 in l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py#L104-L109

Added lines #L104 - L109 were not covered by tests
else:
exchange_date = fields.Date.today()

Check warning on line 111 in l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py#L111

Added line #L111 was not covered by tests

company = company or self.env.user.company_id
euro = self.env.ref('base.EUR')
if currency == euro:
return amount
return currency.with_context(date=exchange_date).compute(amount, euro)

Check warning on line 117 in l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py#L113-L117

Added lines #L113 - L117 were not covered by tests

report_print_menu = fields.Many2one(
comodel_name='ir.actions.actions',
domain=_domain_ir_values,
Expand Down

0 comments on commit d0341c7

Please sign in to comment.