msgs = []
for rec in self:
if len(rec.name_search_ids) > 4:
msgs.append(
"You have selected more than 4 fields for smart search, "
"fewerer fields is recommended"
)
if any(x.translate for x in rec.name_search_ids):
msgs.append(
"You have selected translatable fields in the smart search,"
" try to avoid them if possible"
)
# rec.smart_search_warning = msg
if msgs:
rec.smart_search_warning = (
f"<p>In case of performance issues we recommend to review "
f"these suggestions: <ul>"
f"{''.join(f'<li>{x}</li>' for x in msgs)}</ul></p>"
)
else:
rec.smart_search_warning = False
|