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