Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Improved Name Search

Entity: ir.model

Compute Method: _compute_smart_search_warning

Inputs Method Outputs
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

Back to entity