# List on a wizard stateview

**URL:** https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608
**Category:** Developer
**Created:** [April 19, 2020, 1:48pm UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608 "2020-04-19T13:48:45Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![fransuar](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/f/59ef9b/32.png) [@fransuar](https://discuss.tryton.org/u/fransuar)
#### Post date: [April 19, 2020, 1:48pm UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/1 "2020-04-19T13:48:45Z")

</div>

Hi,  
I am having some issues using tryton 4.6 module on tryton 5.0  
The issue is with a One2Many list based on a ModelView class.  
I tried to scrap an example of the code, so I don’t have to copy all the original.  
The idea behind is to fullfill a list (the one2many) with something.

```
class Element(ModelView):
   'Element'
    __name__ = 'list.element'

    foo = fields.Char("Foo")

class ListElement(ModelView):
    'List Element'
    __name__ = 'list.list'

    elements = fields.One2Many('list.element',None,'Cobertura',
        readonly=True)

class MyWizard(Wizard):
    'The wiz'
    __name__ = 'fill.list'

    start = 'start'
    start = StateView(....)
    check_existence = StateTransition()
    found = StateView(....) # asociated to a view related to ListElement model
    not_found = StateView(....)
    show_results = StateAction(....)

    def transition_check_existence(self):
        Party = Pool().get('party.party')
        (.....)
        parties = Party.search(something)
        names = []
        if parties:
            name = [x.name for x in parties]
            self.found.names = names
            return 'found'
        return 'not found'
    
    def default_found(self):
        elements = []
        element = {}
        for name in self.found.names:
            element['name'] = name
            elements.append(name)
            element = {}
        return{
                'elements': elements,
                }
            
    def do_show_results(self):
        (...)

```

When I try to run the wizard, it’s ok on the start state, but in the found state gives me this error:

```
File "/home/fran/.local/lib/python3.6/site-packages/tryton/common/common.py", line 999, in process
    self.callback(return_)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/wizard.py", line 108, in callback
    self.update(view['fields_view'], view['buttons'])
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/wizard.py", line 361, in update
    super(WizardDialog, self).update(view, buttons)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/wizard.py", line 202, in update
    self.screen.add_view(view)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/screen/screen.py", line 581, in add_view
    self, view_id, view['type'], xml_dom, view.get('field_childs'))
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/ __init__.py", line 74, in parse
    return ViewForm(view_id, screen, root)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/form.py", line 413, in __init__
    super(). __init__ (view_id, screen, xml)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/ __init__.py", line 35, in __init__
    ).parse(xml)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/ __init__.py", line 130, in parse
    parser(node, node_attrs)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/form.py", line 196, in _parse_form
    self.parse_child(node, container)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/form.py", line 203, in parse_child
    self.parse(child)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/ __init__.py", line 130, in parse
    parser(node, node_attrs)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/form.py", line 341, in _parse_group
    self.parse_child(node, group)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/form.py", line 203, in parse_child
    self.parse(child)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/ __init__.py", line 130, in parse
    parser(node, node_attrs)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/form.py", line 341, in _parse_group
    self.parse_child(node, group)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/form.py", line 203, in parse_child
    self.parse(child)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/ __init__.py", line 130, in parse
    parser(node, node_attrs)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/form.py", line 213, in _parse_field
    widget = self.WIDGETS[attributes['widget']](self.view, attributes)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/form_gtk/one2many.py", line 165, in __init__
    limit=None)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/screen/screen.py", line 139, in __init__
    self.switch_view()
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/screen/screen.py", line 514, in switch_view
    self.load_view_to_load()
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/screen/screen.py", line 540, in load_view_to_load
    self.add_view_id(view_id, view_type)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/screen/screen.py", line 553, in add_view_id
    return self.add_view(view)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/screen/screen.py", line 581, in add_view
    self, view_id, view['type'], xml_dom, view.get('field_childs'))
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/ __init__.py", line 72, in parse
    return ViewTree(view_id, screen, root, children_field)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/list.py", line 451, in __init__
    super(). __init__ (view_id, screen, xml)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/ __init__.py", line 35, in __init__
    ).parse(xml)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/ __init__.py", line 130, in parse
    parser(node, node_attrs)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/list.py", line 287, in _parse_tree
    self.parse(child)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/ __init__.py", line 130, in parse
    parser(node, node_attrs)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/list.py", line 291, in _parse_field
    widget = self.WIDGETS[attributes['widget']](self.view, attributes)
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/gui/window/view_form/view/list_gtk/widget.py", line 932, in __init__
    self.init_selection()
  File "/home/fran/.local/lib/python3.6/site-packages/tryton/common/selection.py", line 43, in init_selection
    selection.sort(key=operator.itemgetter(1))

TypeError: '<' not supported between instances of 'str' and 'NoneType'

```

Thanks in advance

---

<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: [April 19, 2020, 2:23pm UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/2 "2020-04-19T14:23:13Z")

</div>

> [@fransuar](#):
>
> I am having some issues using tryton 4.6 module on tryton 5.0

This is not supported. You must use always the same series.

---

<div class="post-metadata">

### Author: ![fransuar](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/f/59ef9b/32.png) [@fransuar](https://discuss.tryton.org/u/fransuar)
#### Post date: [April 19, 2020, 9:39pm UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/3 "2020-04-19T21:39:29Z")

</div>

> [@ced](#):
>
> This is not supported. You must use always the same series.

Yes, I know. It’s a module from my own.

I’m trying to migrate the code from 4.6 to 5.0. I found what lines are the ones wich cause the error, but I can’t interpret the error log.  
Apparently, it’s trying to order the one2many list trough an inexistent field (the "`  
TypeError: ‘\<’ not supported between instances of ‘str’ and ‘NoneType’ " line on the error log).

Don’t know why, but in this series it doesn’t work as it did it on the others.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 19, 2020, 9:59pm UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/4 "2020-04-19T21:59:55Z")

</div>

> [@fransuar](#):
>
> Apparently, it’s trying to order the one2many list trough an inexistent field (the "`  
> TypeError: ‘\<’ not supported between instances of ‘str’ and ‘NoneType’ " line on the error log).

This is an error raised on python3 when comparing None to a string. On python2 this did not cause any error.

For example (on python2):

```python
>>> '' < None
False

```

but on python3:

```python
>>> '' < None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: '<' not supported between instances of 'str' and 'NoneType'

```

Probably removing the non existent field from the order will solve the issue.

---

<div class="post-metadata">

### Author: ![fransuar](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/f/59ef9b/32.png) [@fransuar](https://discuss.tryton.org/u/fransuar)
#### Post date: [April 19, 2020, 10:53pm UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/5 "2020-04-19T22:53:17Z")

</div>

> [@pokoli](#):
>
> Probably removing the non existent field from the order will solve the issue.

Nice. We are getting closer then.  
The question itself will be wich field is that one.

Changing the one2many target to a ModelSQL class (party.party), it gives me no error. Could it be possible that using a ModelView class is the origin of that error? Is there any tip/hint to solve this?

Thanks

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 20, 2020, 7:23am UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/6 "2020-04-20T07:23:51Z")

</div>

> [@fransuar](#):
>
> Could it be possible that using a ModelView class is the origin of that error? Is there any tip/hint to solve this?

If you use a ModelView you should use None as target of the relation.

---

<div class="post-metadata">

### Author: ![fransuar](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/f/59ef9b/32.png) [@fransuar](https://discuss.tryton.org/u/fransuar)
#### Post date: [April 20, 2020, 11:34am UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/7 "2020-04-20T11:34:27Z")

</div>

> [@pokoli](#):
>
> If you use a ModelView you should use None as target of the relation.

Indeed, I am using a None as the field of the model target (see the example code)

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 20, 2020, 11:53am UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/8 "2020-04-20T11:53:33Z")

</div>

So probably there is an error on the model definition or something else.

I’m sorry but without the full code I can not provide more advices.

---

<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: [April 20, 2020, 12:20pm UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/9 "2020-04-20T12:20:17Z")

</div>

You can not use One2Many with None on a wizard, you must use a Many2Many with a couple of None’s.  
But the error is not about that but about a selection widget that is used with values having `None` as string.

---

<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: [April 20, 2020, 2:24pm UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/10 "2020-04-20T14:24:23Z")

</div>

What does the server-side say? You have now only given the error on the client-side.

---

<div class="post-metadata">

### Author: ![fransuar](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/f/59ef9b/32.png) [@fransuar](https://discuss.tryton.org/u/fransuar)
#### Post date: [April 21, 2020, 2:29pm UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/11 "2020-04-21T14:29:50Z")

</div>

> [@pokoli](#):
>
> So probably there is an error on the model definition or something else.

This was the answer!!! Every answer get me closer and closer to the final solution.

I did a mistake on one fields.Selection.  
I put a tuple like (‘’, None) instead of (None, ‘’).

> [@pokoli](#):
>
> This is an error raised on python3 when comparing None to a string. On python2 this did not cause any error.

Like pokoli saids, the code works fine on python2, but returns an error on python3

> [@ced](#):
>
> But the error is not about that but about a selection widget that is used with values having `None` as string.

And like cedric saids, it was about a selection field.

Thank you 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: [May 21, 2020, 2:29pm UTC](https://discuss.tryton.org/t/list-on-a-wizard-stateview/2608/12 "2020-05-21T14:29:52Z")

</div>

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