This question has been flagged
3 Replies
4475 Views

Im using odoo API to generate a pickinglist.

idn = models.execute_kw(db, uid, password, 'stock.picking', 'create', [{
     'name' : "INTERNAL/002",
     'location_id': "39",
     'picking_type_id': "26",
     'location_dest_id': "37",
}])

But i would like the name to be generated from the correct number series in the picking type id ?

How should i code that ? or am I using the wrong code?


Avatar
Discard

Hi, try without giving the name, i think the name will get created automatically as the create function get called. I am not sure, just try it .

Author

I have tested with no name, it didn't work. Maybe there is another reason why it dosn't work, like missing some data to get name autogenerated.

No name gives following error:

Traceback (most recent call last):

File "./test.py", line 40, in <module>

'location_dest_id': "37",

File "/usr/lib/python2.7/xmlrpclib.py", line 1243, in __call__

return self.__send(self.__name, args)

File "/usr/lib/python2.7/xmlrpclib.py", line 1602, in __request

verbose=self.__verbose

File "/usr/lib/python2.7/xmlrpclib.py", line 1283, in request

return self.single_request(host, handler, request_body, verbose)

File "/usr/lib/python2.7/xmlrpclib.py", line 1316, in single_request

return self.parse_response(response)

File "/usr/lib/python2.7/xmlrpclib.py", line 1493, in parse_response

return u.close()

File "/usr/lib/python2.7/xmlrpclib.py", line 800, in close

raise Fault(**self._stack[0])

xmlrpclib.Fault: <Fault 4: '(u"Database fetch misses ids (\'26\') and has extra ids (26), may be caused by a type incoherence in a previous request", None)'>

Author Best Answer

I changed the code to:

idn = models.execute_kw(db, uid, password, 'stock.picking', 'create', [{
     'location_id': 39,
     'picking_type_id': 26,
     'location_dest_id': 37,
     'company_id': 3,
}])

No name company_id if many I guess, no name and numbers instead of string


Avatar
Discard