From 2724ef31dd2154669a81b921fafc754bb2db596d Mon Sep 17 00:00:00 2001 From: miguelpadin Date: Wed, 4 Dec 2024 12:15:48 +0000 Subject: [PATCH 1/3] [FIX] pms-l10n_es: rename field communication_id -> batch_id, extract from ses processing communication communication_id, not re set communication result, etc. --- pms_l10n_es/__manifest__.py | 2 +- .../migrations/14.0.3.0.0/post-migration.py | 20 ++++++++++++ .../migrations/14.0.3.0.0/pre-migration.py | 14 ++++++++ pms_l10n_es/models/pms_ses_communication.py | 6 +++- pms_l10n_es/static/description/index.html | 11 +++---- .../views/pms_ses_communication_views.xml | 3 ++ pms_l10n_es/wizards/traveller_report.py | 32 ++++++++++--------- 7 files changed, 64 insertions(+), 24 deletions(-) create mode 100644 pms_l10n_es/migrations/14.0.3.0.0/post-migration.py create mode 100644 pms_l10n_es/migrations/14.0.3.0.0/pre-migration.py diff --git a/pms_l10n_es/__manifest__.py b/pms_l10n_es/__manifest__.py index b09a69e2b9..770208b8d9 100644 --- a/pms_l10n_es/__manifest__.py +++ b/pms_l10n_es/__manifest__.py @@ -3,7 +3,7 @@ { "name": "PMS Spanish Adaptation", - "version": "14.0.2.15.0", + "version": "14.0.3.0.0", "author": "Commit [Sun], Odoo Community Association (OCA)", "license": "AGPL-3", "application": True, diff --git a/pms_l10n_es/migrations/14.0.3.0.0/post-migration.py b/pms_l10n_es/migrations/14.0.3.0.0/post-migration.py new file mode 100644 index 0000000000..01d5cc3315 --- /dev/null +++ b/pms_l10n_es/migrations/14.0.3.0.0/post-migration.py @@ -0,0 +1,20 @@ +import logging +import xml.etree.cElementTree as ET + +from openupgradelib import openupgrade + +_logger = logging.getLogger(__name__) + + +@openupgrade.migrate() +def migrate(env, version): + _logger.info("Get commuication_ids from soap process response...") + for ses_communication in env["pms.ses.communication"].search( + [ + ("state", "=", "processed"), + ("entity", "=", "RH"), + ("operation", "=", "A"), + ] + ): + root = ET.fromstring(ses_communication.response_query_status_soap) + ses_communication.communication_id = root.find(".//codigoComunicacion").text diff --git a/pms_l10n_es/migrations/14.0.3.0.0/pre-migration.py b/pms_l10n_es/migrations/14.0.3.0.0/pre-migration.py new file mode 100644 index 0000000000..5f45404232 --- /dev/null +++ b/pms_l10n_es/migrations/14.0.3.0.0/pre-migration.py @@ -0,0 +1,14 @@ +import logging + +from openupgradelib import openupgrade + +_logger = logging.getLogger(__name__) + +_field_renames = [ + ("pms.ses.communication", "pms_ses_communication", "communication_id", "batch_id"), +] + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.rename_fields(env, _field_renames) diff --git a/pms_l10n_es/models/pms_ses_communication.py b/pms_l10n_es/models/pms_ses_communication.py index a96ad54376..41056c62b6 100644 --- a/pms_l10n_es/models/pms_ses_communication.py +++ b/pms_l10n_es/models/pms_ses_communication.py @@ -22,6 +22,10 @@ class PmsSesCommunication(models.Model): index=True, store=True, ) + batch_id = fields.Char( + string="Batch ID", + default=False, + ) communication_id = fields.Char( string="Communication ID", help="ID of the communication", @@ -99,5 +103,5 @@ def force_send_communication(self): for record in self: self.env["traveller.report.wizard"].ses_send_communication( entity=record.entity, - communication_id=record.communication_id, + pms_ses_communication_id=record.id, ) diff --git a/pms_l10n_es/static/description/index.html b/pms_l10n_es/static/description/index.html index c122d88ab6..5da882c396 100644 --- a/pms_l10n_es/static/description/index.html +++ b/pms_l10n_es/static/description/index.html @@ -8,11 +8,10 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ +:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. -Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +274,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: gray; } /* line numbers */ +pre.code .ln { color: grey; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +300,7 @@ span.pre { white-space: pre } -span.problematic, pre.problematic { +span.problematic { color: red } span.section-subtitle { @@ -415,9 +414,7 @@

Contributors

Maintainers

This module is maintained by the OCA.

- -Odoo Community Association - +Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

diff --git a/pms_l10n_es/views/pms_ses_communication_views.xml b/pms_l10n_es/views/pms_ses_communication_views.xml index 440961e459..bf363a0a60 100644 --- a/pms_l10n_es/views/pms_ses_communication_views.xml +++ b/pms_l10n_es/views/pms_ses_communication_views.xml @@ -8,6 +8,7 @@ + @@ -52,6 +53,7 @@ > + @@ -73,6 +75,7 @@ + diff --git a/pms_l10n_es/wizards/traveller_report.py b/pms_l10n_es/wizards/traveller_report.py index 2fec5fa5a5..11913dc7e1 100644 --- a/pms_l10n_es/wizards/traveller_report.py +++ b/pms_l10n_es/wizards/traveller_report.py @@ -335,7 +335,7 @@ def _generate_payload(lessor_id, operation, entity, data): {lessor_id} Roomdoo {operation} - {entity} + {''+entity+'' if entity else ''} {data} @@ -1072,13 +1072,13 @@ def generate_xml_reservations_travellers_report( return xml_str @api.model - def ses_send_communications(self, entity, communication_id=False): + def ses_send_communications(self, entity, pms_ses_communication_id=False): domain = [ ("state", "=", "to_send"), ("entity", "=", entity), ] - if communication_id: - domain.append(("id", "=", communication_id)) + if pms_ses_communication_id: + domain.append(("id", "=", pms_ses_communication_id)) for communication in self.env["pms.ses.communication"].search(domain): data = False try: @@ -1135,15 +1135,16 @@ def ses_send_communications(self, entity, communication_id=False): communication.response_communication_soap = soap_response.text result_code = root.find(".//codigo").text if result_code == REQUEST_CODE_OK: - communication.communication_id = root.find(".//lote").text + communication.batch_id = root.find(".//lote").text + communication.state = "to_process" else: communication.state = "error_sending" - except requests.exceptions.RequestException as e: - _handle_request_exception(communication, e) except requests.exceptions.HTTPError as http_err: _handle_request_exception(communication, http_err) + except requests.exceptions.RequestException as e: + _handle_request_exception(communication, e) except Exception as e: _handle_request_exception(communication, e) @@ -1199,18 +1200,17 @@ def ses_send_incomplete_traveller_reports( communication.response_communication_soap = soap_response.text result_code = root.find(".//codigo").text if result_code == REQUEST_CODE_OK: - communication.communication_id = root.find(".//lote").text + communication.batch_id = root.find(".//lote").text if communication.operation == CREATE_OPERATION_CODE: communication.state = "to_process" else: communication.state = "processed" else: communication.state = "error_sending" - - except requests.exceptions.RequestException as e: - _handle_request_exception(communication, e) except requests.exceptions.HTTPError as http_err: _handle_request_exception(communication, http_err) + except requests.exceptions.RequestException as e: + _handle_request_exception(communication, e) except Exception as e: _handle_request_exception(communication, e) @@ -1226,7 +1226,7 @@ def ses_process_communications(self): var_xml_get_batch = f""" - {communication.communication_id} + {communication.batch_id} """ communication.query_status_xml = var_xml_get_batch @@ -1249,13 +1249,15 @@ def ses_process_communications(self): ) soap_response.raise_for_status() root = ET.fromstring(soap_response.text) - communication.response_communication_soap = soap_response.text result_code = root.find(".//codigo").text communication.response_query_status_soap = soap_response.text if result_code == REQUEST_CODE_OK: result_status = root.find(".//codigoEstado").text if result_status == XML_OK: communication.state = "processed" + communication.communication_id = root.find( + ".//codigoComunicacion" + ).text communication.processing_result = root.find( ".//descripcion" ).text @@ -1269,9 +1271,9 @@ def ses_process_communications(self): else: communication.state = "error_processing" communication.processing_result = root.find(".//descripcion").text - except requests.exceptions.RequestException as e: - _handle_request_exception(communication, e) except requests.exceptions.HTTPError as http_err: _handle_request_exception(communication, http_err) + except requests.exceptions.RequestException as e: + _handle_request_exception(communication, e) except Exception as e: _handle_request_exception(communication, e) From 9ebd10266d67202f49ef613dc9fb400ade167347 Mon Sep 17 00:00:00 2001 From: miguelpadin Date: Thu, 5 Dec 2024 09:51:28 +0000 Subject: [PATCH 2/3] [FIX] pms-l10n_es: fix to process SES delete communications --- pms_l10n_es/wizards/traveller_report.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pms_l10n_es/wizards/traveller_report.py b/pms_l10n_es/wizards/traveller_report.py index 11913dc7e1..b90bf10295 100644 --- a/pms_l10n_es/wizards/traveller_report.py +++ b/pms_l10n_es/wizards/traveller_report.py @@ -335,7 +335,9 @@ def _generate_payload(lessor_id, operation, entity, data): {lessor_id} Roomdoo {operation} - {''+entity+'' if entity else ''} + { + ''+entity+'' if entity else '' + } {data} @@ -1219,7 +1221,6 @@ def ses_process_communications(self): for communication in self.env["pms.ses.communication"].search( [ ("state", "=", "to_process"), - ("operation", "!=", DELETE_OPERATION_CODE), ] ): try: @@ -1234,7 +1235,7 @@ def ses_process_communications(self): payload = _generate_payload( communication.reservation_id.pms_property_id.institution_lessor_id, "C", - "", + False, data, ) communication.query_status_soap = payload From a711b9e5832fc9548a46d77059d37bc514f46eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Lodeiros?= Date: Thu, 5 Dec 2024 11:58:32 +0100 Subject: [PATCH 3/3] [FIX]pms_l10n_es: fix migrations 14.0.3 scripts --- .../migrations/14.0.3.0.0/post-migration.py | 11 ++++++++++- pms_l10n_es/migrations/14.0.3.0.0/pre-migration.py | 14 -------------- pms_l10n_es/static/description/index.html | 11 +++++++---- 3 files changed, 17 insertions(+), 19 deletions(-) delete mode 100644 pms_l10n_es/migrations/14.0.3.0.0/pre-migration.py diff --git a/pms_l10n_es/migrations/14.0.3.0.0/post-migration.py b/pms_l10n_es/migrations/14.0.3.0.0/post-migration.py index 01d5cc3315..2f75872078 100644 --- a/pms_l10n_es/migrations/14.0.3.0.0/post-migration.py +++ b/pms_l10n_es/migrations/14.0.3.0.0/post-migration.py @@ -8,7 +8,6 @@ @openupgrade.migrate() def migrate(env, version): - _logger.info("Get commuication_ids from soap process response...") for ses_communication in env["pms.ses.communication"].search( [ ("state", "=", "processed"), @@ -18,3 +17,13 @@ def migrate(env, version): ): root = ET.fromstring(ses_communication.response_query_status_soap) ses_communication.communication_id = root.find(".//codigoComunicacion").text + ses_communication.batch_id = root.find(".//lote").text + + # Retry all communications type delete, set status to to_send + env["pms.ses.communication"].search( + [ + ("state", "in", ["processed", "error_processing"]), + ("entity", "=", "RH"), + ("operation", "=", "D"), + ] + ).write({"state": "to_send"}) diff --git a/pms_l10n_es/migrations/14.0.3.0.0/pre-migration.py b/pms_l10n_es/migrations/14.0.3.0.0/pre-migration.py deleted file mode 100644 index 5f45404232..0000000000 --- a/pms_l10n_es/migrations/14.0.3.0.0/pre-migration.py +++ /dev/null @@ -1,14 +0,0 @@ -import logging - -from openupgradelib import openupgrade - -_logger = logging.getLogger(__name__) - -_field_renames = [ - ("pms.ses.communication", "pms_ses_communication", "communication_id", "batch_id"), -] - - -@openupgrade.migrate() -def migrate(env, version): - openupgrade.rename_fields(env, _field_renames) diff --git a/pms_l10n_es/static/description/index.html b/pms_l10n_es/static/description/index.html index 5da882c396..c122d88ab6 100644 --- a/pms_l10n_es/static/description/index.html +++ b/pms_l10n_es/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -414,7 +415,9 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.