El 18/07/17 a les 08:49, [email protected] ha escrit:
Hi,
I found in party/tests/test_party a json syntax to pass data to populate a
model with proteus, but I see a « keys error » when trying to use it:
Python 2.7.13 (default, Apr 23 2017, 16:56:24)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
from proteus import config, Model, Wizard
def set_config(database, user, config_file=None):
... return config.set_trytond(database, user, config_file=config_file)
...
config = set_config(u't44_4', u'admin',
'/Users/jcm/Sites/_tryton/tryton4.4/my_local_trytond.conf')
Party = Model.get('party.party')
party1, = Party.create([{
... 'name': 'Party 1',
... }])
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/Users/jcm/Sites/_tryton/tryton4.4/proteus/proteus/config.py", line
169, in __call__
rpc.convert(self._object, *args)
File "/Users/jcm/Sites/_tryton/tryton4.4/trytond/trytond/rpc.py", line 36,
in convert
for key in context.keys():
AttributeError: 'list' object has no attribute ‘keys'
You should pass the proteus config as last argument as you are calling
and rpc method directly.
If you want to create a list of objects using proteus, i will recomend
using save with a list of records:
records = []
for x in range(10):
record = Model()
record.xxx = yyy
records.append(record)
Model.save(records)
Hope it helps.
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk
--
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/dade3e29-107c-0e77-f30a-9c15784a833b%40koolpi.com.