restful-openerp
restful-openerp copied to clipboard
OpenERP v7
Is this compatible with OpenERP v7?
I haven't tested OpenERP v7 yet, don't know about the changes they made to the XML-RPC interface. In general, restful-openerp is independent of the particular object model in the database, so newly added fields etc. shouldn't be a problem...
Thanks for the info, we are considering using this to solve the need for a customer to put together with OpenCart, later I let you know how it goes.
That would be great! Please note that this project is developed in a "feature added when needed" way, so in particular a number of things (such as DELETE or more complicated workflows) are not implemented yet. Also I'd be happy about patches (AGPL license) or any other feedback.
First of all i would like to thank you for this program.It's really nicely written. But you see i am using openERP v7 and when im sending GET requests it is working good, But when im sending POST request and one of the fields is one2many i have a problem. This is xml im trying to post:
<?xml version="1.0" encoding="utf-8"?>
<pa:pio_address xmlns:pa="http://localhost:8068/pio_novi48/pio.address/schema" >
<pa:id />
<pa:city type='char'>Mladenovac</pa:city>
<pa:name type='text'>11400 Mladenovac, Masarikova 7</pa:name>
<pa:country type='many2one' relation='http://localhost:8068/pio_novi48/survey.type'>
<link href='/pio_novi48/survey.type/5' />
</pa:country>
<pa:full_address type='text'>11400 BJELOVAR, Masarikova 7</pa:full_address>
<pa:postal_code type='char'>11400</pa:postal_code>
<pa:address type='char'>Masarikova 7</pa:address>
</pa:pio_address>
and various rest clients are showing me this error:
invalid XML:
If you know the answer i would be really gratefull if you could help me. Thanks in advance
@shomy4 What you see is a validation error because (according to the schema of pio.address), the element <pa:country>
should not contain any links to other objects. Are you sure that you have defined country
as a many2one relation to survey
? Can you post the contents of the GET output on that same resource? You may have to define a root namespace that defines the <link>
element, too.
Thank you for your quick answer.
Here is response for this url:
http://localhost:8068/pio_novi48/pio.address/156
Response:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text">43000 BJELOVAR, Masarikova 7</title>
<id>http://localhost:8068/pio_novi48/pio.address/156</id>
<updated>2014-12-24T21:32:28Z</updated>
<link href="http://localhost:8068/pio_novi48/pio.address/156" rel="self" />
<author>
<name>None</name>
</author>
<content type="application/vnd.openerp+xml">
<pa:pio_address xmlns:pa="http://localhost:8068/pio_novi48/pio.address/schema">
<pa:city type='char'>BJELOVAR</pa:city>
<pa:name type='text'>43000 BJELOVAR, Masarikova 7</pa:name>
<pa:country type='many2one' relation='http://localhost:8068/pio_novi48/survey.type'>
<link href='http://localhost:8068/pio_novi48/survey.type/5' />
</pa:country>
<pa:full_address type='text'>43000 BJELOVAR, Masarikova 7</pa:full_address>
<pa:postal_code type='char'>43000</pa:postal_code>
<pa:address type='char'>Masarikova 7</pa:address>
<pa:id>156</pa:id>
</pa:pio_address>
</content>
</entry>
I see. So, in the GET response, you see <link>
without a prefix, but actually it is in the http://www.w3.org/2005/Atom
namespace (see the xmlns
declaration in the <entry>
element). It needs to be the same in your POST body. Try to modify the link
you post to
<link xmlns='http://www.w3.org/2005/Atom' href='/pio_novi48/survey.type/5' />
Thanks Now it's not complaining and row is inserted in database but without country field, and im positive there is survey.type with id=5. The GET response of newly created object is:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text">11400 Mladenovac, Masarikova 7</title>
<id>http://localhost:8068/pio_novi48/pio.address/184</id>
<updated>2015-02-20T13:52:17Z</updated>
<link href="http://localhost:8068/pio_novi48/pio.address/184" rel="self" />
<author>
<name>None</name>
</author>
<content type="application/vnd.openerp+xml">
<pa:pio_address xmlns:pa="http://localhost:8068/pio_novi48/pio.address/schema">
<pa:city type='char'>Mladenovac</pa:city>
<pa:name type='text'>11400 Mladenovac, Masarikova 7</pa:name>
<pa:country type='many2one' relation='http://localhost:8068/pio_novi48/survey.type'><!-- False --></pa:country>
<pa:full_address type='text'>11400 Mladenovac, Masarikova 7</pa:full_address>
<pa:postal_code type='char'>11400</pa:postal_code>
<pa:address type='char'>Masarikova 7</pa:address>
<pa:id>184</pa:id>
</pa:pio_address>
</content>
</entry>
I had a looked at the code (specifically https://github.com/tgpfeiffer/restful-openerp/blob/master/restfulOpenErpProxy.py#L578) and I think the href
must contain the full link, not just the path. Try
<link xmlns='http://www.w3.org/2005/Atom' href='http://localhost:8068/pio_novi48/survey.type/5' />
Sir, Thank you very much. :+1:
Hello,
I have tried to add support for binary field, because i haven't found it in your code.
In your method __addToCollection i added 2 more lines:
elif c.attrib["type"] == "binary":
fields[tagname] = base64.b64encode(c.text)
and this is the error i am getting:
"cannot marshal None unless allow_none is enabled"
I found someplace that this solves the error, but i cannot find the part where i can insert this code:
sock = xmlrpclib.ServerProxy('http://localhost:' + port + '/xmlrpc/common', allow_none=True)
Can you help me with support for binary field?
Thanks in advance.
I 've managed to do it. In Proxy constructor i added this allowNone=True. Thanks anyway. :)