Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
08f1c73
[12.0][NEW] módulo para atualizar cotações de moedas (#683)
renatonlima May 13, 2019
675aa42
[UPD] README.rst
OCA-git-bot May 13, 2019
42de630
[FIX] Tests, there was changes on currency_rate_update module.
mbcosta Jun 17, 2019
cfb97ba
[UPD] README.rst
OCA-git-bot Jul 29, 2019
c1e0406
[UPD] Update l10n_br_currency_rate_update.pot
oca-travis Sep 16, 2019
3771f7c
[REF] Running pre-commit on l10n_br_currency_rate_update
luismalta Oct 18, 2019
0e0b328
[UPD] Update l10n_br_currency_rate_update.pot
oca-travis Oct 24, 2019
0f710cf
Added translation using Weblate (Portuguese (Brazil))
marcelsavegnago Dec 17, 2020
1ed627d
Translated using Weblate (Portuguese (Brazil))
marcelsavegnago Dec 17, 2020
adacc48
faster CI: 14239 queries down to 2663
rvalyi Mar 10, 2021
fe63d3f
B902 Invalid 1st arg 'self' used for class method
rvalyi Jun 9, 2021
82a40dc
[IMP] l10n_br_currency_rate_update: black, isort, prettier
rvalyi Jun 9, 2021
f3829df
[UPD] Update l10n_br_currency_rate_update.pot
oca-travis Jun 10, 2021
6d7abf8
[FIX] converts the value returned by the BCB.
marcelsavegnago Jun 24, 2021
a9387f0
l10n_br_currency_rate_update 12.0.2.0.0
OCA-git-bot Aug 6, 2021
60b1090
[MIG] l10n_br_currency_rate_update: Migration to 13.0
renatonlima Nov 4, 2021
3e3ede5
[UPD] Update l10n_br_currency_rate_update.pot
oca-travis Nov 11, 2021
055981f
[UPD] README.rst
OCA-git-bot Nov 11, 2021
2637ffe
[MIG] l10n_br_currency_rate_update: Migration to 14.0
renatonlima Dec 23, 2021
d322f6d
[MIGR] Added ondelete policy in selection field
renatonlima Dec 23, 2021
86f4715
[UPD] Update l10n_br_currency_rate_update.pot
oca-travis Dec 24, 2021
5edc8fc
[UPD] README.rst
OCA-git-bot Dec 24, 2021
7f2c37c
[REF] to Beta to please manifestoo checks
rvalyi Sep 16, 2022
e37156d
[UPD] README.rst
OCA-git-bot Sep 16, 2022
b71cb7d
[MIG] l10n_br_currency_rate_update: Migration to 15.0
renatonlima Feb 24, 2023
093569e
[UPD] Update l10n_br_currency_rate_update.pot
Feb 26, 2023
f83a87f
[UPD] README.rst
OCA-git-bot Feb 26, 2023
50c8f20
[MIG] l10n_br_currency_rate_update: Migration to 16.0
renatonlima Feb 27, 2023
6f03b0c
[REF] added timeout for external request
renatonlima Feb 27, 2023
cf83823
[UPD] Update l10n_br_currency_rate_update.pot
Feb 27, 2023
9b15499
[UPD] README.rst
OCA-git-bot Feb 27, 2023
68194e1
Update translation files
weblate Feb 28, 2023
b91a170
[UPD] Update l10n_br_currency_rate_update.pot
Jun 26, 2023
627d2d8
Update translation files
weblate Jun 26, 2023
a4409dd
Translated using Weblate (Portuguese (Brazil))
adrianojprado Jul 1, 2023
7a7b8a0
Added translation using Weblate (Spanish)
Ivorra78 Aug 6, 2023
035b60b
Translated using Weblate (Spanish)
Ivorra78 Aug 6, 2023
d5c17dd
[CI] only run BCB tests certain days
rvalyi May 31, 2023
abd6200
[CI] added mocked currency test for coverage
rvalyi May 31, 2023
2a4bdec
[CI][REF] only run BCB tests certain days
rvalyi Jun 6, 2023
c71b534
[FIX] l10n_br_currency_rate_update: Solve Warning Deprecated class Sa…
mbcosta Aug 16, 2023
61d1261
l10n_br_currency_rate_update 16.0.1.1.0
OCA-git-bot Aug 16, 2023
5442ed2
[UPD] README.rst
OCA-git-bot Sep 3, 2023
32dba81
copier update repository
antoniospneto Sep 4, 2024
7997363
[BOT] post-merge updates
OCA-git-bot Sep 5, 2024
14e994b
[REF] l10n_br_currency_rate_update: use Command API
rvalyi Jun 27, 2025
66d711f
[BOT] post-merge updates
OCA-git-bot Jun 28, 2025
d9357f7
[MIG] l10n_br_currency_rate_update: Migration to 17.0
renatonlima Sep 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions l10n_br_currency_rate_update/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=======================
Currency Rate Update BR
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:92c8ab327599792d04fd2444829f3825dd9721b572c616a7bf00a733dbe5e70e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-brazil/tree/16.0/l10n_br_currency_rate_update
:alt: OCA/l10n-brazil
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-brazil-16-0/l10n-brazil-16-0-l10n_br_currency_rate_update
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Este módulo implementa a consulta de cotação de moedas consultando o
Banco Central do Brasil. Ele estende o currency_rate_update do
repositório OCA/currency e adiciona o provedor BCB:

- **Banco Central do Brasil** (portado por Renato Lima - Akretion):
Implementa a consulta diária da cotação do moedas disponibilizada
via API pelo banco central, para saber mais acesse o
https://dadosabertos.bcb.gov.br/dataset/taxas-de-cambio-todos-os-boletins-diarios

**Table of contents**

.. contents::
:local:

Configuration
=============

Para ativar o agendador para atualizar as cotações de moedas:

# Vá em *Faturamento > Configuração > Configurações* # Verifique se a
opção *Automatic Currency Rates (OCA)* esta selecionada

Para configurar os provedores de cotações de moedas:

# Vá em *Faturamento > Configuração > Currency Rates Providers* # Crie e
configure o provedor BCB (Banco Central do Brasil) # Selecione as moedas
que deseja atualizar as cotações

Usage
=====

To update historical currency rates:

# Go to *Invoicing > Configuration > Currency Rates Providers* # Select
specific providers # Launch *Actions > Update Rates Wizard* # Configure
date interval and click *Update*

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-brazil/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-brazil/issues/new?body=module:%20l10n_br_currency_rate_update%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Akretion

Contributors
------------

- Renato Lima <[email protected]>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-renatonlima| image:: https://github.com/renatonlima.png?size=40px
:target: https://github.com/renatonlima
:alt: renatonlima

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-renatonlima|

This module is part of the `OCA/l10n-brazil <https://github.com/OCA/l10n-brazil/tree/16.0/l10n_br_currency_rate_update>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions l10n_br_currency_rate_update/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import models
16 changes: 16 additions & 0 deletions l10n_br_currency_rate_update/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2019 Renato Lima - Akretion <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Currency Rate Update BR",
"summary": "Update exchange rates using OCA modules for Brazil",
"version": "17.0.1.0.0",
"author": "Akretion, " "Odoo Community Association (OCA)",
"maintainers": ["renatonlima"],
"website": "https://github.com/OCA/l10n-brazil",
"license": "AGPL-3",
"category": "Financial Management/Configuration",
"depends": ["currency_rate_update"],
"development_status": "Beta",
"installable": True,
}
43 changes: 43 additions & 0 deletions l10n_br_currency_rate_update/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_br_currency_rate_update
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-08-06 15:10+0000\n"
"Last-Translator: Ivorra78 <[email protected]>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: l10n_br_currency_rate_update
#: model:ir.model.fields.selection,name:l10n_br_currency_rate_update.selection__res_currency_rate_provider__service__bcb
msgid "Brazilian Central Bank"
msgstr "Banco Central Brasileño"

#. module: l10n_br_currency_rate_update
#. odoo-python
#: code:addons/l10n_br_currency_rate_update/models/res_currency_rate_provider_bcb.py:0
#, python-format
msgid ""
"Brazilian Central Bank is suitable only for companies with BRL as base "
"currency!"
msgstr ""
"¡El Banco Central de Brasil sólo es adecuado para empresas con el BRL como "
"divisa base!"

#. module: l10n_br_currency_rate_update
#: model:ir.model,name:l10n_br_currency_rate_update.model_res_currency_rate_provider
msgid "Currency Rates Provider"
msgstr "Proveedor de tipos de cambio"

#. module: l10n_br_currency_rate_update
#: model:ir.model.fields,field_description:l10n_br_currency_rate_update.field_res_currency_rate_provider__service
msgid "Provider"
msgstr "Proveedor"
38 changes: 38 additions & 0 deletions l10n_br_currency_rate_update/i18n/l10n_br_currency_rate_update.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_br_currency_rate_update
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: l10n_br_currency_rate_update
#: model:ir.model.fields.selection,name:l10n_br_currency_rate_update.selection__res_currency_rate_provider__service__bcb
msgid "Brazilian Central Bank"
msgstr ""

#. module: l10n_br_currency_rate_update
#. odoo-python
#: code:addons/l10n_br_currency_rate_update/models/res_currency_rate_provider_bcb.py:0
#, python-format
msgid ""
"Brazilian Central Bank is suitable only for companies with BRL as base "
"currency!"
msgstr ""

#. module: l10n_br_currency_rate_update
#: model:ir.model,name:l10n_br_currency_rate_update.model_res_currency_rate_provider
msgid "Currency Rates Provider"
msgstr ""

#. module: l10n_br_currency_rate_update
#: model:ir.model.fields,field_description:l10n_br_currency_rate_update.field_res_currency_rate_provider__service
msgid "Provider"
msgstr ""
49 changes: 49 additions & 0 deletions l10n_br_currency_rate_update/i18n/pt_BR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_br_currency_rate_update
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-07-01 22:12+0000\n"
"Last-Translator: Adriano Prado <[email protected]>\n"
"Language-Team: none\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: l10n_br_currency_rate_update
#: model:ir.model.fields.selection,name:l10n_br_currency_rate_update.selection__res_currency_rate_provider__service__bcb
msgid "Brazilian Central Bank"
msgstr "Banco Central do Brasil"

#. module: l10n_br_currency_rate_update
#. odoo-python
#: code:addons/l10n_br_currency_rate_update/models/res_currency_rate_provider_bcb.py:0
#, python-format
msgid ""
"Brazilian Central Bank is suitable only for companies with BRL as base "
"currency!"
msgstr ""
"O Banco Central do Brasil é adequado apenas para empresas com BRL como moeda "
"base!"

#. module: l10n_br_currency_rate_update
#: model:ir.model,name:l10n_br_currency_rate_update.model_res_currency_rate_provider
msgid "Currency Rates Provider"
msgstr "Provedor de Taxas de Moeda"

#. module: l10n_br_currency_rate_update
#: model:ir.model.fields,field_description:l10n_br_currency_rate_update.field_res_currency_rate_provider__service
msgid "Provider"
msgstr "Provider"

#~ msgid "Source Service"
#~ msgstr "Origem do Serviço"

#~ msgid "European Central Bank"
#~ msgstr "Banco Central Europeu"
3 changes: 3 additions & 0 deletions l10n_br_currency_rate_update/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import res_currency_rate_provider_bcb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Copyright 2019 Akretion - Renato Lima <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

import requests

from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT


class ResCurrencyRateProviderBCB(models.Model):
_inherit = "res.currency.rate.provider"

service = fields.Selection(
selection_add=[("BCB", "Brazilian Central Bank")],
ondelete={"BCB": "set default"},
)

@api.model
def _get_supported_currencies(self):
self.ensure_one()
if self.service == "BCB":
# List of currencies obrained from:
# https://olinda.bcb.gov.br/olinda/servico/PTAX/versao
# /v1/odata/Moedas?$top=100&$format=json&$select=simbolo
return [
"AUD",
"CAD",
"CHF",
"DKK",
"EUR",
"GBP",
"JPY",
"NOK",
"SEK",
"USD",
]

return super()._get_supported_currencies()

@api.model
def _obtain_rates(self, base_currency, currencies, date_from, date_to):
self.ensure_one()
if self.service == "BCB":
if base_currency != "BRL":
raise UserError(
_(
"Brazilian Central Bank is suitable only for companies"
" with BRL as base currency!"
)
)

url = (
"https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/"
"v1/odata/CotacaoMoedaPeriodo(moeda=@moeda,dataInicial"
"=@dataInicial,dataFinalCotacao=@dataFinalCotacao)?"
"format=json&skip=0&top=10000&$filter=tipoBoletim%20eq"
"%20%27Fechamento%27%20or%20tipoBoletim%20eq%20%27Abert"
"ura%27&select=paridadeCompra%2CparidadeVen"
"da%2CcotacaoCompra%2CcotacaoVenda%2CdataHoraCotacao%2"
"CtipoBoletim"
)

params = dict()
params["@dataInicial"] = date_from.strftime("'%m-%d-%Y'")
params["@dataFinalCotacao"] = date_to.strftime("'%m-%d-%Y'")

data = {}
for cur in currencies:
params["@moeda"] = "'" + cur + "'"
response = requests.get(url, params=params, timeout=10)
if response.ok:
content = response.json()

for rate in content.get("value"):
rate_date = fields.Date.from_string(
rate.get("dataHoraCotacao")
).strftime(DEFAULT_SERVER_DATE_FORMAT)

if data.get(rate_date):
data[rate_date][cur] = 1 / rate.get("cotacaoVenda")
else:
rate_dict = {cur: 1 / rate.get("cotacaoVenda")}
data[rate_date] = rate_dict

return data

return super()._obtain_rates(base_currency, currencies, date_from, date_to)
3 changes: 3 additions & 0 deletions l10n_br_currency_rate_update/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
10 changes: 10 additions & 0 deletions l10n_br_currency_rate_update/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Para ativar o agendador para atualizar as cotações de moedas:

\# Vá em *Faturamento \> Configuração \> Configurações* \# Verifique se
a opção *Automatic Currency Rates (OCA)* esta selecionada

Para configurar os provedores de cotações de moedas:

\# Vá em *Faturamento \> Configuração \> Currency Rates Providers* \#
Crie e configure o provedor BCB (Banco Central do Brasil) \# Selecione
as moedas que deseja atualizar as cotações
1 change: 1 addition & 0 deletions l10n_br_currency_rate_update/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Renato Lima \<<[email protected]>\>
8 changes: 8 additions & 0 deletions l10n_br_currency_rate_update/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Este módulo implementa a consulta de cotação de moedas consultando o
Banco Central do Brasil. Ele estende o currency_rate_update do
repositório OCA/currency e adiciona o provedor BCB:

> - **Banco Central do Brasil** (portado por Renato Lima - Akretion):
> Implementa a consulta diária da cotação do moedas disponibilizada
> via API pelo banco central, para saber mais acesse o
> <https://dadosabertos.bcb.gov.br/dataset/taxas-de-cambio-todos-os-boletins-diarios>
5 changes: 5 additions & 0 deletions l10n_br_currency_rate_update/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To update historical currency rates:

\# Go to *Invoicing \> Configuration \> Currency Rates Providers* \#
Select specific providers \# Launch *Actions \> Update Rates Wizard* \#
Configure date interval and click *Update*
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading