Skip to content

Commit a878f75

Browse files
committed
Merge PR OCA#809 into 14.0
Signed-off-by etobella
2 parents 9ab6a90 + f01bde0 commit a878f75

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

edi_webservice_oca/models/edi_backend.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class EdiBackend(models.Model):
8-
98
_inherit = "edi.backend"
109

1110
webservice_backend_id = fields.Many2one("webservice.backend")
@@ -22,7 +21,7 @@ def _component_match_attrs(self, exchange_record, key):
2221
res = super()._component_match_attrs(exchange_record, key)
2322
if not self.webservice_backend_id or key not in self._webservice_actions:
2423
return res
25-
res["webservice_protocol"] = self.webservice_backend_id.protocol
24+
res["webservice_protocol"] = self.webservice_backend_id.sudo().protocol
2625
return res
2726

2827
def _component_sort_key(self, component_class):

edi_webservice_oca/tests/test_send.py

+25-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ def _setup_records(cls):
4040
endpoint: push/here
4141
"""
4242
cls.record.type_id.set_settings(cls.settings1)
43+
cls.a_user = (
44+
cls.env["res.users"]
45+
.with_context(no_reset_password=True)
46+
.create(
47+
{
48+
"name": "foo",
49+
"login": "a_user",
50+
"email": "foo@bar.com",
51+
"groups_id": [
52+
(
53+
6,
54+
0,
55+
(cls.env.ref("base.group_user")).ids,
56+
)
57+
],
58+
}
59+
)
60+
)
4361

4462
def test_find_component(self):
4563
component = self.backend._get_component(self.record, "send")
@@ -79,9 +97,15 @@ def test_component_params(self):
7997
@responses.activate
8098
def test_component_send(self):
8199
self.record.type_id.set_settings(self.settings2)
100+
# Internal user should be able to call the third party webservice
101+
# without read access (no ir.access.model records)
102+
# on `webservice.backend` model which store credentials
103+
record = self.record.with_user(self.a_user)
104+
backend = self.backend.with_user(self.a_user)
105+
82106
url = "https://foo.test/push/here"
83107
responses.add(responses.POST, url, body="{}")
84-
component = self.backend._get_component(self.record, "send")
108+
component = backend._get_component(record, "send")
85109
result = component.send()
86110
self.assertEqual(result, b"{}")
87111
self.assertEqual(

0 commit comments

Comments
 (0)