Create New Party Record

26 views
Skip to first unread message

Akshay patel

unread,
May 25, 2016, 9:50:06 AM5/25/16
to tryton

I try to create a new party record as follow:

{

"method": "model.party.party.create",

"params": [5, "02d34f6c010a46e4aab8a9deb4a12d17", {

"first_name": "p",

"name": "A"

}, {

"values": {

"first_name": "p",

"name": "A"

}

}]

}


But gives me ERROR as follow:



{

  "id": 0,

  "error": [

    "'unicode' object has no attribute 'copy'",

    "Traceback (most recent call last):\n  File \"/trytond/protocols/wsgi/__init__.py\", line 55, in jsonrpc_app\n    response['result'] = dispatch(*args)\n  File \"/trytond/protocols/dispatcher.py\", line 158, in dispatch\n    result = rpc.result(meth(*c_args, **c_kwargs))\n  File \"/trytond/modules/party/party.py\", line 205, in create\n    vlist = [x.copy() for x in vlist]\nAttributeError: 'unicode' object has no attribute 'copy'\n"

  ]

}



Help me to solve this

Sergi Almacellas Abellana

unread,
May 25, 2016, 10:02:54 AM5/25/16
to try...@googlegroups.com
El 25/05/16 a les 13:18, Akshay patel ha escrit:
>
> *I try to create a new party record as follow:*
>
> {
>
> "method": "model.party.party.create",
>
> "params": [5, "02d34f6c010a46e4aab8a9deb4a12d17", {
>
> "first_name": "p",
>
> "name": "A"
>
> }, {
>
> "values": {
>
> "first_name": "p",
>
> "name": "A"
>
> }
>
> }]
>
> }
>

The create method expects a list of dictionaries as explained in the docs[1]

I see you have a "values" dictionary which doest not seem correct, so
the following parameters:

[{"first_name": "p","name": "A"}, {"first_name": "p","name": "A"}]

Will create two parties, with name A and first_name p.

Hope it helps!


[1]
http://doc.tryton.org/4.0/trytond/doc/ref/models/models.html?highlight=create#trytond.model.ModelStorage.create


--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Akshay patel

unread,
May 26, 2016, 3:20:06 AM5/26/16
to tryton
I try following :

{
"method": "model.party.party.create",
"params": {
"first_name": "p",
"name": "A"
}
}

Error

<html>
    <head>
        <title>502 Bad Gateway</title>
    </head>
    <body bgcolor="white">
        <center>
            <h1>502 Bad Gateway</h1>
        </center>
        <hr>
        <center>nginx/1.4.1</center>
    </body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->

Sergi Almacellas Abellana

unread,
May 26, 2016, 3:29:06 AM5/26/16
to try...@googlegroups.com
El 26/05/16 a les 09:01, Akshay patel ha escrit:
> I try following :
>
> {
> "method": "model.party.party.create",
> "params": {
> "first_name": "p",
> "name": "A"
> }
> }

Params has to be a list of dictionaries.

> *
> *
> *Error*
> *
> *
> <html>
> <head>
> <title>502 Bad Gateway</title>
> </head>
> <body bgcolor="white">
> <center>
> <h1>502 Bad Gateway</h1>
> </center>
> <hr>
> <center>nginx/1.4.1</center>
> </body>
> </html>

This is error is unrelated to tryton, basically you have an nginx proxy
which is unable to contact the tryton server. So double check your
trytond is running.

PS: Please don't top-post on this mailing list, see
http://groups.tryton.org/netiquette
Reply all
Reply to author
Forward
0 new messages