Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
175 changes: 175 additions & 0 deletions currency_rate_update_BI/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
====================================
Currency Rate Update: Bank Indonesia
====================================

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

.. |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/licence-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%2Fcurrency-lightgray.png?logo=github
:target: https://github.com/OCA/currency/tree/16.0/currency_rate_update_BI
:alt: OCA/currency
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/currency-16-0/currency-16-0-currency_rate_update_BI
: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/currency&target_branch=16.0
:alt: Try me on Runboat

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

Adds **Bank Indonesia (BI)** as a currency rates provider for the
``currency_rate_update`` module. Exchange rates are fetched from
Bank Indonesia's official SOAP webservice (wsKursBI) using the
``getSubKursLokal3`` method.

**Data Source:** Bank Indonesia — https://www.bi.go.id

**Rate Type:** Kurs Transaksi BI (Transaction Rates — middle rate / kurs tengah)

**Update Frequency:** Daily on business days (Mon–Fri, excluding Indonesian national holidays)

**Supported Currencies (vs IDR):**

+-----+----------------------------+
| USD | United States Dollar |
+-----+----------------------------+
| EUR | Euro |
+-----+----------------------------+
| GBP | British Pound |
+-----+----------------------------+
| JPY | Japanese Yen |
+-----+----------------------------+
| SGD | Singapore Dollar |
+-----+----------------------------+
| AUD | Australian Dollar |
+-----+----------------------------+
| BND | Brunei Dollar |
+-----+----------------------------+
| CAD | Canadian Dollar |
+-----+----------------------------+
| CHF | Swiss Franc |
+-----+----------------------------+
| CNY | Chinese Yuan |
+-----+----------------------------+
| DKK | Danish Krone |
+-----+----------------------------+
| HKD | Hong Kong Dollar |
+-----+----------------------------+
| KRW | South Korean Won |
+-----+----------------------------+
| MYR | Malaysian Ringgit |
+-----+----------------------------+
| NOK | Norwegian Krone |
+-----+----------------------------+
| NZD | New Zealand Dollar |
+-----+----------------------------+
| SAR | Saudi Riyal |
+-----+----------------------------+
| SEK | Swedish Krona |
+-----+----------------------------+
| THB | Thai Baht |
+-----+----------------------------+

**Note:** This module is designed primarily for Indonesian companies
using **IDR (Indonesian Rupiah)** as their base currency. Cross-rate
calculations (e.g. USD base company wanting EUR rates) are supported
as long as the base currency is in the list above.

**Table of contents**

.. contents::
:local:

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

To configure Bank Indonesia currency rates provider:

#. Go to *Invoicing > Configuration > Settings*
#. Ensure *Automatic Currency Rates (OCA)* is checked
#. Go to *Invoicing > Configuration > Currency Rates Providers*
#. Create a new provider with *Provider: Bank Indonesia (Kurs Transaksi)*
#. Select the currencies you want to update (USD, EUR, SGD, etc.)
#. Configure the update schedule (e.g., daily, weekly)
#. Save the provider

.. note::
Your company's base currency should be **IDR (Indonesian Rupiah)**
or one of the supported foreign currencies if you need cross-rate
calculations.

Usage
=====

After configuration, currency rates are automatically updated based on
your schedule. To manually update rates:

#. Go to *Invoicing > Configuration > Currency Rates Providers*
#. Select the Bank Indonesia provider
#. Click *Action > Update Rates Wizard*
#. Set the date range (From/To dates)
#. Click *Update* to fetch rates from Bank Indonesia

To view the fetched rates:

#. Go to *Invoicing > Configuration > Currencies*
#. Select a currency (e.g., USD)
#. Open the *Rates* tab to see historical exchange rates

The rates are fetched from Bank Indonesia's official webservice at
https://www.bi.go.id/biwebservice/wskursbi.asmx and represent the
middle rate (average of buy/sell rates) for each currency pair.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/currency/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/currency/issues/new?body=module:%20currency_rate_update_BI%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
~~~~~~~

* PT Solusi Aglis Indonesia

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-hitrosol| image:: https://github.com/hitrosol.png?size=40px
:target: https://github.com/hitrosol
:alt: hitrosol

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

|maintainer-hitrosol|

This module is part of the `OCA/currency <https://github.com/OCA/currency/tree/16.0/currency_rate_update_BI>`_ project on GitHub.

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

from .hooks import post_init_hook
from . import models
17 changes: 17 additions & 0 deletions currency_rate_update_BI/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2026 PT Solusi Aglis Indonesia (http://solusiaglis.co.id)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Currency Rate Update: Bank Indonesia",
"version": "16.0.1.0.0",
"category": "Financial Management/Configuration",
"summary": "Update exchange rates using Bank Indonesia (BI) official rates",
"author": "PT Solusi Aglis Indonesia, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/currency",
"license": "AGPL-3",
"installable": True,
"application": False,
"depends": ["currency_rate_update"],
"post_init_hook": "post_init_hook",
"maintainers": ["hitrosol"],
}
57 changes: 57 additions & 0 deletions currency_rate_update_BI/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2026 PT Solusi Aglis Indonesia (http://solusiaglis.co.id)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

import logging

_logger = logging.getLogger(__name__)


def post_init_hook(cr, registry):
"""Remove stale rate records for all companies' base currencies.

When a company switches its base currency (e.g. from USD to IDR),
historical rate records for the old foreign currency remain in
res_currency_rate. Odoo's company_rate formula divides the stored
rate by the *last* rate found for the company's current base currency:

company_rate = rate / last_base_currency_rate

If last_base_currency_rate != 1.0 the displayed "Unit per IDR" /
"IDR per Unit" columns become wildly incorrect, even though the raw
Technical Rate is correct.

This hook detects and removes any such stale records so the module
works correctly on both fresh and migrated databases.
"""
cr.execute(
"""
SELECT rc.id, rc.name AS currency_name, COUNT(rcr.id) AS rate_count
FROM res_company rco
JOIN res_currency rc ON rc.id = rco.currency_id
LEFT JOIN res_currency_rate rcr ON rcr.currency_id = rc.id
GROUP BY rc.id, rc.name
HAVING COUNT(rcr.id) > 0
"""
)
rows = cr.fetchall()
if not rows:
return

for currency_id, currency_name, rate_count in rows:
_logger.warning(
"currency_rate_update_BI: Found %d stale rate record(s) for base "
"currency '%s'. These cause incorrect company_rate display. "
"Removing them now.",
rate_count,
currency_name,
)
cr.execute(
"DELETE FROM res_currency_rate WHERE currency_id = %s",
(currency_id,),
)
_logger.info(
"currency_rate_update_BI: Removed %d rate record(s) for base "
"currency '%s'.",
rate_count,
currency_name,
)
29 changes: 29 additions & 0 deletions currency_rate_update_BI/i18n/currency_rate_update_BI.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * currency_rate_update_BI
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2026-01-01 00:00+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#. module: currency_rate_update_BI
#: model_terms:res.currency.rate.provider,service:currency_rate_update_BI.service_bi
msgid "Bank Indonesia (Kurs Transaksi)"
msgstr ""

#. module: currency_rate_update_BI
#: code:addons/currency_rate_update_BI/models/res_currency_rate_provider_BI.py:0
msgid "Cannot connect to Bank Indonesia webservice.\nPlease check your internet connection.\nURL: %(url)s\nError: %(error)s"
msgstr ""

#. module: currency_rate_update_BI
#: code:addons/currency_rate_update_BI/models/res_currency_rate_provider_BI.py:0
msgid "Bank Indonesia provider: Company base currency %(currency)s is not supported. BI supports IDR as base or any of: %(list)s"
msgstr ""
31 changes: 31 additions & 0 deletions currency_rate_update_BI/i18n/id.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Indonesian translation of currency_rate_update_BI
# Copyright (C) 2026 PT Solusi Aglis Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2026-01-01 00:00+0700\n"
"Last-Translator: PT Solusi Aglis Indonesia <info@solusiaglis.co.id>\n"
"Language-Team: Indonesian\n"
"Language: id\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"

#. module: currency_rate_update_BI
#: model_terms:res.currency.rate.provider,service:currency_rate_update_BI.service_bi
msgid "Bank Indonesia (Kurs Transaksi)"
msgstr "Bank Indonesia (Kurs Transaksi)"

#. module: currency_rate_update_BI
#: code:addons/currency_rate_update_BI/models/res_currency_rate_provider_BI.py:0
msgid "Cannot connect to Bank Indonesia webservice.\nPlease check your internet connection.\nURL: %(url)s\nError: %(error)s"
msgstr "Tidak dapat terhubung ke webservice Bank Indonesia.\nMohon periksa koneksi internet Anda.\nURL: %(url)s\nError: %(error)s"

#. module: currency_rate_update_BI
#: code:addons/currency_rate_update_BI/models/res_currency_rate_provider_BI.py:0
msgid "Bank Indonesia provider: Company base currency %(currency)s is not supported. BI supports IDR as base or any of: %(list)s"
msgstr "Provider Bank Indonesia: Mata uang dasar perusahaan %(currency)s tidak didukung. BI mendukung IDR sebagai dasar atau salah satu dari: %(list)s"
3 changes: 3 additions & 0 deletions currency_rate_update_BI/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import res_currency_rate_provider_BI
Loading