[ADD] currency_rate_update_BI: Add Bank Indonesia currency rate provider#215
[ADD] currency_rate_update_BI: Add Bank Indonesia currency rate provider#215hitrosol wants to merge 2 commits into
Conversation
6bc5064 to
6e2eba2
Compare
Add new currency rate provider for Bank Indonesia (BI) Kurs Transaksi. This provider fetches official exchange rates from BI's webservice for 19 major currencies against IDR. Features: - Support for BI Kurs Transaksi webservice (getSubKursLokal3) - Handles 19 currencies published by Bank Indonesia - Calculates cross-rates for non-IDR base currencies - Proper XML parsing of BI's SOAP DataSet response Technical details: - Fetches buy/sell rates and computes middle rate - Handles nominal units (e.g., 100 for JPY) - Supports both IDR and foreign base currencies - Implements proper error handling and logging
6e2eba2 to
de89bf3
Compare
|
LGTM |
|
As this is something specific of Indonesia, it should go into l10n-indonesia, not here. |
When company base currency is USD (or any foreign currency supported by BI), users can now select and get IDR exchange rates.
|
@nurinayati There is improvement or fix to use this module to download the ex. rate for non IDR base currency. I will move this to l10n-Indonesia after this Dear @pedrobaeza, the l10n-indonesia repository has not been active for several years. Our company is planning to develop several additional modules in that repository. Would it be possible to assign me as a maintainer of that repository? Thanks |
|
Please do the request at https://github.com/OCA/repo-maintainer-conf, and I think it can be possible if no other maintainers. |
marcos-mendez
left a comment
There was a problem hiding this comment.
Automated Review -- Tests Failed
1. Root Cause
The test failure is due to a database connection error (Connection to the database failed) during the Odoo server startup. This indicates that the test environment is misconfigured or the database is unreachable, not a problem in the module code itself.
2. Suggested Fix
No code fix is needed for the test failure — this is an infrastructure or test environment issue. However, to prevent such failures in the future:
- Ensure the test database is correctly initialized and accessible.
- Verify that the
runboatconfiguration in the PR's CI setup properly sets up the database connection.
3. Additional Code Issues
-
Missing
__all__in__init__.py: Thecurrency_rate_update_BI/__init__.pyfile does not define__all__, which is a best practice for explicit imports.- File:
currency_rate_update_BI/__init__.py - Suggestion: Add
__all__ = ['post_init_hook', 'models']for clarity and consistency.
- File:
-
Insecure use of
urlopenin_fetch_bi_rates: The code usesurlopenwithout SSL context validation, which may be insecure.- File:
currency_rate_update_BI/models/res_currency_rate_provider_BI.py - Suggestion: Add
contextlib.closingor useurllib.request.urlopenwith a proper SSL context for production use (though this is a low-priority improvement for now).
- File:
-
Potential
KeyErrorin_convert_foreign_base_rates: Ifbase_currencyis not present inratesfor a given date, the loop continues, but this may silently skip valid entries.- File:
currency_rate_update_BI/models/res_currency_rate_provider_BI.py - Lines: 220–229
- Suggestion: Log a warning or raise an error if base currency is missing, to ensure data integrity.
- File:
4. Test Improvements
To better test this module, add the following test cases using OCA patterns:
Test Cases:
-
Test
post_init_hook:- Type:
SavepointCase - Purpose: Ensure stale
res_currency_raterecords are removed correctly. - Coverage:
- Create a company with a base currency.
- Insert stale rate records.
- Run
post_init_hook. - Assert stale records are deleted.
- Type:
-
Test
_get_supported_currencies:- Type:
TransactionCase - Purpose: Validate that supported currencies are returned correctly.
- Coverage:
- Set base currency to IDR.
- Assert
BI_SUPPORTED_CURRENCIESare returned. - Set base currency to USD.
- Assert
["USD", "IDR"]are returned.
- Type:
-
Test
_fetch_bi_rateswith mocked HTTP response:- Type:
TransactionCase - Purpose: Ensure proper handling of network errors and XML parsing.
- Coverage:
- Mock
urlopento simulate connection failure. - Assert
UserErroris raised. - Mock valid XML response.
- Assert rates are parsed correctly.
- Mock
- Type:
-
Test
_convert_bi_rates_to_odoo:- Type:
TransactionCase - Purpose: Validate conversion logic for both IDR and foreign base currencies.
- Coverage:
- Test
IDRbase case. - Test foreign base case (e.g., USD).
- Test unsupported base currency →
UserError.
- Test
- Type:
OCA Testing Patterns:
- Use
@tagged('post_install', 'standard')for tests that require installation hooks. - Use
TransactionCasefor tests that involve data creation and modification. - Use
SavepointCasefor tests that require rollback of database changes (e.g.,post_init_hook).
These tests will ensure the module behaves correctly under various conditions and edge cases.
⏰ This PR has been open for 32 days.
Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)
Reciprocal Review Request
Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):
My open PRs across OCA:
- server-tools#3548 [18.0][MIG] base_kanban_stage: Migration to 18.0
- hr-attendance#262 [16.0][ADD] Hr_attendance_idsecure: iDSecure (ControliD) attendance integration
- stock-logistics-workflow#2276 [16.0][ADD] stock_move_line_devaluation
- stock-logistics-workflow#2275 [16.0][ADD] Stock move line analytic account
- stock-logistics-workflow#2268 [16.0][ADD] stock_move_line_picking_partner
- purchase-workflow#2694 [16.0][IMP]Purchase workflow added to review state & exception fix
Reviewing each other's work helps the whole community move forward. Thank you!
Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b
Not sure if I should propose this to repo currency or l10n-indonesia.
Add new currency rate provider for Bank Indonesia (BI) Kurs Transaksi. This provider fetches official exchange rates from BI's webservice for 19 major currencies against IDR.
Features:
Technical details: