# Search for full name in tryton

**URL:** https://discuss.tryton.org/t/search-for-full-name-in-tryton/6754
**Category:** Developer
**Created:** [December 6, 2023, 12:10am UTC](https://discuss.tryton.org/t/search-for-full-name-in-tryton/6754 "2023-12-06T00:10:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![iehoshia](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/iehoshia/32/243_2.png) [@iehoshia](https://discuss.tryton.org/u/iehoshia)
#### Post date: [December 6, 2023, 12:10am UTC](https://discuss.tryton.org/t/search-for-full-name-in-tryton/6754/1 "2023-12-06T00:10:06Z")

</div>

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

```auto
    @classmethod
    def search_rec_name(cls, name, clause):
        _, operator, operand, *extra = clause
        if operator.startswith('!') or operator.startswith('not '):
            bool_op = 'AND'
        else:
            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.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 6, 2023, 8:34am UTC](https://discuss.tryton.org/t/search-for-full-name-in-tryton/6754/2 "2023-12-06T08:34:23Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [December 8, 2023, 6:37pm UTC](https://discuss.tryton.org/t/search-for-full-name-in-tryton/6754/3 "2023-12-08T18:37:27Z")

</div>

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