Skip to content

Commit

Permalink
[FIX] l10n_be_bpost_address_autocomplete: remove headers from api call
Browse files Browse the repository at this point in the history
Since the required headers are no more supported, this commit removes
them from the api call in order to successfully fetch the results.
  • Loading branch information
Laurent Stukkens committed Oct 16, 2024
1 parent 64fcaf9 commit a09e842
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,9 @@ let BpAddressAutocomplete = class BpAddressAutocomplete extends s$1 {
}
async _sendRequest(input) {
this.count++;
await fetch(`https://webservices-pub.bpost.be/ws/ExternalMailingAddressProofingCSREST_v1/address/autocomplete?id=${this.count}&q=${input.value}`, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
}).then(response => {
await fetch(
`https://webservices-pub.bpost.be/ws/ExternalMailingAddressProofingCSREST_v1/address/autocomplete?id=${this.count}&q=${input.value}`
).then(response => {
if (!response.ok) {
this.suggestions = [];
throw new Error("Network response was not OK");
Expand Down
14 changes: 14 additions & 0 deletions l10n_be_bpost_address_autocomplete/tests/test_res_partner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import requests

from odoo.tests.common import TransactionCase
from odoo.tools.misc import mute_logger


class TestResPartner(TransactionCase):
Expand All @@ -25,3 +28,14 @@ def test_country_is_not_belgium(self):
self.partner_be.is_belgian_address = False
self.partner_be._onchange_is_belgian_address()
self.assertFalse(self.partner_be.country_id == self.env.ref("base.be"))

@mute_logger("py.warnings")
def test_api_call(self):
response = requests.get(
"https://webservices-pub.bpost.be/ws/"
"ExternalMailingAddressProofingCSREST_v1/address/autocomplete?"
"id=1&q=watterloo",
timeout=10,
verify=False,
)
self.assertEqual(response.status_code, 200)

0 comments on commit a09e842

Please sign in to comment.