Automatically update currency rates

Rational

Currency rates need to be manually set if you want to use different currencies in registers like sale or purchase, it would be nice if we automatically update those rates once per day.

Proposal

We could add a daily cron which would check and get the rates for the currencies.
Those rates would be updated based on company currency.

I’ve researched, and we could use an open source api or we could directly parse a xml given by the European Central Bank (the only problem it’s that we would need to convert the currencies as it only gives the rates for euros)

Implementation

https://bugs.tryton.org/issue8804

This could be done with https://pypi.org/project/forex-python/
Doc: https://forex-python.readthedocs.io/en/latest/usage.html

I think we should have more flexibility on the scheduling.
Some companies will take a rate once every month for example.

I think this should be customizable. Some countries will have requirements about the source of the rate (and which rate to use).

Agree, we should add a selection of currency update sources, having by default the forex-python option.
Indeed if we make the field non mandatory we allow users to deactivate the update of currencies.

What I’m not sure is where to define this option.

Also I think there is the when to make the update and with which rate (like starting day, average of the day etc.). Maybe the which should be included in the selection option.
But we need that the cron task if it miss some rates (cron fail the last time it runs for example), it should complete the missing rate depending of the frequency.

Also I think the cron task should have the base currency defined somewhere.