# Error throws on clicking the plus button at Many2Many list

**URL:** https://discuss.tryton.org/t/error-throws-on-clicking-the-plus-button-at-many2many-list/8794
**Category:** Developer
**Created:** [August 25, 2025, 5:34pm UTC](https://discuss.tryton.org/t/error-throws-on-clicking-the-plus-button-at-many2many-list/8794 "2025-08-25T17:34:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bromoapp](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bromoapp](https://discuss.tryton.org/u/bromoapp)
#### Post date: [August 25, 2025, 5:34pm UTC](https://discuss.tryton.org/t/error-throws-on-clicking-the-plus-button-at-many2many-list/8794/1 "2025-08-25T17:34:53Z")

</div>

I have 3 related classes:  
The **1st** is:

```auto
class Note(ModelSQL, ModelView):
    'Note'
    __name__ = 'ltl.common.note'

    date = fields.Date('Date', required=True, states={
        'readonly': True
    })

    note = fields.Text('Note')

    @classmethod
    def default_date(cls):
        return datetime.today()

```

The **2nd** is:

```auto
class ProjectNote(ModelSQL, ModelView):
    'Project Note'
    __name__ = 'ltl.project.note'

    project = fields.Many2One('ltl.project', 'Project', required=True)
    
    note = fields.Many2One('ltl.common.note', 'Note', required=True)

```

The **3rd** is:

```auto
class Project(ModelSQL, ModelView):
    'Project'
    __name__ = 'ltl.project'

    name = fields.Char('Name', required=True)

    remarks = fields.Many2Many('ltl.project.note', 'project', 'note', 'Remarks',
        states={
            'readonly': Eval('id', -1) < 0
        },
        depends=['id'],
        domain=[
            ('project', '=', Eval('id'))
        ]
    )

```

I dunno why, but the **domain** at **remarks** field in the **3rd** class has cause:

```auto
[Mon Aug 25 17:27:29 2025] ERROR:trytond.protocols.dispatcher:ltl.common.note.search([[['project', '=', 1]], ...], 0, 1000, None, {'client': '706d045c-5270-40f...', 'language': 'en', 'language_directio...': 'ltr', 'groups': [1, 4]}) from admin@127.0.0.1/tryton/ in 0 ms [dispatcher.py:253]
Traceback (most recent call last):
  File "/home/tryton/project/.env/lib/python3.10/site-packages/trytond/protocols/dispatcher.py", line 216, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/home/tryton/project/.env/lib/python3.10/site-packages/trytond/model/modelsql.py", line 1819, in search
    super().search(
  File "/home/tryton/project/.env/lib/python3.10/site-packages/trytond/model/modelstorage.py", line 711, in search
    check_domain(domain, cls, to_check)
  File "/home/tryton/project/.env/lib/python3.10/site-packages/trytond/model/modelstorage.py", line 695, in check_domain
    check_domain(d, cls, to_check)
  File "/home/tryton/project/.env/lib/python3.10/site-packages/trytond/model/modelstorage.py", line 695, in check_domain
    check_domain(d, cls, to_check)
  File "/home/tryton/project/.env/lib/python3.10/site-packages/trytond/model/modelstorage.py", line 674, in check_domain
    field = cls._fields[local]
KeyError: 'project'

```

Why is the **domain** cause error while in **ltl.project.note** it has **project** field?  
When I take out the **domain** all are fine, its just listing the un-related notes which I don’t want it.

Bromo

---

<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: [August 25, 2025, 10:05pm UTC](https://discuss.tryton.org/t/error-throws-on-clicking-the-plus-button-at-many2many-list/8794/2 "2025-08-25T22:05:56Z")

</div>

> [@bromoapp](#):
>
> ```auto
> domain=[
> ('project', '=', Eval('id'))
> ]
> 
> ```

The domain of a `Many2Many` field is on the target model not the relation model.  
So I do not think you need this domain at all.

---

<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: [August 26, 2025, 10:06pm UTC](https://discuss.tryton.org/t/error-throws-on-clicking-the-plus-button-at-many2many-list/8794/3 "2025-08-26T22:06:13Z")

</div>

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