From 5f870ed29b4d67729a7513e3e1c1dacc1b07da4b Mon Sep 17 00:00:00 2001 From: "Pedram (pebr)" Date: Tue, 23 Apr 2024 17:08:41 +0200 Subject: [PATCH] [FIX] l10n_fr_pos_cert: log hash string for better error investigation This commit add the logging of hash string data. By printing the string to hash, it becomes easier to investigate issues. opw-3839287 Part-of: odoo/odoo#163018 --- addons/l10n_fr_pos_cert/models/pos.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/l10n_fr_pos_cert/models/pos.py b/addons/l10n_fr_pos_cert/models/pos.py index 7a69ca08ada..57f71cc6b53 100644 --- a/addons/l10n_fr_pos_cert/models/pos.py +++ b/addons/l10n_fr_pos_cert/models/pos.py @@ -2,13 +2,16 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from datetime import datetime, timedelta from hashlib import sha256 -from json import dumps +from json import dumps, loads +import logging from odoo import models, api, fields from odoo.fields import Datetime from odoo.tools.translate import _, _lt from odoo.exceptions import UserError +_logger = logging.getLogger(__name__) + class pos_config(models.Model): _inherit = 'pos.config' @@ -63,7 +66,15 @@ class pos_order(models.Model): _('An error occurred when computing the inalterability. Impossible to get the unique previous posted point of sale order.')) #build and return the hash - return self._compute_hash(prev_order.l10n_fr_hash if prev_order else u'') + computed_hash = self._compute_hash(prev_order.l10n_fr_hash if prev_order else '') + _logger.info( + 'Computed hash for order ID %s: %s \n String to hash: %s \n Previous hash: %s', + self.id, + computed_hash, + dumps(loads(self.l10n_fr_string_to_hash), indent=2), + prev_order.l10n_fr_hash + ) + return computed_hash def _compute_hash(self, previous_hash): """ Computes the hash of the browse_record given as self, based on the hash