# Error unhashable type: 'dict' when using ir.note in a form

**URL:** https://discuss.tryton.org/t/error-unhashable-type-dict-when-using-ir-note-in-a-form/4458
**Category:** Developer
**Created:** [July 23, 2021, 5:33pm UTC](https://discuss.tryton.org/t/error-unhashable-type-dict-when-using-ir-note-in-a-form/4458 "2021-07-23T17:33:35Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [July 23, 2021, 5:33pm UTC](https://discuss.tryton.org/t/error-unhashable-type-dict-when-using-ir-note-in-a-form/4458/1 "2021-07-23T17:33:36Z")

</div>

To make access to the notes on a record more easily I’ve added a new field to the model like:

```auto
messages = fields.One2Many('ir.note', 'resource', 'Notes')

```

In the view I added:

```xml
<page string="Notes" id="notes">
    <field name="messages" colspan="4"/>
</page>

```

This worked in version 5.4 like you would expect. All the notes linked to that particular record are shown. However after upgrading to 6.0 I got an error from the client:

```auto
ERROR:tryton.common.common: File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/view/form_gtk/one2many.py", line 344, in _sig_new
    self._new_single()
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/view/form_gtk/one2many.py", line 361, in _new_single
    WinForm(self.screen, lambda a: update_sequence(), new=True,
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/win_form.py", line 54, in __init__
    self.screen.new(rec_name=rec_name)
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/screen/screen.py", line 627, in new
    group.add(record, self.new_position)
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/model/group.py", line 341, in add
    self.signal('group-changed', record)
  File "/home/tryton/tryton-6.0.4/tryton/signal_event.py", line 15, in signal
    fnct(self, signal_data, *data)
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/model/field.py", line 551, in _group_changed
    parent.signal('record-changed')
  File "/home/tryton/tryton-6.0.4/tryton/signal_event.py", line 15, in signal
    fnct(self, signal_data, *data)
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/model/group.py", line 448, in _record_changed
    self.signal('group-changed', record)
  File "/home/tryton/tryton-6.0.4/tryton/signal_event.py", line 15, in signal
    fnct(self, signal_data, *data)
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/screen/screen.py", line 451, in _group_changed
    self.display()
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/screen/screen.py", line 944, in display
    view.display()
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/view/form.py", line 539, in display
    widget.display()
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/view/form_gtk/one2many.py", line 534, in display
    self.screen.display()
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/screen/screen.py", line 944, in display
    view.display()
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/view/form.py", line 539, in display
    widget.display()
  File "/home/tryton/tryton-6.0.4/tryton/gui/window/view_form/view/form_gtk/multiselection.py", line 79, in display
    self.update_selection(self.record, self.field)
  File "/home/tryton/tryton-6.0.4/tryton/common/selection.py", line 58, in update_selection
    self.init_selection(value)
  File "/home/tryton/tryton-6.0.4/tryton/common/selection.py", line 31, in init_selection
    and key not in self._values2selection):

TypeError: unhashable type: 'dict'

```

Is this a bug in the client and have I create a bug report or am I doing something wrong?

---

<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: [July 23, 2021, 9:11pm UTC](https://discuss.tryton.org/t/error-unhashable-type-dict-when-using-ir-note-in-a-form/4458/2 "2021-07-23T21:11:02Z")

</div>

For me the problem is not directly related to this change but it looks like a `MultiSelection` field is wrongly defined. I think the `selection_change_with` contains a `dict` instead of just field name strings.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [July 23, 2021, 9:32pm UTC](https://discuss.tryton.org/t/error-unhashable-type-dict-when-using-ir-note-in-a-form/4458/3 "2021-07-23T21:32:16Z")

</div>

I just removed the `copy_to_resources` field from the `note_form.xml` because that’s the only `MultiSelection` I can find in the `ir.note`. And that was indeed the culprit. I can now add new notes, open the form to see more information.

Now it’s time to dig a bit deeper and see if we can fix it by returning the right data.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [July 23, 2021, 9:46pm UTC](https://discuss.tryton.org/t/error-unhashable-type-dict-when-using-ir-note-in-a-form/4458/4 "2021-07-23T21:46:50Z")

</div>

Hmm, I think that the problem lies at the client side.

- adding a new note from my defined view:  
`{(('resource', None),): []}`

- adding a new note from the list of notes with the ‘notes’ button  
`{(('resource', None),): [], (('resource', 'asset,8'),): []}`

Do I need to add some `context` to my `messages` field?

---

<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: [July 24, 2021, 7:16am UTC](https://discuss.tryton.org/t/error-unhashable-type-dict-when-using-ir-note-in-a-form/4458/5 "2021-07-24T07:16:11Z")

</div>

It should be fixed by [MultiSelection fails to init with Reference field in selection change set by parent (#10603) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue10603)

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [July 24, 2021, 8:48am UTC](https://discuss.tryton.org/t/error-unhashable-type-dict-when-using-ir-note-in-a-form/4458/6 "2021-07-24T08:48:08Z")

</div>

Thanks 👍 ! this indeed fixes it.

---

<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 23, 2021, 8:48am UTC](https://discuss.tryton.org/t/error-unhashable-type-dict-when-using-ir-note-in-a-form/4458/7 "2021-08-23T08:48:11Z")

</div>

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