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 !

-- 
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/a36d7bc2-2a27-4ff6-8f53-fba5f1e5279a%40googlegroups.com.

Reply via email to