From 35c34415a1c99a13704f795f57f13c7ffe2d0949 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 24 Apr 2024 12:12:28 +0200 Subject: [PATCH] [FIX] tools: zeep, oversight in c111d5cd17a00644a99828848c81ecb6c5b06d22 `l10n_es_edi_sii` requires `Client.bind` as well as `_binding_options` in the service returned by this `bind` call. ```py serv = client.bind('siiService', service_name) if company.l10n_es_edi_test_env and connection_vals.get('test_url'): serv._binding_options['address'] = connection_vals['test_url'] ``` Can be tested with a external l1On unit test, tested only in nightly builds, not by regular runbot builds / mergebot. `--test-tags=external_l10n:TestEdiWebServices` opw-3888257 opw-3888559 opw-3888155 opw-3890269 opw-3889683 closes odoo/odoo#163123 Signed-off-by: Denis Ledoux (dle) --- odoo/tools/zeep/client.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/odoo/tools/zeep/client.py b/odoo/tools/zeep/client.py index 900029e0e62..b28ef32a441 100644 --- a/odoo/tools/zeep/client.py +++ b/odoo/tools/zeep/client.py @@ -80,6 +80,15 @@ class Client: for key, operation in service._operations.items() }) + def bind(self, service_name, port_name): + service = self.__obj.bind(service_name, port_name) + operations = { + key: self.__serialize_object_wrapper(operation) + for key, operation in service._operations.items() + } + operations['_binding_options'] = service._binding_options + return ReadOnlyMethodNamespace(**operations) + class ReadOnlyMethodNamespace(SimpleNamespace): """A read-only attribute-based namespace not prefixed by `_` and restricted to functions. @@ -88,7 +97,12 @@ class ReadOnlyMethodNamespace(SimpleNamespace): no need to implement them to ensure the read-only property of this class. """ def __init__(self, **kwargs): - assert all(not key.startswith('_') and isinstance(value, FunctionType) for key, value in kwargs.items()) + assert all( + (not key.startswith('_') and isinstance(value, FunctionType)) + or + (key == '_binding_options' and isinstance(value, dict)) + for key, value in kwargs.items() + ) super().__init__(**kwargs) def __getitem__(self, key):