Search for full name in tryton

For special development, I need to add lastname to party_party.

It works well, except when I try to search for full name (name + lastname).

I added this code, and works when I search for name or lastname but no when I use both at same time.

For example,

John works fine
Doe works fine
John Doe doesn’t work

    def search_rec_name(cls, name, clause):
        _, operator, operand, *extra = clause
        if operator.startswith('!') or operator.startswith('not '):
            bool_op = 'AND'
            bool_op = 'OR'
        code_value = operand
        if operator.endswith('like') and is_full_text(operand):
            code_value = lstrip_wildcard(operand)
        return [bool_op,
            ('code', operator, code_value, *extra),
            ('identifiers.code', operator, code_value, *extra),
            ('name', operator, operand, *extra),
            ('lastname', operator, operand, *extra),
            ('contact_mechanisms.rec_name', operator, operand, *extra),

I will thank any help.

Of course you could split each word in the operand and create an AND-ed domain with each part.

But I would advise to not change the name for the first-name but add a first and last-name (and optionally build the name from them).
Also the first-name and last-name could be new types of identifiers.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.