Multi Currency API auto sync (crontask)

Hello all,

I have setup the multicurrency several years ago and always updated it manually, I found a post to update them with an API key from https://currencylayer.com/ but I could only press the sync once, then it disappeared.

How can I re-enable this field? I have changed MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION set to 1.

A daily cron task would be amazing, but can’t find that either.

Best,

Mike

1 Like

which dolibarr version?

19.0.1 is the current version I use

I am using the same version. When I press the sync button, the following warning appears in the upper right corner of the screen.

Use of API for currency update is disabled by option MULTICURRENCY_DISABLE_SYNC_CURRENCYLAYER

@alfim

You can still see it, I can’t and it used only once a credit for syncing on the API platform. https://currencylayer.com/

Does your version uses credits or it does not work at all?

Hi Mark,

We fixed the Multicurrency as follows:

  1. Under Home->Setup->Other Setup we added the following as a precautionary measure:
    MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION (set to 1)
    MULTICURRENCY_DISABLE_SYNC_CURRENCYLAYER (set to 0)
  2. directly in the code, in module: multicurrency/class/multicurrency.class.php, we commented out the global variable: MULTICURRENCY_DISABLE_SYNC_CURRENCYLAYER as it seems to break the sync features of the module. As the same variable was defined in the “Other Setup” section of Dolibarr, these feature is still available.

I hope this helps!

Luis

You can find the Cron job in Home-> Admin Tools-> Scheduled Jobs-> MultiCurrencyAutoUpdateCurrencies

If the cron job does not appear, turn off the Multicurrency module and turn it back on, that seems to fix the issue.

Luis

Hey Luis,

Thanks for the detailed information, I checked the Multicurrency field and it was there.

I upgraded a while ago to 20.0.0, and the sync button was there; maybe a fix I didn’t notice in the commits. Credits are being used from the API platform. https://currencylayer.com/ now, every time I hit Sync. The sync did not work yet, and will try your suggestion to comment out the global variable: MULTICURRENCY_DISABLE_SYNC_CURRENCYLAYER

Thanks again!,

Best,

Mike

1 Like

Same here with version 20.0.3
Now clicking in the sync button, a message is displayed explaining the sync with Currencylayer is correclty performed. Also in the dashboard of currency layer we see that the counter of API calls is incremented. If is used an API call using the browser, also works fine.

But the problem is that the new entry in the db of dolibar with the new exchange rate is not created.
Any iedea how to fix it ?

If you set logging to debug mode and look in the dolibarr.log file, what do you then see?

I can not find anything strange.
Please take a look to the attached file.
multicurrency_log.txt (34.8 KB)