Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] l10n_be_bpost_address_autocomplete: remove headers from api call #227

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
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
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)
Loading