2
votes

I am trying save record from django (front-end) to openerp (back-end). I am using openerp webservice using xmlrpclib. It works well with normal string and number data, but when i tried to pass date field, it throws error. cannot marshal <type 'datetime.date'> objects

Please help me..

2
It looks like it cannot be done by xmlrpc. You should try to pickle it or convert to string.Lukasz Puchala
convert the date into string and then pass the valueSenthilnathan
Thanks to all for your support. I got solution, First I have to covert date into ISO 8601 format to pass as xmlrpc object.Vimal Rughani

2 Answers

2
votes

To solve the cannot marshal <type 'datetime.date'> objects error, first convert the date into ISO 8601 format, and then pass it as an object to xmlrpclib.

For example:

    dob = form.date_of_birth
    xmlrpc_dob = dob.strftime("%Y%m%dT%H:%M:%S")

For more details you can read the official Python documentation of xmlrpclib.

0
votes

Aternatively you can promote datetime.date() to datetime.datetime() before sending the reply.