Calling find method in scenario

20 views
Skip to first unread message

Christophe (.net)

unread,
Dec 14, 2017, 2:41:05 AM12/14/17
to tryton-dev
Hello,

I try to calling 'find' method in a scenario with this piece of code:

Period = Model.get('account.period')
period = Period.find(company.id)

and when i running the scenario the followikg error appear

File
"/home/ccr/Technique/tryton/ate-dev/trytond/trytond/modules/account_asset/tests/scenario_account_asset.rst",
line 143, in scenario_account_asset.rst
Failed example:
period = Period.find(company.id)
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.7/doctest.py", line 1315, in __run
compileflags, 1) in test.globs
File "<doctest scenario_account_asset.rst[83]>", line 1, in <module>
period = Period.find(company.id)
File
"/home/ccr/Technique/tryton/ate-dev/proteus/proteus/__init__.py", line
765, in find
cls._config.context)
File
"/home/ccr/Technique/tryton/ate-dev/proteus/proteus/config.py", line
172, in __call__
result = rpc.result(meth(*args, **kwargs))
File
"/home/ccr/Technique/tryton/ate-dev/trytond/trytond/modules/account/period.py",
line 227, in search
args = args[:]
TypeError: 'int' object has no attribute '__getitem__'

it would seem that the method called is that of proteus and not that of
the class Period. How to call that of the class?


Regards.
--
Christophe CRIER
Adiczion - http://adiczion.com

Sergi Almacellas Abellana

unread,
Dec 14, 2017, 3:23:42 AM12/14/17
to tryto...@googlegroups.com
El 14/12/17 a les 08:41, Christophe (.net) ha escrit:
> Hello,
>
> I try to calling 'find' method in a scenario with this piece of code:
>
> Period = Model.get('account.period')
> period = Period.find(company.id)
The problem is that the find method on attribute is used to perform a
search. And that's why you get an error.

Indeed, the find method is not available throw RPC and thus it's not
possible to call it on proteus.

Hope it helps.

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk
Reply all
Reply to author
Forward
0 new messages