Il giorno martedì 19 dicembre 2017 07:38:05 UTC+1, Cato Nano ha scritto:
> Il giorno lunedì 18 dicembre 2017 17:27:03 UTC+1, Mark Shane Hayden ha 
> scritto:
> > On Dec 18, 2017 04:08, "Cato Nano" <[email protected]> wrote:
> > Now that a list of entities represented by my model get correctly shown, I 
> > want to add a selection field to my model. Like this
> > 
> > 
> > 
> > 
> > 
> >     tipo = fields.Selection('tipo', [
> > 
> >         ('M', 'Male')
> > 
> >         ('F', 'Female')
> > 
> >     ],
> > 
> >     )
> > 
> > 
> > You need to separate your tuples with commas in the selection list like 
> > this:
> >     ('M', 'Male),
> >     ('F', 'Female')
> > 
> > 
> > without the comma it looks to the Python interpreter like the second tuple 
> > is parameters and the first tuple is a function hence the error.
> > 
> > 
> > 
> > 
> > 
> > I copied this from the manual, here
> > 
> > http://doc.tryton.org/4.6/trytond/doc/ref/models/fields.html#ref-models-fields
> > 
> > 
> > 
> > when updating the module like this
> > 
> > 
> > 
> > :~/tributi$ sudo python3 setup.py develop
> > 
> > :~/tributi$ sudo trytond-admin -c /etc/tryton/trytond.conf -d tryton -u 
> > tributi
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > i get this error
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Traceback (most recent call last):
> > 
> >   File "/usr/bin/trytond-admin", line 21, in <module>
> > 
> >     admin.run(options)
> > 
> >   File "/usr/lib/python3/dist-packages/trytond/admin.py", line 54, in run
> > 
> >     installdeps=options.installdeps)
> > 
> >   File "/usr/lib/python3/dist-packages/trytond/pool.py", line 142, in init
> > 
> >     self.start()
> > 
> >   File "/usr/lib/python3/dist-packages/trytond/pool.py", line 95, in start
> > 
> >     register_classes()
> > 
> >   File "/usr/lib/python3/dist-packages/trytond/modules/__init__.py", line 
> > 373, in register_classes
> > 
> >     mod_file, pathname, description)
> > 
> >   File "/usr/lib/python3.6/imp.py", line 245, in load_module
> > 
> >     return load_package(name, filename)
> > 
> >   File "/usr/lib/python3.6/imp.py", line 217, in load_package
> > 
> >     return _load(spec)
> > 
> >   File "<frozen importlib._bootstrap>", line 684, in _load
> > 
> >   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
> > 
> >   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
> > 
> >   File "<frozen importlib._bootstrap>", line 219, in 
> > _call_with_frames_removed
> > 
> >   File "/home/admin/tributi/build/lib/trytond/modules/tributi/__init__.py", 
> > line 2, in <module>
> > 
> >     from .bolletta import Bolletta
> > 
> >   File "/home/admin/tributi/build/lib/trytond/modules/tributi/bolletta.py", 
> > line 6, in <module>
> > 
> >     class Bolletta(ModelSQL, ModelView):
> > 
> >   File "/home/admin/tributi/build/lib/trytond/modules/tributi/bolletta.py", 
> > line 13, in Bolletta
> > 
> >     ('F', 'Female')
> > 
> > TypeError: 'tuple' object is not callable
> > 
> > 
> > 
> > 
> > 
> > Thanks in advance !
> > 
> > 
> > 
> > --
> > 
> > You received this message because you are subscribed to the Google Groups 
> > "tryton" group.
> > 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/tryton/8ddc439a-f4cb-49bc-a5aa-09d7e4201e58%40googlegroups.com.
> 
> thank you people
> 
> I managed to make it work
> 
> I found a selection field in the "sales" module and copied that code and 
> adapted it
> 
> Thats how I discovered that the options list ought to be the first argument
> 
> For now I have no "form" view for my bolletta so I can t test the drop down 
> menu
> 
> But the field shows up in a tree view, so I guess it s ok
> 
> Thanks !

ok, now I also have a form view and the selction field works like a charm !!

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/3c58acb5-7774-44e6-b437-1b39f1940b0e%40googlegroups.com.

Reply via email to