From ef5d43a4d2e76e26aed6e8fd921eb9ecf58d36e6 Mon Sep 17 00:00:00 2001 From: baa Date: Mon, 30 Jan 2023 11:16:07 +0000 Subject: [PATCH] [FIX] l10n_eg_edi_eta: fix the url within the qr code on the egyptian invoice The URL computed by Odoo was not mathing the URL computed by the ETA system. The previous endpoint used was https://api.invoicing.eta.gov.eg instead of https://invoicing.eta.gov.eg. Also the url contained '/search/' which should not be there. Correct format should be https://invoicing.eta.gov.eg/documents/id/share/long_id closes odoo/odoo#113937 X-original-commit: 70f6199401cfde0cdb7864910f9e8e14117981b6 Signed-off-by: Josse Colpaert --- addons/l10n_eg_edi_eta/models/account_edi_format.py | 6 ++++++ addons/l10n_eg_edi_eta/models/account_move.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/l10n_eg_edi_eta/models/account_edi_format.py b/addons/l10n_eg_edi_eta/models/account_edi_format.py index beb8ed3835e..d3b95722967 100644 --- a/addons/l10n_eg_edi_eta/models/account_edi_format.py +++ b/addons/l10n_eg_edi_eta/models/account_edi_format.py @@ -18,6 +18,8 @@ _logger = logging.getLogger(__name__) ETA_DOMAINS = { 'preproduction': 'https://api.preprod.invoicing.eta.gov.eg', 'production': 'https://api.invoicing.eta.gov.eg', + 'invoice.preproduction': 'https://preprod.invoicing.eta.gov.eg/', + 'invoice.production': 'https://invoicing.eta.gov.eg', 'token.preproduction': 'https://id.preprod.eta.gov.eg', 'token.production': 'https://id.eta.gov.eg', } @@ -41,6 +43,10 @@ class L10nEgHTTPAdapter(requests.adapters.HTTPAdapter): class AccountEdiFormat(models.Model): _inherit = 'account.edi.format' + @api.model + def _l10n_eg_get_eta_qr_domain(self, production_enviroment=False): + return production_enviroment and ETA_DOMAINS['invoice.production'] or ETA_DOMAINS['invoice.preproduction'] + @api.model def _l10n_eg_get_eta_api_domain(self, production_enviroment=False): return production_enviroment and ETA_DOMAINS['production'] or ETA_DOMAINS['preproduction'] diff --git a/addons/l10n_eg_edi_eta/models/account_move.py b/addons/l10n_eg_edi_eta/models/account_move.py index 8ca1f05bff7..c34c758ff9e 100644 --- a/addons/l10n_eg_edi_eta/models/account_move.py +++ b/addons/l10n_eg_edi_eta/models/account_move.py @@ -43,8 +43,8 @@ class AccountMove(models.Model): for move in self: if move.invoice_date and move.l10n_eg_uuid and move.l10n_eg_long_id: is_prod = move.company_id.l10n_eg_production_env - base_url = self.env['account.edi.format']._l10n_eg_get_eta_api_domain(production_enviroment=is_prod) - qr_code_str = '%s/documents/search/%s/share/%s' % (base_url, move.l10n_eg_uuid, move.l10n_eg_long_id) + base_url = self.env['account.edi.format']._l10n_eg_get_eta_qr_domain(production_enviroment=is_prod) + qr_code_str = '%s/documents/%s/share/%s' % (base_url, move.l10n_eg_uuid, move.l10n_eg_long_id) move.l10n_eg_qr_code = qr_code_str else: move.l10n_eg_qr_code = ''