[FIX] pms-l10n_es: rename field communication_id -> batch_id, extract from ses processing communication communication_id, not re set communication result, etc.

This commit is contained in:
miguelpadin
2024-12-04 12:15:48 +00:00
parent 832c20322a
commit 2724ef31dd
7 changed files with 64 additions and 24 deletions

View File

@@ -3,7 +3,7 @@
{ {
"name": "PMS Spanish Adaptation", "name": "PMS Spanish Adaptation",
"version": "14.0.2.15.0", "version": "14.0.3.0.0",
"author": "Commit [Sun], Odoo Community Association (OCA)", "author": "Commit [Sun], Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"application": True, "application": True,

View File

@@ -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

View File

@@ -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)

View File

@@ -22,6 +22,10 @@ class PmsSesCommunication(models.Model):
index=True, index=True,
store=True, store=True,
) )
batch_id = fields.Char(
string="Batch ID",
default=False,
)
communication_id = fields.Char( communication_id = fields.Char(
string="Communication ID", string="Communication ID",
help="ID of the communication", help="ID of the communication",
@@ -99,5 +103,5 @@ class PmsSesCommunication(models.Model):
for record in self: for record in self:
self.env["traveller.report.wizard"].ses_send_communication( self.env["traveller.report.wizard"].ses_send_communication(
entity=record.entity, entity=record.entity,
communication_id=record.communication_id, pms_ses_communication_id=record.id,
) )

View File

@@ -8,11 +8,10 @@
/* /*
:Author: David Goodger (goodger@python.org) :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. :Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils. 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 See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet. customize this style sheet.
@@ -275,7 +274,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ; margin-left: 2em ;
margin-right: 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, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 } pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +300,7 @@ span.option {
span.pre { span.pre {
white-space: pre } white-space: pre }
span.problematic, pre.problematic { span.problematic {
color: red } color: red }
span.section-subtitle { span.section-subtitle {
@@ -415,9 +414,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2> <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p> <p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>

View File

@@ -8,6 +8,7 @@
<sheet> <sheet>
<group> <group>
<field name="reservation_id" /> <field name="reservation_id" />
<field name="batch_id" />
<field name="communication_id" /> <field name="communication_id" />
<field name="operation" /> <field name="operation" />
<field name="entity" /> <field name="entity" />
@@ -52,6 +53,7 @@
> >
<field name="pms_property_id" /> <field name="pms_property_id" />
<field name="reservation_id" /> <field name="reservation_id" />
<field name="batch_id" />
<field name="communication_id" /> <field name="communication_id" />
<field name="operation" /> <field name="operation" />
<field name="entity" /> <field name="entity" />
@@ -73,6 +75,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<search string="Log SES Communications"> <search string="Log SES Communications">
<field name="pms_property_id" widget="selection" /> <field name="pms_property_id" widget="selection" />
<field name="batch_id" />
<field name="communication_id" /> <field name="communication_id" />
<field name="reservation_id" /> <field name="reservation_id" />
<!-- filters --> <!-- filters -->

View File

@@ -335,7 +335,7 @@ def _generate_payload(lessor_id, operation, entity, data):
<codigoArrendador>{lessor_id}</codigoArrendador> <codigoArrendador>{lessor_id}</codigoArrendador>
<aplicacion>Roomdoo</aplicacion> <aplicacion>Roomdoo</aplicacion>
<tipoOperacion>{operation}</tipoOperacion> <tipoOperacion>{operation}</tipoOperacion>
<tipoComunicacion>{entity}</tipoComunicacion> {'<tipoComunicacion>'+entity+'</tipoComunicacion>' if entity else ''}
</cabecera> </cabecera>
<solicitud>{data}</solicitud> <solicitud>{data}</solicitud>
</peticion> </peticion>
@@ -1072,13 +1072,13 @@ class TravellerReport(models.TransientModel):
return xml_str return xml_str
@api.model @api.model
def ses_send_communications(self, entity, communication_id=False): def ses_send_communications(self, entity, pms_ses_communication_id=False):
domain = [ domain = [
("state", "=", "to_send"), ("state", "=", "to_send"),
("entity", "=", entity), ("entity", "=", entity),
] ]
if communication_id: if pms_ses_communication_id:
domain.append(("id", "=", communication_id)) domain.append(("id", "=", pms_ses_communication_id))
for communication in self.env["pms.ses.communication"].search(domain): for communication in self.env["pms.ses.communication"].search(domain):
data = False data = False
try: try:
@@ -1135,15 +1135,16 @@ class TravellerReport(models.TransientModel):
communication.response_communication_soap = soap_response.text communication.response_communication_soap = soap_response.text
result_code = root.find(".//codigo").text result_code = root.find(".//codigo").text
if result_code == REQUEST_CODE_OK: if result_code == REQUEST_CODE_OK:
communication.communication_id = root.find(".//lote").text communication.batch_id = root.find(".//lote").text
communication.state = "to_process" communication.state = "to_process"
else: else:
communication.state = "error_sending" communication.state = "error_sending"
except requests.exceptions.RequestException as e:
_handle_request_exception(communication, e)
except requests.exceptions.HTTPError as http_err: except requests.exceptions.HTTPError as http_err:
_handle_request_exception(communication, http_err) _handle_request_exception(communication, http_err)
except requests.exceptions.RequestException as e:
_handle_request_exception(communication, e)
except Exception as e: except Exception as e:
_handle_request_exception(communication, e) _handle_request_exception(communication, e)
@@ -1199,18 +1200,17 @@ class TravellerReport(models.TransientModel):
communication.response_communication_soap = soap_response.text communication.response_communication_soap = soap_response.text
result_code = root.find(".//codigo").text result_code = root.find(".//codigo").text
if result_code == REQUEST_CODE_OK: 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: if communication.operation == CREATE_OPERATION_CODE:
communication.state = "to_process" communication.state = "to_process"
else: else:
communication.state = "processed" communication.state = "processed"
else: else:
communication.state = "error_sending" communication.state = "error_sending"
except requests.exceptions.RequestException as e:
_handle_request_exception(communication, e)
except requests.exceptions.HTTPError as http_err: except requests.exceptions.HTTPError as http_err:
_handle_request_exception(communication, http_err) _handle_request_exception(communication, http_err)
except requests.exceptions.RequestException as e:
_handle_request_exception(communication, e)
except Exception as e: except Exception as e:
_handle_request_exception(communication, e) _handle_request_exception(communication, e)
@@ -1226,7 +1226,7 @@ class TravellerReport(models.TransientModel):
var_xml_get_batch = f""" var_xml_get_batch = f"""
<con:lotes <con:lotes
xmlns:con="http://www.neg.hospedajes.mir.es/consultarComunicacion"> xmlns:con="http://www.neg.hospedajes.mir.es/consultarComunicacion">
<con:lote>{communication.communication_id}</con:lote> <con:lote>{communication.batch_id}</con:lote>
</con:lotes> </con:lotes>
""" """
communication.query_status_xml = var_xml_get_batch communication.query_status_xml = var_xml_get_batch
@@ -1249,13 +1249,15 @@ class TravellerReport(models.TransientModel):
) )
soap_response.raise_for_status() soap_response.raise_for_status()
root = ET.fromstring(soap_response.text) root = ET.fromstring(soap_response.text)
communication.response_communication_soap = soap_response.text
result_code = root.find(".//codigo").text result_code = root.find(".//codigo").text
communication.response_query_status_soap = soap_response.text communication.response_query_status_soap = soap_response.text
if result_code == REQUEST_CODE_OK: if result_code == REQUEST_CODE_OK:
result_status = root.find(".//codigoEstado").text result_status = root.find(".//codigoEstado").text
if result_status == XML_OK: if result_status == XML_OK:
communication.state = "processed" communication.state = "processed"
communication.communication_id = root.find(
".//codigoComunicacion"
).text
communication.processing_result = root.find( communication.processing_result = root.find(
".//descripcion" ".//descripcion"
).text ).text
@@ -1269,9 +1271,9 @@ class TravellerReport(models.TransientModel):
else: else:
communication.state = "error_processing" communication.state = "error_processing"
communication.processing_result = root.find(".//descripcion").text 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: except requests.exceptions.HTTPError as http_err:
_handle_request_exception(communication, http_err) _handle_request_exception(communication, http_err)
except requests.exceptions.RequestException as e:
_handle_request_exception(communication, e)
except Exception as e: except Exception as e:
_handle_request_exception(communication, e) _handle_request_exception(communication, e)