From bcd72ba7d6c32d21468378c64275d13daf1247a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20-=20Le=20Filament?= <30716308+remi-filament@users.noreply.github.com> Date: Mon, 13 Jul 2026 15:50:43 +0200 Subject: [PATCH] [ADD] l10n_fr_einvoicing: support EsaLink PA --- l10n_fr_einvoicing/i18n/fr.po | 10 +++++++++ .../i18n/l10n_fr_einvoicing.pot | 10 +++++++++ l10n_fr_einvoicing/models/res_company.py | 22 +++++++++++++++++++ l10n_fr_einvoicing/views/res_partner.xml | 2 +- 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/l10n_fr_einvoicing/i18n/fr.po b/l10n_fr_einvoicing/i18n/fr.po index 3269849..54b40e3 100644 --- a/l10n_fr_einvoicing/i18n/fr.po +++ b/l10n_fr_einvoicing/i18n/fr.po @@ -1131,6 +1131,16 @@ msgstr "Erreur" msgid "Errors reported by AP" msgstr "Erreurs remontées par la PA" +#. module: l10n_fr_einvoicing +#: model:ir.model.fields.selection,name:l10n_fr_einvoicing.selection__res_company__fr_ctc_accredited_platform__esalink +msgid "EsaLink" +msgstr "" + +#. module: l10n_fr_einvoicing +#: model:ir.model.fields.selection,name:l10n_fr_einvoicing.selection__res_company__fr_ctc_accredited_platform__esalink_test +msgid "EsaLink (test)" +msgstr "" + #. module: l10n_fr_einvoicing #: model:ir.model.fields,field_description:l10n_fr_einvoicing.field_fr_einvoicing_event_detail__event_id #: model:ir.model.fields,field_description:l10n_fr_einvoicing.field_fr_einvoicing_event_detail_manual__event_id diff --git a/l10n_fr_einvoicing/i18n/l10n_fr_einvoicing.pot b/l10n_fr_einvoicing/i18n/l10n_fr_einvoicing.pot index beb907e..9d05346 100644 --- a/l10n_fr_einvoicing/i18n/l10n_fr_einvoicing.pot +++ b/l10n_fr_einvoicing/i18n/l10n_fr_einvoicing.pot @@ -1049,6 +1049,16 @@ msgstr "" msgid "Errors reported by AP" msgstr "" +#. module: l10n_fr_einvoicing +#: model:ir.model.fields.selection,name:l10n_fr_einvoicing.selection__res_company__fr_ctc_accredited_platform__esalink +msgid "EsaLink" +msgstr "" + +#. module: l10n_fr_einvoicing +#: model:ir.model.fields.selection,name:l10n_fr_einvoicing.selection__res_company__fr_ctc_accredited_platform__esalink_test +msgid "EsaLink (test)" +msgstr "" + #. module: l10n_fr_einvoicing #: model:ir.model.fields,field_description:l10n_fr_einvoicing.field_fr_einvoicing_event_detail__event_id #: model:ir.model.fields,field_description:l10n_fr_einvoicing.field_fr_einvoicing_event_detail_manual__event_id diff --git a/l10n_fr_einvoicing/models/res_company.py b/l10n_fr_einvoicing/models/res_company.py index a83c759..8377eb4 100644 --- a/l10n_fr_einvoicing/models/res_company.py +++ b/l10n_fr_einvoicing/models/res_company.py @@ -33,6 +33,8 @@ class ResCompany(models.Model): fr_ctc_accredited_platform = fields.Selection( [ ("superpdp", "SUPER PDP"), + ("esalink_test", "EsaLink (test)"), + ("esalink", "EsaLink"), ], default="superpdp", string="Accredited Platform", @@ -145,6 +147,11 @@ def default_get(self, fields_list): client_id = tools.config.get(client_id_key) if client_id: res["fr_ctc_auth_method"] = "authorization_code" + else: + api_key = f"fr_ctc_{platform}_api_key" + api = tools.config.get(api_key) + if api: + res["fr_ctc_auth_method"] = "client_credentials" return res def _fr_ctc_credentials(self): @@ -275,6 +282,20 @@ def _fr_ctc_write_token(self, new_token): def _fr_ctc_get_session(self): self.ensure_one() client_id, client_secret = self._fr_ctc_credentials() + platform = self.fr_ctc_accredited_platform + extra_headers = {} + if platform in ["esalink_test", "esalink"]: + api_config_key = f"fr_ctc_{platform}_api_key" + api_key = tools.config.get(api_config_key) + if api_key: + extra_headers = {"hubtimize-api-key": api_key} + else: + raise UserError( + self.env._( + f"Missing key '{api_config_key}' in the Odoo server " + f"configuration file.", + ) + ) company_ident4log = f"{self.display_name} ID {self.id}" return get_session( self.fr_ctc_accredited_platform, @@ -284,6 +305,7 @@ def _fr_ctc_get_session(self): self._fr_ctc_write_token, client_id, client_secret=client_secret, + extra_headers=extra_headers, ) def fr_ctc_run_import_log_action(self, origin): diff --git a/l10n_fr_einvoicing/views/res_partner.xml b/l10n_fr_einvoicing/views/res_partner.xml index 9e6bcbd..42356fa 100644 --- a/l10n_fr_einvoicing/views/res_partner.xml +++ b/l10n_fr_einvoicing/views/res_partner.xml @@ -50,7 +50,7 @@ >