Replace forex-python and fetch rates directly from EU website

https://theforexapi.com/ is frequently down which breaks the tests. The EU
website is more reliable.
As forex-python is just also used to set the symbol of currencies when
importing, we can just fill the symbol when it is empty with the alpha-3 code.

issue11731
review439631003
(grafted from 2097ae9311186817cd70c172c478d102435ad2bf)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier committed 2022-10-22 01:02:01 +02:00
1 parent f55cf8804e
commit 40f3bdc4da
5 files changed
+179 -17

No files matched your search

+3 -4
View File
@@ -7,7 +7,6 @@ import sys
from argparse import ArgumentParser
import pycountry
from forex_python.converter import CurrencyCodes
try:
from progressbar import ProgressBar, Bar, ETA, SimpleProgress
@@ -53,7 +52,6 @@ def get_currencies():
def update_currencies(currencies):
print("Update currencies", file=sys.stderr)
Currency = Model.get('currency.currency')
codes = CurrencyCodes()
records = []
for currency in _progress(pycountry.currencies):
@@ -61,10 +59,11 @@ def update_currencies(currencies):
if code in currencies:
record = currencies[code]
else:
record = Currency(code=code)
record = Currency(code=code, symbol=None)
record.name = _remove_forbidden_chars(currency.name)
record.numeric_code = currency.numeric
record.symbol = codes.get_symbol(currency.alpha_3) or currency.alpha_3
if not record.symbol:
record.symbol = currency.alpha_3
records.append(record)
Currency.save(records)