Udo Spallek
unread,Jul 16, 2016, 11:22:19 AM7/16/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to try...@googlegroups.com
Hi,
in a many2one field definition I want to set a domain for a
specific resource in ir.attachments. Is it possible to create such a
domain in a fields definition or do I need to use a function field?
My non working code looks like this::
class Content(ModelSQL, ModelView):
__name__ = 'content'
original_data = fields.Many2One( # 1. try
'ir.attachment', domain=[
('resource', '=', ('content', Eval('id')))])
original_data = fields.Many2One( # 2. try
'ir.attachment', domain=[
('resource', '=', (__name__, Eval('id')))])
Both tries raises the following error:
Traceback (most recent call last):
File "/usr/local/bin/trytond", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/ado/src/trytond/bin/trytond", line 80, in <module>
trytond.server.TrytonServer(options).run()
File "/ado/src/trytond/trytond/server.py", line 98, in run
Pool(db_name).init(update=self.options.update, lang=lang)
File "/ado/src/trytond/trytond/pool.py", line 140, in init
self.start()
File "/ado/src/trytond/trytond/pool.py", line 92, in start
register_classes()
File "/ado/src/trytond/trytond/modules/__init__.py", line 351, in
register_classes
mod_file, pathname, description)
File "/ado/src/collecting_society/__init__.py", line 5, in <module>
from .collecting_society import *
File "/ado/src/collecting_society/collecting_society.py", line 585,
in <module>
class Content(ModelSQL, ModelView):
File "/ado/src/collecting_society/collecting_society.py", line 614,
in Content
'ir.attachment', domain=[('resource', '=', ('content',
Eval('id')))])
File "/ado/src/trytond/trytond/model/fields/many2one.py", line 49, in
__init__
depends=depends, context=context, loading=loading)
File "/ado/src/trytond/trytond/model/fields/field.py", line 142, in
__init__
assert string, 'a string is required'
AssertionError: a string is required
It seems I need to create a string for the resource, which is a fields
reference, but how can I do this with PYSON?
Do you have experience in this?
TIA,
best Udo Spallek