From 5e344b73ccb91961cbb9fec8d23a47cd27a0784f Mon Sep 17 00:00:00 2001 From: dorra-benamor <122746341+dorra-benamor@users.noreply.github.com> Date: Mon, 21 Aug 2023 09:47:58 +0200 Subject: [PATCH] Fix filter and sorting in debug mode (#23) Fix #PJAZZ-1168 Fix #PJAZZ-1050 --- coopengo_modules/debug/debug.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/coopengo_modules/debug/debug.py b/coopengo_modules/debug/debug.py index d357f64d09a..867cbb51145 100644 --- a/coopengo_modules/debug/debug.py +++ b/coopengo_modules/debug/debug.py @@ -5,6 +5,7 @@ from collections import defaultdict import pprint import logging +import unicodedata from trytond.wizard import Wizard, StateTransition, StateView, Button from trytond.config import config @@ -282,14 +283,15 @@ def recalculate_field_infos(self): all_fields_infos = [ info for info in all_fields_infos if info is not None] if self.name_filter: - name_filter = self.name_filter.replace('_', '').replace( - ' ', '').lower() + name_filter = self.name_filter.lower() all_fields_infos = [ info for info in all_fields_infos if self.match_filter_name(name_filter, info)] self.field_infos = sorted( [x for x in all_fields_infos], - key=lambda x: getattr(x, self.filter_value)) + key=lambda x: unicodedata.normalize('NFKD', + getattr(x, self.filter_value)).encode('ascii', + 'ignore').decode('ascii')) if self.id_to_calculate: for field in self.field_infos: try: @@ -300,8 +302,8 @@ def recalculate_field_infos(self): @staticmethod def match_filter_name(name_filter, info): - return (name_filter in info.string.replace(' ', '').lower() or - name_filter in info.name.replace('_', '')) + return (name_filter in info.string.lower() or + name_filter in info.name) @classmethod def raw_field_info(cls, base_model, field_name):